diff options
Diffstat (limited to 'spec/inputs')
| -rw-r--r-- | spec/inputs/macro.moon | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/inputs/macro.moon b/spec/inputs/macro.moon index 9083449..47e5a26 100644 --- a/spec/inputs/macro.moon +++ b/spec/inputs/macro.moon | |||
| @@ -102,5 +102,38 @@ do | |||
| 102 | a += $get_inner_hygienic! | 102 | a += $get_inner_hygienic! |
| 103 | print a | 103 | print a |
| 104 | 104 | ||
| 105 | macro lua lua = (codes)-> "#{codes}" | ||
| 106 | |||
| 107 | x = 0 | ||
| 108 | |||
| 109 | $lua [[ | ||
| 110 | local function f(a) | ||
| 111 | return a + 1 | ||
| 112 | end | ||
| 113 | x = x + f(3) | ||
| 114 | ]] | ||
| 115 | |||
| 116 | print x | ||
| 117 | |||
| 118 | macro lua def = (fname, ...)-> | ||
| 119 | args = {...} | ||
| 120 | last = table.remove args | ||
| 121 | $showMacro "def", "local function #{fname}(#{table.concat args, ', '}) | ||
| 122 | #{last} | ||
| 123 | end" | ||
| 124 | |||
| 125 | sel = (a, b, c)-> if a then b else c | ||
| 126 | |||
| 127 | $def sel, a, b, c, [[ | ||
| 128 | if a then | ||
| 129 | return b | ||
| 130 | else | ||
| 131 | return c | ||
| 132 | end | ||
| 133 | ]] | ||
| 134 | |||
| 135 | $def dummy,[[ | ||
| 136 | ]] | ||
| 137 | |||
| 105 | nil | 138 | nil |
| 106 | 139 | ||
