GambasSelftests integer overflow tests

[DEVELOPMENT ENVIRONMENT]
* NEW: GambasSelftests integer overflow tests
* FIX: GambasSelftests run.sh just tests without JIT

Also refactored GambasSelftests a bit and removed some duplicated code
This commit is contained in:
Christof Thalhofer 2023-01-13 11:49:43 +01:00
parent b0041e93ef
commit 1a8fdb41b7
6 changed files with 43 additions and 87 deletions

View file

@ -2,7 +2,7 @@
Title=Gambas3 Selftest
Startup=mTest
Icon=.hidden/logo.png
Version=3.17.90
Version=3.18.90
VersionFile=1
Component=gb.image
Component=gb.gui

View file

@ -4,83 +4,16 @@ Export
Fast
Private fTime As Float = Timer
Library "libc:6"
Private Extern modf(param As Float, pp As Pointer) As Float
#If SYSTEM = "Linux"
Private sSystem As String = "Linux"
#Else If SYSTEM = "FreeBSD"
Private sSystem As String = "FreeBSD"
#Else If SYSTEM = "OpenBSD"
Private sSystem As String = "OpenBSD"
#Else If SYSTEM = "NetBSD"
Private sSystem As String = "NetBSD"
#Else If SYSTEM = "Solaris"
Private sSystem As String = "Solaris"
#Else
Private sSystem As String = "Unknown"
#Endif
#If ARCHITECTURE = "x86"
Private sArchitecture As String = "x86"
#Else If ARCHITECTURE = "x86_64"
Private sArchitecture As String = "x86_64"
#Else If ARCHITECTURE = "ARM"
Private sArchitecture As String = "ARM"
#Else If ARCHITECTURE = "PPC"
Private sArchitecture As String = "PPC"
#Else
Private sArchitecture As String = "Unknown"
#Endif
#If Debug
Private DebuggingEnabled As Boolean = True
#Else
Private DebuggingEnabled As Boolean = False
#Endif
Private $sGrep As String
Private sSearch As New String[]
Private Const TestConst2 As Integer = 2
Public Const LowestLong As Long = -9223372036854775808
Public Const HighestLong As Long = 9223372036854775807
Public Const LowestInteger As Integer = -2147483648
Public Const HighestInteger As Integer = 2147483647
Public Const LowestShort As Short = -32768
Public Const HighestShort As Short = 32767
Public Struct MyPoint
x As Integer
y As Integer
End Struct
Private arr As New Integer[2, 2]
Private hProcess As Process
Private sTest As String '
Private hStillHere1 As New MyPoint
Private Enum Zero, One, Two
Public hFormForEvent As New TestClass3
Private iTestAndIf As Integer = 0
Private Errors As New String[]
Private hFile2 As File
Private iseek As Integer
Private hCrash2 As New ChildClass
Private bRun As Boolean = False
Public Const kkX As Integer = 1999
Public Const kkY As Integer = 1499
Public hChild As New ChildClass
Public timo As Integer
@ -90,9 +23,6 @@ Public Const gHour As Integer = 30833
Public Const bbb As Integer = 50
Public bArray As New Boolean[100]
Private ctrl_dc[7] As Integer
Public sPublic As String = "Test"
Fast Private Sub VoidFn()

View file

