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

21 lines
684 B
Plaintext
Raw Normal View History

2013-11-19 18:24:58 -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 18:24:58 -08:00
// Return the first true argument.
2015-09-15 07:46:09 -07:00
System.print(1 || true) // expect: 1
System.print(false || 1) // expect: 1
System.print(false || false || true) // expect: true
2013-11-19 18:24:58 -08:00
// Return the last argument if all are false.
2015-09-15 07:46:09 -07:00
System.print(false || false) // expect: false
System.print(false || false || false) // expect: false
2013-11-19 18:24:58 -08:00
// Short-circuit at the first true argument.
2015-09-15 07:46:09 -07:00
System.print(false) || // expect: false
System.print(true) || // expect: true
System.print(true) // should not print
2013-11-19 18:24:58 -08:00
// Swallow a trailing newline.
2015-09-15 07:46:09 -07:00
System.print(true ||
2013-11-19 18:24:58 -08:00
true) // expect: true