Files
wren/test/logical_operator/or.wren
T

21 lines
644 B
Plaintext
Raw Normal View History

2013-11-19 18:24:58 -08:00
// Note: These tests implicitly depend on ints being truthy.
2014-01-05 12:27:12 -08:00
// Also rely on IO.print() returning its argument.
2013-11-19 18:24:58 -08:00
// Return the first true argument.
2014-01-05 12:27:12 -08:00
IO.print(1 || true) // expect: 1
IO.print(false || 1) // expect: 1
IO.print(false || false || true) // expect: true
2013-11-19 18:24:58 -08:00
// Return the last argument if all are false.
2014-01-05 12:27:12 -08:00
IO.print(false || false) // expect: false
IO.print(false || false || false) // expect: false
2013-11-19 18:24:58 -08:00
// Short-circuit at the first true argument.
2014-01-05 12:27:12 -08:00
IO.print(false) || // expect: false
IO.print(true) || // expect: true
IO.print(true) // should not print
2013-11-19 18:24:58 -08:00
// Swallow a trailing newline.
2014-01-05 12:27:12 -08:00
IO.print(true ||
2013-11-19 18:24:58 -08:00
true) // expect: true