Files
wren/test/method_operators.wren
2013-11-14 10:59:28 -08:00

32 lines
972 B
Plaintext

class Foo {
+ other { "infix + " + other }
- other { "infix - " + other }
* other { "infix * " + other }
/ other { "infix / " + other }
% other { "infix % " + other }
< other { "infix < " + other }
> other { "infix > " + other }
<= other { "infix <= " + other }
>= other { "infix >= " + other }
== other { "infix == " + other }
!= other { "infix != " + other }
! { "prefix !" }
- { "prefix -" }
}
var foo = Foo.new
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 -