From cb1fbac9223cc62739aa5c7bb97cba6e9dbd87c0 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Tue, 13 Sep 2022 22:31:31 +0800 Subject: fix readme. --- doc/docs/doc/README.md | 4 ++-- spec/inputs/test/loops_spec.yue | 15 +++++++++++++++ spec/outputs/test/loops_spec.lua | 32 +++++++++++++++++++++++++++++++- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/doc/docs/doc/README.md b/doc/docs/doc/README.md index 46511ea..3e94c9c 100755 --- a/doc/docs/doc/README.md +++ b/doc/docs/doc/README.md @@ -1243,12 +1243,12 @@ The syntax support for Lua 5.4 attributes. ```moonscript const a = 123 -close _ = close#: -> print "Out of scope." +close _ = : -> print "Out of scope." ```
 const a = 123
-close _ = close#: -> print "Out of scope."
+close _ = <close>: -> print "Out of scope."
 
diff --git a/spec/inputs/test/loops_spec.yue b/spec/inputs/test/loops_spec.yue index 16531ef..817919f 100644 --- a/spec/inputs/test/loops_spec.yue +++ b/spec/inputs/test/loops_spec.yue @@ -6,3 +6,18 @@ describe "loops", -> x assert.same output, { 2,4,6 } + + it "continue in repeat", -> + output = {} + a = 0 + repeat + a += 1 + if a == 3 + continue + if a == 5 + break + output[] = a + until a == 8 + + assert.same output, { 1,2,4 } + diff --git a/spec/outputs/test/loops_spec.lua b/spec/outputs/test/loops_spec.lua index 3fc0332..34f2e9c 100644 --- a/spec/outputs/test/loops_spec.lua +++ b/spec/outputs/test/loops_spec.lua @@ -1,5 +1,5 @@ return describe("loops", function() - return it("should continue", function() + it("should continue", function() local input = { 1, 2, @@ -36,4 +36,34 @@ return describe("loops", function() 6 }) end) + return it("continue in repeat", function() + local output = { } + local a = 0 + repeat + local _cond_0 = false + local _continue_0 = false + repeat + a = a + 1 + if a == 3 then + _cond_0 = a == 8 + _continue_0 = true + break + end + if a == 5 then + break + end + output[#output + 1] = a + _cond_0 = a == 8 + _continue_0 = true + until true + if not _continue_0 then + break + end + until _cond_0 + return assert.same(output, { + 1, + 2, + 4 + }) + end) end) -- cgit v1.2.3-55-g6feb