@ -1,11 +1,7 @@
' Gambas test file
'Export
Fast
'Private fTime As Float = Timer
Library "libc:6"
Private Extern modf(param As Float, pp As Pointer) As Float
@ -722,12 +718,6 @@ Fast Public Function FastTests() As Integer
Assert.Fail("CShort")
Endif
Test.Note("CShort Overflow")
Test.TODO("Expected error, that an overflow happened in CShort")
Dim siShort As Short
Try siShort = CShort(100000)
Assert.Error()
Test.Note("CSingle")
If Format$(CSingle("+3.1416"), "#.####") <> Str$(3.1416) Or CSingle("1.0E+3") <> 1000 Then
'' Or CSng(Pi) <> 3.141592741013 Then' Actually gives 3.14159274101257 Which is correct?
@ -2314,3 +2304,35 @@ Fast Public Function _TestAndIf() As Integer
Return 0
End
Fast Public Sub IntegerOverflows()
Dim s As Short
Dim i As Integer
Dim l As Integer
Test.Note("Short Overflow")
Try s = HighestShort + 1
Assert.Error("Short overflow error")
Test.Note("Integer Overflow")
Try i = HighestInteger + 1
Assert.Error("Int overflow error")
Test.Note("Long Overflow")
Try l = HighestLong + 1
Assert.Error("Long overflow error")
Test.Note("Short Underflow")
Try s = LowestShort - 1
Assert.Error("Short underflow error")
Test.Note("Integer Underflow")
Try i = LowestInteger - 1
Assert.Error("Int underflow error")
Test.Note("Long Underflow")
Try l = LowestLong - 1
Assert.Error("Long underflow error")
End

View file

@ -1,15 +1,15 @@
[TestSuites]
Count=4
TestWith=1
Default="Errorhandling.GeneralError"
Default="GambasSelftests.IntegerOverflows"
[TestSuites/1]
Name="Fast"
Tests="Errorhandling.GeneralError,GambasSelftests.FastTests;TCatch;TError;TVal,LocalStaticFun.CountALot;Saysth;SwingDoor"
Tests="Errorhandling.GeneralError,GambasSelftests.FastTests;IntegerOverflows;TCatch;TError;TVal,LocalStaticFun.CountALot;Saysth;SwingDoor"
[TestSuites/2]
Name="Full"
Tests="Errorhandling.GeneralError,FileReadWrite.FileReadWrite;ReadUrandom;ReadZero,GambasSelftests.FastTests;TCatch;TError;TVal,LocalStaticFun.CountALot;Saysth;SwingDoor,SlowThousandsProcs.FewThousandProcesses,Timers.Timers"
Tests="Errorhandling.GeneralError,FileReadWrite.FileReadWrite;ReadUrandom;ReadZero,GambasSelftests.FastTests;IntegerOverflows;TCatch;TError;TVal,LocalStaticFun.CountALot;Saysth;SwingDoor,SlowThousandsProcs.FewThousandProcesses,Timers.Timers"
[TestSuites/3]
Name="Slow tests"
@ -17,5 +17,5 @@ Tests="FileReadWrite.FileReadWrite;ReadUrandom;ReadZero,SlowThousandsProcs.FewTh
[TestSuites/4]
Name="Production"
Tests="Errorhandling.GeneralError,FileReadWrite.FileReadWrite;ReadUrandom;ReadZero,GambasSelftests.FastTests;TCatch;TError;TVal,LocalStaticFun.CountALot;Saysth;SwingDoor,SlowThousandsProcs.FewThousandProcesses"
Tests="Errorhandling.GeneralError,FileReadWrite.FileReadWrite;ReadUrandom;ReadZero,GambasSelftests.FastTests;IntegerOverflows;TCatch;TError;TVal,LocalStaticFun.CountALot;Saysth;SwingDoor,SlowThousandsProcs.FewThousandProcesses"

View file

@ -10,6 +10,9 @@ fi
MYDIR=$(cd `dirname $0` && pwd)
# run Production without JIT
echo "########### Run without JIT ############"
gbx3 -j -T "$TESTSUITE" $MYDIR
if [ $? -ne 0 ]
@ -19,7 +22,8 @@ then
fi
# run Production with JIT
GB_NO_JIT=01 GB_JIT_CFLAGS=-O0 gbx3 -T "$TESTSUITE" $MYDIR
echo "########### Now run with JIT ############"
GB_JIT_CFLAGS=-O0 gbx3 -T "$TESTSUITE" $MYDIR
if [ $? -ne 0 ]
then

View file

@ -1,6 +1,6 @@
[TestSuites]
Count=8
TestWith=4
TestWith=6
Default="TCrashes.DoACrash"
[TestSuites/1]