|
| 1 | +'-----PREPROCESSED BY picaxepreprocess.py----- |
| 2 | +'----UPDATED AT 02:41PM, December 27, 2020---- |
| 3 | +'----SAVING AS .\Examples\Ifs\compiled.bas ---- |
| 4 | + |
| 5 | +'---BEGIN .\Examples\Ifs\IfTest.bas --- |
| 6 | +; Test IFDEF, IFNDEF, ELSE, ELSEIFDEF, ELSEIFNDEF, ENDIF |
| 7 | +; PE6: 14M2 is 281 bytes |
| 8 | +; Preprocessor with the same compilers: 14M2 is also 281 bytes. Hopefully this means they match. |
| 9 | +; #REM [Commented out] |
| 10 | +; This is a block comment. Stuff like [Commented out] |
| 11 | +; #ERROR "is ignored... hopefully" [Commented out] |
| 12 | +; #ENDREM [Commented out] |
| 13 | + |
| 14 | +; #DEFINE TESTA 12 |
| 15 | +; #IFDEF TESTA ; Should be true |
| 16 | + sertxd("TESTA is defined") |
| 17 | +; #ENDIF |
| 18 | + |
| 19 | +; #DEFINE TESTB |
| 20 | +; #IFDEF TESTB ; Should be true |
| 21 | + sertxd("TESTB is defined") |
| 22 | +; #ENDIF |
| 23 | + |
| 24 | +; #IFDEF TESTA ; Should be true |
| 25 | +; #IFDEF TESTB ; Should be true |
| 26 | + sertxd("TESTA and TESTB are defined") |
| 27 | +; #ENDIF |
| 28 | +; ; #IFDEF TESTC ; Should not be true [#IF CODE REMOVED] |
| 29 | +; sertxd("TESTA and TESTC are defined") [#IF CODE REMOVED] |
| 30 | +; #ERROR "TESTC should not be defined" [#IF CODE REMOVED] |
| 31 | +; ; #ELSEIFDEF TESTD ' Should not be true [#IF CODE REMOVED] |
| 32 | +; sertxd("TESTA and TESTD are defined and TESTC is not") [#IF CODE REMOVED] |
| 33 | +; #ERROR "TESTD should not be defined" [#IF CODE REMOVED] |
| 34 | +; #ELSEIFDEF TESTB ; Should be true |
| 35 | + sertxd("TESTA and TESTB are defined and TESTC and TESTD not") |
| 36 | +; #rem ; #elseifndef is not a standared preprocessor directive, but it was not hard to include seeing as #elseifdef is implemented. [Commented out] |
| 37 | +; #ELSEIFNDEF TESTZ ; Should not be true [Commented out] |
| 38 | +; sertxd("TESTA is defined and TESTB, TESTC and TESTD are not defined") [Commented out] |
| 39 | +; #ERROR "Already should have evaluated something to True in this statement, so should ignore" [Commented out] |
| 40 | +; #endrem [Commented out] |
| 41 | +; ; #ELSEIFDEF TESTA ; Should not be true [#IF CODE REMOVED] |
| 42 | +; sertxd("TESTA is defined and TESTB, TESTC and are not defined") [#IF CODE REMOVED] |
| 43 | +; #ERROR "Already should have evaluated something to True in this statement, so should ignore" [#IF CODE REMOVED] |
| 44 | +; #ENDIF |
| 45 | +; #ENDIF |
| 46 | + |
| 47 | +; Test with values and comparisons |
| 48 | +; #DEFINE VALUE 123 |
| 49 | +; #IF 123 > 12 ; Should be true |
| 50 | + sertxd("VALUE > 12") |
| 51 | +; #IF 123 = 123 ; Should be true |
| 52 | + sertxd("VALUE == 123") |
| 53 | +; ; #ELSE ; Should not be true [#IF CODE REMOVED] |
| 54 | +; sertxd("VALUE != 123") [#IF CODE REMOVED] |
| 55 | +; #ERROR "Should not have got here" [#IF CODE REMOVED] |
| 56 | +; #ENDIF |
| 57 | + sertxd("VALUE is still > 12") |
| 58 | +; #ELSEIF 123 < 200 ; Should not be true [#IF CODE REMOVED] |
| 59 | +; sertxd("12 > VALUE < 200") [#IF CODE REMOVED] |
| 60 | +; #ERROR "Should not have got here" [#IF CODE REMOVED] |
| 61 | +; ; #ELSE ; Should not de true [#IF CODE REMOVED] |
| 62 | +; sertxd("VALUE <= 12 or VALUE >= 200") [#IF CODE REMOVED] |
| 63 | +; #ERROR "Should not have got here" [#IF CODE REMOVED] |
| 64 | +; #ENDIF |
| 65 | + |
| 66 | +; #IF 123 <> 2 ; Should be true |
| 67 | + sertxd("VALUE <> 2") |
| 68 | +; ; #ELSEIFDEF VALUE ' Should be false [#IF CODE REMOVED] |
| 69 | +; sertxd("VALUE is defined and != 2") [#IF CODE REMOVED] |
| 70 | +; #ERROR "Should not have got here" [#IF CODE REMOVED] |
| 71 | +; #ENDIF |
| 72 | + |
| 73 | +; #rem ; Even though #undef is in the manual, it does not appear to be implemented in PE6. Uncomment to test with [Commented out] |
| 74 | +; #UNDEF TESTA [Commented out] |
| 75 | +; #IFDEF TESTA ; Should no longer be defined [Commented out] |
| 76 | +; sertxd("TESTA is defined") [Commented out] |
| 77 | +; #ERROR "TESTA should not be still defined" [Commented out] |
| 78 | +; #ENDIF [Commented out] |
| 79 | +; [Commented out] |
| 80 | +; #IFNDEF TESTA ; Should be true [Commented out] |
| 81 | +; sertxd("TESTA is NOT defined") [Commented out] |
| 82 | +; #ENDIF [Commented out] |
| 83 | +; #endrem [Commented out] |
| 84 | + |
| 85 | +'---END IfTest.bas--- |
0 commit comments