aboutsummaryrefslogtreecommitdiff
path: root/spec/inputs/metatable.yue
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2021-03-05 10:14:10 +0800
committerLi Jin <dragon-fly@qq.com>2021-03-05 10:14:10 +0800
commit05283b77da4ba236f02b42d1205433f6b1fcb0d6 (patch)
treeecb5e6688109ed3e9be6acd5f1b8c22d6fd407dc /spec/inputs/metatable.yue
parent1df786307c1983b8ce693e3916081a8bcd4e95ae (diff)
downloadyuescript-05283b77da4ba236f02b42d1205433f6b1fcb0d6.tar.gz
yuescript-05283b77da4ba236f02b42d1205433f6b1fcb0d6.tar.bz2
yuescript-05283b77da4ba236f02b42d1205433f6b1fcb0d6.zip
fix issue #41, add square brackets support for metatable syntax. fix using metatable with "with" syntax issue.
Diffstat (limited to 'spec/inputs/metatable.yue')
-rw-r--r--spec/inputs/metatable.yue8
1 files changed, 8 insertions, 0 deletions
diff --git a/spec/inputs/metatable.yue b/spec/inputs/metatable.yue
index 6f7b418..13ea917 100644
--- a/spec/inputs/metatable.yue
+++ b/spec/inputs/metatable.yue
@@ -1,6 +1,8 @@
1a = close: true, close#: => print "out of scope" 1a = close: true, close#: => print "out of scope"
2b = add#: (left, right)-> right - left 2b = add#: (left, right)-> right - left
3c = key1: true, :add#, key2: true 3c = key1: true, :add#, key2: true
4w = [name]#:123, ["new"]#:(val)=> {val}
5w.#["new"] w.#[name]
4 6
5close _ = close#: -> print "out of scope" 7close _ = close#: -> print "out of scope"
6 8
@@ -40,4 +42,10 @@ tb\func# list
40 42
41import "module" as :index#, newindex#:setFunc 43import "module" as :index#, newindex#:setFunc
42 44
45with tb
46 print .add#, .x\index# "key"
47 a = .index#.add#\new# 123
48 b = t#.close#.test
49 c = t #.close# .test
50
43nil 51nil