diff options
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/inputs/metatable.yue | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/inputs/metatable.yue b/spec/inputs/metatable.yue new file mode 100644 index 0000000..6f7b418 --- /dev/null +++ b/spec/inputs/metatable.yue | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | a = close: true, close#: => print "out of scope" | ||
| 2 | b = add#: (left, right)-> right - left | ||
| 3 | c = key1: true, :add#, key2: true | ||
| 4 | |||
| 5 | close _ = close#: -> print "out of scope" | ||
| 6 | |||
| 7 | d, e = a.close, a.close# | ||
| 8 | |||
| 9 | f = a\close# 1 | ||
| 10 | a.add# = (x, y)-> x + y | ||
| 11 | |||
| 12 | do | ||
| 13 | {:new, :close#, close#: closeA} = a | ||
| 14 | print new, close, closeA | ||
| 15 | |||
| 16 | do | ||
| 17 | local * | ||
| 18 | x, \ | ||
| 19 | {:new, :var, :close#, close#: closeA}, \ | ||
| 20 | :num, :add#, :sub# \ | ||
| 21 | = 123, a.b.c, func! | ||
| 22 | |||
| 23 | x.abc, a.b.# = 123, {} | ||
| 24 | func!.# = mt, extra | ||
| 25 | a, b.c.#, d, e = 1, mt, "abc" | ||
| 26 | |||
| 27 | is_same = a.#.__index == a.index# | ||
| 28 | |||
| 29 | -- | ||
| 30 | a.# = __index: tb | ||
| 31 | a.#.__index = tb | ||
| 32 | a.index# = tb | ||
| 33 | -- | ||
| 34 | |||
| 35 | mt = a.# | ||
| 36 | |||
| 37 | tb\func #list | ||
| 38 | tb\func#list | ||
| 39 | tb\func# list | ||
| 40 | |||
| 41 | import "module" as :index#, newindex#:setFunc | ||
| 42 | |||
| 43 | nil | ||
