mirror of
https://github.com/MorizzG/rlox.git
synced 2025-12-06 12:22:42 +00:00
added tests
This commit is contained in:
parent
1cca1494a4
commit
660464638f
255 changed files with 7220 additions and 3 deletions
19
interpreter/tests/lox/logical_operator/and.lox
Normal file
19
interpreter/tests/lox/logical_operator/and.lox
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// Note: These tests implicitly depend on ints being truthy.
|
||||
|
||||
// Return the first non-true argument.
|
||||
print false and 1; // expect: false
|
||||
print true and 1; // expect: 1
|
||||
print 1 and 2 and false; // expect: false
|
||||
|
||||
// Return the last argument if all are true.
|
||||
print 1 and true; // expect: true
|
||||
print 1 and 2 and 3; // expect: 3
|
||||
|
||||
// Short-circuit at the first false argument.
|
||||
var a = "before";
|
||||
var b = "before";
|
||||
(a = true) and
|
||||
(b = false) and
|
||||
(a = "bad");
|
||||
print a; // expect: true
|
||||
print b; // expect: false
|
||||
Loading…
Add table
Add a link
Reference in a new issue