Files
wren/test/language/method/subscript_operators.wren
Bob Nystrom 64eccdd9be Reorganize tests and benchmark scripts.
Mainly to get rid of one top level directory. But this will
also be useful when there are tests of the embedding API.
2015-03-14 12:45:56 -07:00

17 lines
759 B
Plaintext

class Foo {
[a] { "1-subscript " + a }
[a, b] { "2-subscript " + a + " " + b }
[a, b, c] { "3-subscript " + a + " " + b + " " + c }
[a]=(value) { "1-subscript setter " + a + " = " + value }
[a, b]=(value) { "2-subscript setter " + a + " " + b + " = " + value }
[a, b, c]=(value) { "3-subscript setter " + a + " " + b + " " + c + " = " + value }
}
var foo = new Foo
IO.print(foo["a"]) // expect: 1-subscript a
IO.print(foo["a", "b"]) // expect: 2-subscript a b
IO.print(foo["a", "b", "c"]) // expect: 3-subscript a b c
IO.print(foo["a"] = "value") // expect: 1-subscript setter a = value
IO.print(foo["a", "b"] = "value") // expect: 2-subscript setter a b = value
IO.print(foo["a", "b", "c"] = "value") // expect: 3-subscript setter a b c = value