+ test for range checking (and against false positives for overflow checking)

git-svn-id: trunk@22809 -
This commit is contained in:
Jonas Maebe 2012-10-21 17:56:42 +00:00
parent 29263eb343
commit 027776a708
4 changed files with 122 additions and 0 deletions

1
.gitattributes vendored
View File

@ -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

View File

@ -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%

View File

@ -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

115
tests/test/jvm/ttincdec.pp Normal file
View File

@ -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.