diff options
| author | Li Jin <dragon-fly@qq.com> | 2021-03-03 21:31:01 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2021-03-03 21:33:37 +0800 |
| commit | 1df786307c1983b8ce693e3916081a8bcd4e95ae (patch) | |
| tree | 6c7aeb2198d825877fd3d179c394b7a5c1f06a17 /spec/inputs | |
| parent | 66168b112b707172b9035edf8c1daed469781e06 (diff) | |
| download | yuescript-1df786307c1983b8ce693e3916081a8bcd4e95ae.tar.gz yuescript-1df786307c1983b8ce693e3916081a8bcd4e95ae.tar.bz2 yuescript-1df786307c1983b8ce693e3916081a8bcd4e95ae.zip | |
add new metatable syntax for issue #41, fix reusing local variable issue, update built-in Lua.
Diffstat (limited to 'spec/inputs')
| -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 | ||
