Files
wren/test/language/method/operators.wren
T

42 lines
1.3 KiB
Plaintext
Raw Normal View History

2013-11-14 10:27:33 -08:00
class Foo {
2015-09-01 08:16:04 -07:00
construct new() {}
2015-11-11 07:55:48 -08:00
+(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)" }
&(other) { "infix & %(other)" }
|(other) { "infix | %(other)" }
is(other) { "infix is %(other)" }
2013-11-14 10:27:33 -08:00
2014-04-03 07:48:19 -07:00
! { "prefix !" }
2014-04-08 21:18:17 -07:00
~ { "prefix ~" }
2014-04-03 07:48:19 -07:00
- { "prefix -" }
2013-11-14 10:27:33 -08:00
}
2015-07-10 09:18:22 -07:00
var foo = Foo.new()
2015-09-15 07:46:09 -07:00
System.print(foo + "a") // expect: infix + a
System.print(foo - "a") // expect: infix - a
System.print(foo * "a") // expect: infix * a
System.print(foo / "a") // expect: infix / a
System.print(foo % "a") // expect: infix % a
System.print(foo < "a") // expect: infix < a
System.print(foo > "a") // expect: infix > a
System.print(foo <= "a") // expect: infix <= a
System.print(foo >= "a") // expect: infix >= a
System.print(foo == "a") // expect: infix == a
System.print(foo != "a") // expect: infix != a
System.print(foo & "a") // expect: infix & a
System.print(foo | "a") // expect: infix | a
System.print(!foo) // expect: prefix !
System.print(~foo) // expect: prefix ~
System.print(-foo) // expect: prefix -
System.print(foo is "a") // expect: infix is a