From 825b5d96f8a0d146615f0c6a76feab46da9baa60 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Mon, 22 Nov 2021 10:05:39 +0800 Subject: update macro spec and builtin Lua. --- spec/inputs/macro-todo.yue | 13 +++++++++++++ spec/inputs/macro.yue | 15 ++------------- spec/outputs/macro-todo.lua | 2 ++ spec/outputs/macro.lua | 2 +- 4 files changed, 18 insertions(+), 14 deletions(-) create mode 100644 spec/inputs/macro-todo.yue create mode 100644 spec/outputs/macro-todo.lua (limited to 'spec') 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 @@ +export macro todoInner = (module, line, msg)-> + print "TODO#{msg and ': ' .. msg or ''} in file #{module}, at line #{line}" + { + code: "-- TODO#{msg and ': ' .. msg or ''}" + type: "lua" + } + +export macro todo = (msg)-> + if msg + "$todoInner $MODULE, $LINE, #{msg}" + else + "$todoInner $MODULE, $LINE" + 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 { $config:$myconfig, -- rename macro $config to $myconfig } +import "macro-todo" as $ + $asserts item == nil $myconfig false @@ -258,19 +260,6 @@ print $tb[1], $tb.a, ($tb)!, $tb! print "current line: #{ $LINE }" -macro todoInner = (module, line, msg)-> - print "TODO#{msg and ': ' .. msg or ''} in file #{module}, at line #{line}" - { - code: "-- TODO#{msg and ': ' .. msg or ''}" - type: "lua" - } - -macro todo = (msg)-> - if msg - "$todoInner $MODULE, $LINE, #{msg}" - else - "$todoInner $MODULE, $LINE" - $todo 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 @@ +local _module_0 = { } +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({ return 998 end })) -print("current line: " .. tostring(259)) +print("current line: " .. tostring(261)); -- TODO print('abc') return 123 -- cgit v1.2.3-55-g6feb