|
| 1 | +%% Copyright (C) 2019 LiveCode Ltd. |
| 2 | +%% |
| 3 | +%% This file is part of LiveCode. |
| 4 | +%% |
| 5 | +%% LiveCode is free software; you can redistribute it and/or modify it under |
| 6 | +%% the terms of the GNU General Public License v3 as published by the Free |
| 7 | +%% Software Foundation. |
| 8 | +%% |
| 9 | +%% LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY |
| 10 | +%% WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | +%% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | +%% for more details. |
| 13 | +%% |
| 14 | +%% You should have received a copy of the GNU General Public License |
| 15 | +%% along with LiveCode. If not see <http://www.gnu.org/licenses/>. |
| 16 | + |
| 17 | +%% infinity constant is okay as uql assignment |
| 18 | +%TEST UnquotedLiteralConstantInfinity |
| 19 | +on compiler_test |
| 20 | + local tInfinity = infinity |
| 21 | +end compiler_test |
| 22 | +%EXPECT PASS |
| 23 | +%SUCCESS |
| 24 | +%ENDTEST |
| 25 | + |
| 26 | +%% true and false constants are okay for uql assignment |
| 27 | +%TEST UnquotedLiteralConstantBoolean |
| 28 | +on compiler_test |
| 29 | + local tTrue = true |
| 30 | + local tFalse = false |
| 31 | +end compiler_test |
| 32 | +%EXPECT PASS |
| 33 | +%SUCCESS |
| 34 | +%ENDTEST |
| 35 | + |
| 36 | +%% string constants are okay for uql assignment if their |
| 37 | +%% constant value is equal to their name |
| 38 | +%TEST UnquotedLiteralConstantConverts |
| 39 | +on compiler_test |
| 40 | + local tDown = down |
| 41 | + local tUp = up |
| 42 | + local tRight = right |
| 43 | + local tLeft = left |
| 44 | + local tDone = done |
| 45 | +end compiler_test |
| 46 | +%EXPECT PASS |
| 47 | +%SUCCESS |
| 48 | +%ENDTEST |
| 49 | + |
| 50 | +%% constants whose name values do not convert as the constant's |
| 51 | +%% type to their value are only okay for uql assignment if |
| 52 | +%% explicit variables is false |
| 53 | +%TEST UnquotedLiteralConstantDoesntConvertNonExplicit |
| 54 | +%SET explicitvariables false |
| 55 | + // Real constant |
| 56 | + local tPi = pi |
| 57 | + // Integer constant |
| 58 | + local tOne = one |
| 59 | + // String constant |
| 60 | + local tEOF = eof |
| 61 | + // Special-case value constants |
| 62 | + local tNull = null |
| 63 | + local tEmpty = empty |
| 64 | +end compiler_test |
| 65 | +%EXPECT PASS |
| 66 | +%SUCCESS |
| 67 | +%ENDTEST |
| 68 | + |
| 69 | +%TEST UnquotedLiteralRealConstantDoesntConvertExplicit |
| 70 | +%SET explicitvariables true |
| 71 | +on compiler_test |
| 72 | + local tPi = pi%{UQL} |
| 73 | +end compiler_test |
| 74 | +%EXPECT PASS |
| 75 | +%ERROR PE_LOCAL_BADINIT AT UQL |
| 76 | +%ENDTEST |
| 77 | + |
| 78 | +%TEST UnquotedLiteralIntegerConstantDoesntConvertExplicit |
| 79 | +%SET explicitvariables true |
| 80 | +on compiler_test |
| 81 | + constant tOne = one%{UQL} |
| 82 | +end compiler_test |
| 83 | +%EXPECT PASS |
| 84 | +%ERROR PE_CONSTANT_BADINIT AT UQL |
| 85 | +%ENDTEST |
| 86 | + |
| 87 | +%TEST UnquotedLiteralStringConstantDoesntConvertExplicit |
| 88 | +%SET explicitvariables true |
| 89 | +on compiler_test |
| 90 | + local tEOF = eof%{UQL} |
| 91 | +end compiler_test |
| 92 | +%EXPECT PASS |
| 93 | +%ERROR PE_LOCAL_BADINIT AT UQL |
| 94 | +%ENDTEST |
| 95 | + |
| 96 | +%TEST UnquotedLiteralNullDoesntConvertExplicit |
| 97 | +%SET explicitvariables true |
| 98 | +on compiler_test |
| 99 | + constant tNull = null%{UQL} |
| 100 | +end compiler_test |
| 101 | +%EXPECT PASS |
| 102 | +%ERROR PE_CONSTANT_BADINIT AT UQL |
| 103 | +%ENDTEST |
| 104 | + |
| 105 | +%TEST UnquotedLiteralEmptyDoesntConvertExplicit |
| 106 | +%SET explicitvariables true |
| 107 | +on compiler_test |
| 108 | + local tEmpty = empty%{UQL} |
| 109 | +end compiler_test |
| 110 | +%EXPECT PASS |
| 111 | +%ERROR PE_LOCAL_BADINIT AT UQL |
| 112 | +%ENDTEST |
| 113 | + |
| 114 | +%% infinity constant as uql assignment is case sensitive |
| 115 | +%TEST UnquotedLiteralConstantInfinityCase |
| 116 | +on compiler_test |
| 117 | + local tInfinity = InFiNiTy%{UQL_CASE} |
| 118 | +end compiler_test |
| 119 | +%EXPECT PASS |
| 120 | +%ERROR PE_LOCAL_BADINIT AT UQL_CASE |
| 121 | +%ENDTEST |
| 122 | + |
| 123 | +%% true constant as uql assignment is case sensitive |
| 124 | +%TEST UnquotedLiteralConstantTrueCase |
| 125 | +on compiler_test |
| 126 | + local tInfinity = TrUe%{UQL_CASE} |
| 127 | +end compiler_test |
| 128 | +%EXPECT PASS |
| 129 | +%ERROR PE_LOCAL_BADINIT AT UQL_CASE |
| 130 | +%ENDTEST |
| 131 | + |
| 132 | +%% false constant as uql assignment is case sensitive |
| 133 | +%TEST UnquotedLiteralConstantFalseCase |
| 134 | +on compiler_test |
| 135 | + local tFalse = FaLsE%{UQL_CASE} |
| 136 | +end compiler_test |
| 137 | +%EXPECT PASS |
| 138 | +%ERROR PE_LOCAL_BADINIT AT UQL_CASE |
| 139 | +%ENDTEST |
| 140 | + |
| 141 | +%% string constants with constant value is equal to |
| 142 | +%% their name as uql assigment is case sensitive |
| 143 | +%TEST UnquotedLiteralConstantConvertsCase |
| 144 | +on compiler_test |
| 145 | + local tDown = dOwN%{UQL_CASE} |
| 146 | +end compiler_test |
| 147 | +%EXPECT PASS |
| 148 | +%ERROR PE_LOCAL_BADINIT AT UQL_CASE |
| 149 | +%ENDTEST |
0 commit comments