Files
wren/test/grammar.wren

32 lines
769 B
Plaintext
Raw Normal View History

2013-10-31 21:49:15 -07:00
// * has higher precedence than +.
IO.print(2 + 3 * 4) // expect: 14
2013-10-31 21:49:15 -07:00
// * has higher precedence than -.
IO.print(20 - 3 * 4) // expect: 8
2013-10-31 21:49:15 -07:00
2013-11-05 09:57:57 -08:00
// / has higher precedence than +.
IO.print(2 + 6 / 3) // expect: 4
2013-11-05 09:57:57 -08:00
// / has higher precedence than -.
IO.print(2 - 6 / 3) // expect: 0
2013-11-05 09:57:57 -08:00
// < has higher precedence than ==.
IO.print(false == 2 < 1) // expect: true
2013-11-05 09:57:57 -08:00
// > has higher precedence than ==.
IO.print(false == 1 > 2) // expect: true
2013-11-05 09:57:57 -08:00
// <= has higher precedence than ==.
IO.print(false == 2 <= 1) // expect: true
2013-11-05 09:57:57 -08:00
// >= has higher precedence than ==.
IO.print(false == 1 >= 2) // expect: true
2013-11-05 09:57:57 -08:00
// Unary - has lower precedence than ..
IO.print(-"abc".count) // expect: -3
// TODO: %, associativity.
2013-11-05 09:57:57 -08:00
2013-10-31 21:49:15 -07:00
// Using () for grouping.
IO.print((2 * (6 - (2 + 2)))) // expect: 4