diff options
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/inputs/funcs.yue | 35 | ||||
| -rw-r--r-- | spec/outputs/funcs.lua | 70 |
2 files changed, 105 insertions, 0 deletions
diff --git a/spec/inputs/funcs.yue b/spec/inputs/funcs.yue index 0e45ff1..e647edc 100644 --- a/spec/inputs/funcs.yue +++ b/spec/inputs/funcs.yue | |||
| @@ -158,4 +158,39 @@ args = (f,g,m | |||
| 158 | return 1 if n == 0 | 158 | return 1 if n == 0 |
| 159 | n * @(n-1) | 159 | n * @(n-1) |
| 160 | 160 | ||
| 161 | do | ||
| 162 | items.every (item) -> | ||
| 163 | if item.field | ||
| 164 | value = item.field.get "abc" | ||
| 165 | if value | ||
| 166 | switch value\get! | ||
| 167 | when 123 | ||
| 168 | return false | ||
| 169 | when 456 | ||
| 170 | handle item | ||
| 171 | true | ||
| 172 | |||
| 173 | items.every (item): true -> | ||
| 174 | if item.field | ||
| 175 | value = item.field.get "abc" | ||
| 176 | if value | ||
| 177 | switch value\get! | ||
| 178 | when 123 | ||
| 179 | return false | ||
| 180 | when 456 | ||
| 181 | -- prevent implicit return for next line | ||
| 182 | handle item | ||
| 183 | |||
| 184 | HttpServer\post "/login", (req): success: false -> | ||
| 185 | switch req when {:name, :pwd} | ||
| 186 | if name ~= "" | ||
| 187 | if user := DB\queryUser name, pwd | ||
| 188 | if user.status == "available" | ||
| 189 | return success: true | ||
| 190 | |||
| 191 | check = (num) -> return num | ||
| 192 | -- func without implicit return | ||
| 193 | func = (): -> check 123 | ||
| 194 | print func! -- get nil | ||
| 195 | |||
| 161 | nil | 196 | nil |
diff --git a/spec/outputs/funcs.lua b/spec/outputs/funcs.lua index 03281e4..c07989e 100644 --- a/spec/outputs/funcs.lua +++ b/spec/outputs/funcs.lua | |||
| @@ -219,4 +219,74 @@ self = function(n) | |||
| 219 | end | 219 | end |
| 220 | return n * self(n - 1) | 220 | return n * self(n - 1) |
| 221 | end | 221 | end |
| 222 | do | ||
| 223 | items.every(function(item) | ||
| 224 | if item.field then | ||
| 225 | local value = item.field.get("abc") | ||
| 226 | if value then | ||
| 227 | do | ||
| 228 | local _exp_0 = value:get() | ||
| 229 | if 123 == _exp_0 then | ||
| 230 | return false | ||
| 231 | elseif 456 == _exp_0 then | ||
| 232 | handle(item) | ||
| 233 | end | ||
| 234 | end | ||
| 235 | end | ||
| 236 | end | ||
| 237 | return true | ||
| 238 | end) | ||
| 239 | items.every(function(item) | ||
| 240 | if item.field then | ||
| 241 | local value = item.field.get("abc") | ||
| 242 | if value then | ||
| 243 | do | ||
| 244 | local _exp_0 = value:get() | ||
| 245 | if 123 == _exp_0 then | ||
| 246 | return false | ||
| 247 | elseif 456 == _exp_0 then | ||
| 248 | handle(item) | ||
| 249 | end | ||
| 250 | end | ||
| 251 | end | ||
| 252 | end | ||
| 253 | return true | ||
| 254 | end) | ||
| 255 | HttpServer:post("/login", function(req) | ||
| 256 | do | ||
| 257 | local _type_0 = type(req) | ||
| 258 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 | ||
| 259 | if _tab_0 then | ||
| 260 | local name = req.name | ||
| 261 | local pwd = req.pwd | ||
| 262 | if name ~= nil and pwd ~= nil then | ||
| 263 | if name ~= "" then | ||
| 264 | do | ||
| 265 | local user = DB:queryUser(name, pwd) | ||
| 266 | if user then | ||
| 267 | if user.status == "available" then | ||
| 268 | return { | ||
| 269 | success = true | ||
| 270 | } | ||
| 271 | end | ||
| 272 | end | ||
| 273 | end | ||
| 274 | end | ||
| 275 | end | ||
| 276 | end | ||
| 277 | end | ||
| 278 | return { | ||
| 279 | success = false | ||
| 280 | } | ||
| 281 | end) | ||
| 282 | local check | ||
| 283 | check = function(num) | ||
| 284 | return num | ||
| 285 | end | ||
| 286 | local func | ||
| 287 | func = function() | ||
| 288 | check(123) | ||
| 289 | end | ||
| 290 | print(func()) | ||
| 291 | end | ||
| 222 | return nil | 292 | return nil |
