From 027776a708e88e2d457ba85d1c95213e1d5fbec1 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Sun, 21 Oct 2012 17:56:42 +0000 Subject: [PATCH] + test for range checking (and against false positives for overflow checking) git-svn-id: trunk@22809 - --- .gitattributes | 1 + tests/test/jvm/testall.bat | 4 ++ tests/test/jvm/testall.sh | 2 + tests/test/jvm/ttincdec.pp | 115 +++++++++++++++++++++++++++++++++++++ 4 files changed, 122 insertions(+) create mode 100644 tests/test/jvm/ttincdec.pp diff --git a/.gitattributes b/.gitattributes index a7f96696ed..46de4c642c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -10296,6 +10296,7 @@ tests/test/jvm/tstring9.pp svneol=native#text/plain tests/test/jvm/tstrreal1.pp svneol=native#text/plain tests/test/jvm/tstrreal2.pp svneol=native#text/plain tests/test/jvm/tthreadvar.pp svneol=native#text/plain +tests/test/jvm/ttincdec.pp svneol=native#text/plain tests/test/jvm/ttrig.pp svneol=native#text/plain tests/test/jvm/ttrunc.pp svneol=native#text/plain tests/test/jvm/tval.inc svneol=native#text/plain diff --git a/tests/test/jvm/testall.bat b/tests/test/jvm/testall.bat index b931fff85b..283699b22f 100644 --- a/tests/test/jvm/testall.bat +++ b/tests/test/jvm/testall.bat @@ -248,3 +248,7 @@ ppcjvm -O2 -g -B tw22807 if %errorlevel% neq 0 exit /b %errorlevel% java -Dfile.encoding=UTF-8 -cp ..\..\..\rtl\units\jvm-java;. -Sa tw22807 if %errorlevel% neq 0 exit /b %errorlevel% +ppcjvm -O2 -g -B ttincdec.pp +if %errorlevel% neq 0 exit /b %errorlevel% +java -Dfile.encoding=UTF-8 -cp ..\..\..\rtl\units\jvm-java;. -Sa ttincdec +if %errorlevel% neq 0 exit /b %errorlevel% diff --git a/tests/test/jvm/testall.sh b/tests/test/jvm/testall.sh index 7c958554d6..b553a7c1f9 100755 --- a/tests/test/jvm/testall.sh +++ b/tests/test/jvm/testall.sh @@ -139,3 +139,5 @@ $PPC -O2 -g -B -Sa tsetansistr java -Dfile.encoding=UTF-8 -cp ../../../rtl/units/$RTLDIR:. tsetansistr $PPC -O2 -g -B -Sa tw22807 java -Dfile.encoding=UTF-8 -cp ../../../rtl/units/$RTLDIR:. tw22807 +$PPC -O2 -g -B -Sa ttincdec.pp +java -Dfile.encoding=UTF-8 -cp ../../../rtl/units/$RTLDIR:. ttincdec diff --git a/tests/test/jvm/ttincdec.pp b/tests/test/jvm/ttincdec.pp new file mode 100644 index 0000000000..bc72cee2a6 --- /dev/null +++ b/tests/test/jvm/ttincdec.pp @@ -0,0 +1,115 @@ +{$mode objfpc} + +program ttincdec; + +{$q+} +{$r+} + + +type + tenum = (ea,eb,ec,ed,ef,eg,eh); + +procedure testbool; +var + b: boolean; + caught: boolean; +begin + caught := false; + b := false; + inc(b); + try + inc(b); + except + on e: FpcRunTimeError do + caught := e.errornr=201; + end; + if not caught or + not b then + halt(1); + + caught := false; + dec(b); + try + dec(b); + except + on e: FpcRunTimeError do + caught := e.errornr=201; + end; + if not caught or + b then + halt(2); +end; + + +procedure testchar; +var + b: char; + caught: boolean; +begin + caught := false; + b := #254; + inc(b); + try + inc(b); + except + on e: FpcRunTimeError do + caught := e.errornr=201; + end; + if not caught or + (b <> #255) then + halt(3); + + caught := false; + b := #1; + dec(b); + try + dec(b); + except + on e: FpcRunTimeError do + caught := e.errornr=201; + end; + if not caught or + (b <> #0) then + halt(4); +end; + + + +procedure testenum; +var + b: tenum; + caught: boolean; +begin + caught := false; + b := eg; + inc(b); + try + inc(b); + except + on e: FpcRunTimeError do + caught := e.errornr=201; + end; + if not caught or + (b <> eh) then + halt(5); + + caught := false; + b := eb; + dec(b); + try + dec(b); + except + on e: FpcRunTimeError do + caught := e.errornr=201; + end; + if not caught or + (b <> ea) then + halt(6); +end; + + +begin + testbool; + testchar; + testenum; +end.