mirror of
https://github.com/QB64-Phoenix-Edition/QB64pe.git
synced 2024-05-02 21:50:13 +00:00
Add test for boolean logical ops
This commit is contained in:
parent
ed75e871c8
commit
4e4b8149b4
65
tests/compile_tests/bool_test/bool_test.bas
Normal file
65
tests/compile_tests/bool_test/bool_test.bas
Normal file
|
@ -0,0 +1,65 @@
|
|||
$CONSOLE:ONLY
|
||||
_DEFINE A-Z AS LONG
|
||||
OPTION _EXPLICIT
|
||||
|
||||
CONST A = -100
|
||||
CONST B = -10
|
||||
CONST D = 10
|
||||
CONST E = 100
|
||||
|
||||
DIM c AS LONG
|
||||
|
||||
PRINT "Logical op test:"
|
||||
PRINT
|
||||
|
||||
c = _NEGATE (_NEGATE (_NEGATE (_NEGATE c)))
|
||||
|
||||
IF _NEGATE GetValue(c) THEN
|
||||
PRINT "_NEGATE: Test passed."
|
||||
ELSE
|
||||
PRINT "_NEGATE: Test failed."
|
||||
END IF
|
||||
|
||||
IF GetValue(D) < 0 _ANDALSO GetValue(E) < 0 THEN
|
||||
PRINT "_ANDALSO: Test failed."
|
||||
ELSE
|
||||
PRINT "_ANDALSO: Test passed."
|
||||
END IF
|
||||
|
||||
IF GetValue(A) < 0 _ORELSE GetValue(B) < 0 THEN
|
||||
PRINT "_ORELSE: Test passed."
|
||||
ELSE
|
||||
PRINT "_ORELSE: Test failed."
|
||||
END IF
|
||||
|
||||
|
||||
PRINT
|
||||
PRINT "Bitwise op test:"
|
||||
PRINT
|
||||
|
||||
c = NOT (NOT (NOT (NOT c)))
|
||||
|
||||
IF NOT GetValue(c) THEN
|
||||
PRINT "NOT: Test passed."
|
||||
ELSE
|
||||
PRINT "NOT: Test failed."
|
||||
END IF
|
||||
|
||||
IF GetValue(D) < 0 AND GetValue(E) < 0 THEN
|
||||
PRINT "AND: Test failed."
|
||||
ELSE
|
||||
PRINT "AND: Test passed."
|
||||
END IF
|
||||
|
||||
IF GetValue(A) < 0 OR GetValue(B) < 0 THEN
|
||||
PRINT "OR: Test passed."
|
||||
ELSE
|
||||
PRINT "OR: Test failed."
|
||||
END IF
|
||||
|
||||
SYSTEM
|
||||
|
||||
FUNCTION GetValue& (x AS LONG)
|
||||
PRINT "Function called for value:"; x
|
||||
GetValue = x
|
||||
END FUNCTION
|
19
tests/compile_tests/bool_test/bool_test.output
Normal file
19
tests/compile_tests/bool_test/bool_test.output
Normal file
|
@ -0,0 +1,19 @@
|
|||
Logical op test:
|
||||
|
||||
Function called for value: 0
|
||||
_NEGATE: Test passed.
|
||||
Function called for value: 10
|
||||
_ANDALSO: Test passed.
|
||||
Function called for value:-100
|
||||
_ORELSE: Test passed.
|
||||
|
||||
Bitwise op test:
|
||||
|
||||
Function called for value: 0
|
||||
NOT: Test passed.
|
||||
Function called for value: 10
|
||||
Function called for value: 100
|
||||
AND: Test passed.
|
||||
Function called for value:-100
|
||||
Function called for value:-10
|
||||
OR: Test passed.
|
Loading…
Reference in a new issue