mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-13 17:59:27 +02:00
Move test for read-only data to new separate test source treadonlydata.pp
git-svn-id: trunk@42747 -
This commit is contained in:
parent
94e22f1262
commit
c406d0121e
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -15065,6 +15065,7 @@ tests/test/trange3.pp svneol=native#text/plain
|
||||
tests/test/trange4.pp svneol=native#text/plain
|
||||
tests/test/trange5.pp svneol=native#text/plain
|
||||
tests/test/trangeob.pp svneol=native#text/plain
|
||||
tests/test/treadonlydata.pp svneol=native#text/pascal
|
||||
tests/test/trecreg.pp svneol=native#text/plain
|
||||
tests/test/trecreg2.pp svneol=native#text/plain
|
||||
tests/test/trecreg3.pp svneol=native#text/plain
|
||||
|
@ -1,10 +1,5 @@
|
||||
program tarray15;
|
||||
|
||||
{$define target_supports_rodata}
|
||||
{$if defined(msdos) or defined(hasamiga) or defined(atari) or defined(palmos)}
|
||||
{$undef target_supports_rodata}
|
||||
{$endif}
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
{ needed for "except" to work }
|
||||
@ -84,13 +79,6 @@ begin
|
||||
Halt(17);
|
||||
if not specialize CheckArray<LongInt>(rc1, [1, 2, 3]) then
|
||||
Halt(18);
|
||||
{$ifdef target_supports_rodata}
|
||||
try
|
||||
rc1[1] := 42;
|
||||
Halt(19);
|
||||
except
|
||||
end;
|
||||
{$endif}
|
||||
if not specialize CheckArray<LongInt>(wc1, [1, 2, 3]) then
|
||||
Halt(20);
|
||||
wc1[1] := 42;
|
||||
|
48
tests/test/treadonlydata.pp
Normal file
48
tests/test/treadonlydata.pp
Normal file
@ -0,0 +1,48 @@
|
||||
program treadonlydata;
|
||||
|
||||
{$define target_supports_rodata}
|
||||
{$if defined(msdos) or defined(hasamiga) or defined(atari) or defined(palmos)}
|
||||
{$undef target_supports_rodata}
|
||||
{$endif}
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
{ needed for "except" to work }
|
||||
uses
|
||||
SysUtils;
|
||||
|
||||
{$push}
|
||||
{$J-}
|
||||
const
|
||||
rc1: array of LongInt = (1, 2, 3);
|
||||
{$J+}
|
||||
const
|
||||
wc1: array of LongInt = (1, 2, 3);
|
||||
{$pop}
|
||||
|
||||
|
||||
begin
|
||||
{$ifdef target_supports_rodata}
|
||||
try
|
||||
rc1[1] := 42;
|
||||
writeln('Error: Trying to write read-only data did not generate an exception');
|
||||
Halt(1);
|
||||
except
|
||||
writeln('Trying to write read-only data generated exception');
|
||||
end;
|
||||
{$else}
|
||||
try
|
||||
rc1[1] := 42;
|
||||
writeln('Trying to write read-only data did not generate an exception, as expected');
|
||||
except
|
||||
writeln('Trying to write read-only data generated exception, while system is supposed not to support this');
|
||||
halt(2);
|
||||
end;
|
||||
{$endif}
|
||||
try
|
||||
wc1[1] := 42;
|
||||
except
|
||||
writeln('Error: Trying to write normal data generated exception');
|
||||
halt(3);
|
||||
end;
|
||||
end.
|
Loading…
Reference in New Issue
Block a user