Files
wren/test/method/operators.wren
2013-12-21 19:25:09 -08:00

32 lines
1.0 KiB
Plaintext

class Foo {
+ other { return "infix + " + other }
- other { return "infix - " + other }
* other { return "infix * " + other }
/ other { return "infix / " + other }
% other { return "infix % " + other }
< other { return "infix < " + other }
> other { return "infix > " + other }
<= other { return "infix <= " + other }
>= other { return "infix >= " + other }
== other { return "infix == " + other }
!= other { return "infix != " + other }
! { return "prefix !" }
- { return "prefix -" }
}
var foo = new Foo
IO.write(foo + "a") // expect: infix + a
IO.write(foo - "a") // expect: infix - a
IO.write(foo * "a") // expect: infix * a
IO.write(foo / "a") // expect: infix / a
IO.write(foo % "a") // expect: infix % a
IO.write(foo < "a") // expect: infix < a
IO.write(foo > "a") // expect: infix > a
IO.write(foo <= "a") // expect: infix <= a
IO.write(foo >= "a") // expect: infix >= a
IO.write(foo == "a") // expect: infix == a
IO.write(foo != "a") // expect: infix != a
IO.write(!foo) // expect: prefix !
IO.write(-foo) // expect: prefix -