Files
wren/test/language/logical_operator/and.wren
T

21 lines
665 B
Plaintext
Raw Normal View History

2013-11-19 07:35:25 -08:00
// Note: These tests implicitly depend on ints being truthy.
2015-09-15 07:46:09 -07:00
// Also rely on System.print() returning its argument.
2013-11-19 07:35:25 -08:00
// Return the first non-true argument.
2015-09-15 07:46:09 -07:00
System.print(false && 1) // expect: false
System.print(true && 1) // expect: 1
System.print(1 && 2 && false) // expect: false
2013-11-19 07:35:25 -08:00
// Return the last argument if all are true.
2015-09-15 07:46:09 -07:00
System.print(1 && true) // expect: true
System.print(1 && 2 && 3) // expect: 3
2013-11-19 07:35:25 -08:00
// Short-circuit at the first false argument.
2015-09-15 07:46:09 -07:00
System.print(true) && // expect: true
System.print(false) && // expect: false
System.print(false) // should not print
2013-11-19 07:35:25 -08:00
// Swallow a trailing newline.
2015-09-15 07:46:09 -07:00
System.print(true &&
2013-11-19 07:35:25 -08:00
true) // expect: true