From 403043058cd7fe0b67928c70deca21f30ac05eed Mon Sep 17 00:00:00 2001 From: olle Date: Tue, 11 Jan 2005 21:23:36 +0000 Subject: [PATCH] + Added tests for mode macpas --- tests/test/tmacpas1.pp | 65 ++++++++++++++++++++++++++++++++++++++++++ tests/test/tmacpas2.pp | 59 ++++++++++++++++++++++++++++++++++++++ tests/test/umacpas1.pp | 59 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 183 insertions(+) create mode 100644 tests/test/tmacpas1.pp create mode 100644 tests/test/tmacpas2.pp create mode 100644 tests/test/umacpas1.pp diff --git a/tests/test/tmacpas1.pp b/tests/test/tmacpas1.pp new file mode 100644 index 0000000000..7343b959aa --- /dev/null +++ b/tests/test/tmacpas1.pp @@ -0,0 +1,65 @@ +program tmacpas1; + +{Tests of mac pascal constructs, concerning two units} + +{$MODE MACPAS} + +uses + umacpas1; + +{** Test exportable macros **} + +{$IFC UNDEFINED UMACPAS_COMP_VAR } +{$NOTE In using unit: UMACPAS_COMP_VAR is undefined} +{$ERRORC UMACPAS_COMP_VAR should be defined} +{$ELSEC} +{$IFC UMACPAS_COMP_VAR } +{$NOTE In using unit: UMACPAS_COMP_VAR is true} +{$ELSEC} +{$NOTE In using unit: UMACPAS_COMP_VAR is false} +{$ERRORC UMACPAS_COMP_VAR should be true} +{$ENDC} +{$ENDC} + +{$IFC UNDEFINED UMACPAS_PRE_IMPL_COMP_VAR } +{$ERRORC UMACPAS_PRE_IMPL_COMP_VAR is not defined} +{$ENDC} + +{$IFC UNDEFINED UMACPAS_PRE_IMPL_COMP_VAR } +{$ERRORC UMACPAS_PRE_IMPL_COMP_VAR is defined, while it shoud not} +{$ENDC} + +{** Test Push/Pop **} + +{$J-} + +{$PUSH} +{$PUSH} + +{$J+} + +{$POP} +{$POP} + +{$IFC OPTION(J)} +{$ERRORC $PUSH/$POP doesnt work properly} +{$ENDC} + +{** Test J directive for var and external for proc **} + +{$J+} +var + nisse: Integer; {Is available in Umacpas} +{$J-} + +function Get84: Integer; +external; + +begin + Writeln(nisse); + Writeln(Get84); + if nisse <> 42 then + halt(1); + if Get84 <> 84 then + halt(1); +end. diff --git a/tests/test/tmacpas2.pp b/tests/test/tmacpas2.pp new file mode 100644 index 0000000000..6b882c03af --- /dev/null +++ b/tests/test/tmacpas2.pp @@ -0,0 +1,59 @@ +{$MODE MACPAS} + +{Tests of mac pascal constructs} + +program tmacpas2; + +var + success: Boolean = true; + + +procedure Proc; + +begin + {** Exit with proc name as argument **} + Exit(Proc); +end; + +const + a = true; + b = true; + c = false; + +var + p: pointer; + l,i: longint; + +begin + {** Test & and | as alias for AND and OR **} + if not (a & b) then + success:= false; + if not (c | b) then + success:= false; + + {** Test that Ord() can take pointer values **} + p:= pointer(4711); + l:= Ord(p); + if l <> 4711 then + success:= false; + + i:= 0; + while true do + begin + i:= i+1; + if i = 1 then + Cycle; + Leave; + end; + if i<> 2 then + success:= false; + + + if success then + Writeln('Whole test succeded') + else + begin + Writeln('Whole test failed'); + halt(1); + end; +end. diff --git a/tests/test/umacpas1.pp b/tests/test/umacpas1.pp new file mode 100644 index 0000000000..f2323d7b97 --- /dev/null +++ b/tests/test/umacpas1.pp @@ -0,0 +1,59 @@ +unit umacpas1; + +{$DEFINE UMACPAS_PRE_INTERFACE_VAR} +{The above will _not_ be exported, unless it is redefined + after the mode switch (which it is). Note the non-macpas + style, because $mode macpas has not yet been parsed.} + +{$MODE MACPAS} + +interface +{$SETC UMACPAS_COMP_VAR = TRUE} +{The above macro is deliberatelly immediatelly after INTERFACE + to check that this works.} + +{$SETC UMACPAS_PRE_INTERFACE_VAR = TRUE} +{Is redefined here and thus exported..} + +{$IFC UMACPAS_COMP_VAR } +{$NOTE UMACPAS_COMP_VAR is true} +{$ELSEC} +{$NOTE UMACPAS_COMP_VAR is false} +{$ENDC} + +var + a: Integer; + +{The below macro should be exported} +{$SETC UMACPAS_PRE_IMPL_COMP_VAR = TRUE} +implementation +{$SETC UMACPAS_COMP_VAR = FALSE} +{The above macro is deliberatelly immediatelly after IMPLEMENTATION + to check that this works. Note that here UMACPAS_COMP_VAR is set to false, + but the exported value of UMACPAS_COMP_VAR should nevertheless be TRUE. } + +{$Z+} +var + nisse: Integer; + {To be available in tmacpas via the mode macpas $J directive} + +function Get84: Integer; + {To be available in tmacpas via EXTERNAL} + +begin + Get84:= 84; +end; + +{$Z-} + +{$IFC UMACPAS_PRE_INTERFACE_VAR } +{$NOTE UMACPAS_PRE_INTERFACE_VAR is true} +{$ELSEC} +{$ERRORC UMACPAS_PRE_INTERFACE_VAR is false} +{Erroneous since it was set to true in the interface section.} +{$ENDC} + + +begin + nisse:= 42; +end.