mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-10 21:58:48 +01:00
Test static operators (#798)
In #797 it was stated that static operators are valid in Wren, and proposed to check this behavior
This commit is contained in:
committed by
GitHub
parent
84b29e6995
commit
76fb4f311b
52
test/language/method/static_operators.wren
Normal file
52
test/language/method/static_operators.wren
Normal file
@ -0,0 +1,52 @@
|
||||
class Foo {
|
||||
static +(other) { "infix %(this) + %(other)" }
|
||||
static -(other) { "infix %(this) - %(other)" }
|
||||
static *(other) { "infix %(this) * %(other)" }
|
||||
static /(other) { "infix %(this) / %(other)" }
|
||||
static %(other) { "infix %(this) \% %(other)" }
|
||||
static <(other) { "infix %(this) < %(other)" }
|
||||
static >(other) { "infix %(this) > %(other)" }
|
||||
static <=(other) { "infix %(this) <= %(other)" }
|
||||
static >=(other) { "infix %(this) >= %(other)" }
|
||||
static ==(other) { "infix %(this) == %(other)" }
|
||||
static !=(other) { "infix %(this) != %(other)" }
|
||||
static &(other) { "infix %(this) & %(other)" }
|
||||
static |(other) { "infix %(this) | %(other)" }
|
||||
static is(other) { "infix %(this) is %(other)" }
|
||||
|
||||
static ! { "prefix !%(this)" }
|
||||
static ~ { "prefix ~%(this)" }
|
||||
static - { "prefix -%(this)" }
|
||||
|
||||
static [a] { "%(this) 1-subscript %(a)" }
|
||||
static [a, b] { "%(this) 2-subscript %(a) %(b)" }
|
||||
static [a, b, c] { "%(this) 3-subscript %(a) %(b) %(c)" }
|
||||
static [a]=(value) { "%(this) 1-subscript setter %(a) = %(value)" }
|
||||
static [a, b]=(value) { "%(this) 2-subscript setter %(a) %(b) = %(value)" }
|
||||
static [a, b, c]=(value) { "%(this) 3-subscript setter %(a) %(b) %(c) = %(value)" }
|
||||
}
|
||||
|
||||
System.print(Foo + "a") // expect: infix Foo + a
|
||||
System.print(Foo - "a") // expect: infix Foo - a
|
||||
System.print(Foo * "a") // expect: infix Foo * a
|
||||
System.print(Foo / "a") // expect: infix Foo / a
|
||||
System.print(Foo % "a") // expect: infix Foo % a
|
||||
System.print(Foo < "a") // expec%(this) t: infix Foo < a
|
||||
System.print(Foo > "a") // expect:%(this) infix Foo > a
|
||||
System.print(Foo <= "a") // expec%(this) t: infix Foo <= a
|
||||
System.print(Foo >= "a") // expect: infix Foo >= a
|
||||
System.print(Foo == "a") // expect: infix Foo == a
|
||||
System.print(Foo != "a") // expect: infix Foo != a
|
||||
System.print(Foo & "a") // expect: infix Foo & a
|
||||
System.print(Foo | "a") // expect: infix Foo | a
|
||||
System.print(!Foo) // expect: prefix !Foo
|
||||
System.print(~Foo) // expect: prefix ~Foo
|
||||
System.print(-Foo) // expect: prefix -Foo
|
||||
System.print(Foo is "a") // expect: infix Foo is a
|
||||
|
||||
System.print(Foo["a"]) // expect: Foo 1-subscript a
|
||||
System.print(Foo["a", "b"]) // expect: Foo 2-subscript a b
|
||||
System.print(Foo["a", "b", "c"]) // expect: Foo 3-subscript a b c
|
||||
System.print(Foo["a"] = "value") // expect: Foo 1-subscript setter a = value
|
||||
System.print(Foo["a", "b"] = "value") // expect: Foo 2-subscript setter a b = value
|
||||
System.print(Foo["a", "b", "c"] = "value") // expect: Foo 3-subscript setter a b c = value
|
||||
Reference in New Issue
Block a user