diff options
author | Li Jin <dragon-fly@qq.com> | 2021-11-22 10:05:39 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2021-11-22 10:05:39 +0800 |
commit | 825b5d96f8a0d146615f0c6a76feab46da9baa60 (patch) | |
tree | df450bac65848dddc4929383fdd0a48485254484 /spec | |
parent | 125f709b065acb35bcd216001720c0bb4635dd25 (diff) | |
download | yuescript-0.9.1.tar.gz yuescript-0.9.1.tar.bz2 yuescript-0.9.1.zip |
update macro spec and builtin Lua.v0.9.1
Diffstat (limited to 'spec')
-rw-r--r-- | spec/inputs/macro-todo.yue | 13 | ||||
-rw-r--r-- | spec/inputs/macro.yue | 15 | ||||
-rw-r--r-- | spec/outputs/macro-todo.lua | 2 | ||||
-rw-r--r-- | spec/outputs/macro.lua | 2 |
4 files changed, 18 insertions, 14 deletions
diff --git a/spec/inputs/macro-todo.yue b/spec/inputs/macro-todo.yue new file mode 100644 index 0000000..8477e5a --- /dev/null +++ b/spec/inputs/macro-todo.yue | |||
@@ -0,0 +1,13 @@ | |||
1 | export macro todoInner = (module, line, msg)-> | ||
2 | print "TODO#{msg and ': ' .. msg or ''} in file #{module}, at line #{line}" | ||
3 | { | ||
4 | code: "-- TODO#{msg and ': ' .. msg or ''}" | ||
5 | type: "lua" | ||
6 | } | ||
7 | |||
8 | export macro todo = (msg)-> | ||
9 | if msg | ||
10 | "$todoInner $MODULE, $LINE, #{msg}" | ||
11 | else | ||
12 | "$todoInner $MODULE, $LINE" | ||
13 | |||
diff --git a/spec/inputs/macro.yue b/spec/inputs/macro.yue index 366a3d9..2742bd0 100644 --- a/spec/inputs/macro.yue +++ b/spec/inputs/macro.yue | |||
@@ -6,6 +6,8 @@ import "macro-export" as { | |||
6 | $config:$myconfig, -- rename macro $config to $myconfig | 6 | $config:$myconfig, -- rename macro $config to $myconfig |
7 | } | 7 | } |
8 | 8 | ||
9 | import "macro-todo" as $ | ||
10 | |||
9 | $asserts item == nil | 11 | $asserts item == nil |
10 | 12 | ||
11 | $myconfig false | 13 | $myconfig false |
@@ -258,19 +260,6 @@ print $tb[1], $tb.a, ($tb)!, $tb! | |||
258 | 260 | ||
259 | print "current line: #{ $LINE }" | 261 | print "current line: #{ $LINE }" |
260 | 262 | ||
261 | macro todoInner = (module, line, msg)-> | ||
262 | print "TODO#{msg and ': ' .. msg or ''} in file #{module}, at line #{line}" | ||
263 | { | ||
264 | code: "-- TODO#{msg and ': ' .. msg or ''}" | ||
265 | type: "lua" | ||
266 | } | ||
267 | |||
268 | macro todo = (msg)-> | ||
269 | if msg | ||
270 | "$todoInner $MODULE, $LINE, #{msg}" | ||
271 | else | ||
272 | "$todoInner $MODULE, $LINE" | ||
273 | |||
274 | $todo | 263 | $todo |
275 | 264 | ||
276 | macro implicitReturnMacroIsAllowed = -> "print 'abc'\n123" | 265 | macro implicitReturnMacroIsAllowed = -> "print 'abc'\n123" |
diff --git a/spec/outputs/macro-todo.lua b/spec/outputs/macro-todo.lua new file mode 100644 index 0000000..b5a63f8 --- /dev/null +++ b/spec/outputs/macro-todo.lua | |||
@@ -0,0 +1,2 @@ | |||
1 | local _module_0 = { } | ||
2 | return _module_0 | ||
diff --git a/spec/outputs/macro.lua b/spec/outputs/macro.lua index 7812182..9f04216 100644 --- a/spec/outputs/macro.lua +++ b/spec/outputs/macro.lua | |||
@@ -258,7 +258,7 @@ print((setmetatable({ | |||
258 | return 998 | 258 | return 998 |
259 | end | 259 | end |
260 | })) | 260 | })) |
261 | print("current line: " .. tostring(259)) | 261 | print("current line: " .. tostring(261)); |
262 | -- TODO | 262 | -- TODO |
263 | print('abc') | 263 | print('abc') |
264 | return 123 | 264 | return 123 |