aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2022-09-13 22:31:31 +0800
committerLi Jin <dragon-fly@qq.com>2022-09-13 22:31:31 +0800
commitcb1fbac9223cc62739aa5c7bb97cba6e9dbd87c0 (patch)
treecd08fb8a717a4fb31bc800761652eec95171c0da
parent27b7211e74d5677fbf5c5212264d32c7bfaffc20 (diff)
downloadyuescript-cb1fbac9223cc62739aa5c7bb97cba6e9dbd87c0.tar.gz
yuescript-cb1fbac9223cc62739aa5c7bb97cba6e9dbd87c0.tar.bz2
yuescript-cb1fbac9223cc62739aa5c7bb97cba6e9dbd87c0.zip
fix readme.
-rwxr-xr-xdoc/docs/doc/README.md4
-rw-r--r--spec/inputs/test/loops_spec.yue15
-rw-r--r--spec/outputs/test/loops_spec.lua32
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.
1243 1243
1244```moonscript 1244```moonscript
1245const a = 123 1245const a = 123
1246close _ = close#: -> print "Out of scope." 1246close _ = <close>: -> print "Out of scope."
1247``` 1247```
1248<YueDisplay> 1248<YueDisplay>
1249<pre> 1249<pre>
1250const a = 123 1250const a = 123
1251close _ = close#: -> print "Out of scope." 1251close _ = &lt;close&gt;: -> print "Out of scope."
1252</pre> 1252</pre>
1253</YueDisplay> 1253</YueDisplay>
1254 1254
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", ->
6 x 6 x
7 7
8 assert.same output, { 2,4,6 } 8 assert.same output, { 2,4,6 }
9
10 it "continue in repeat", ->
11 output = {}
12 a = 0
13 repeat
14 a += 1
15 if a == 3
16 continue
17 if a == 5
18 break
19 output[] = a
20 until a == 8
21
22 assert.same output, { 1,2,4 }
23
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 @@
1return describe("loops", function() 1return describe("loops", function()
2 return it("should continue", function() 2 it("should continue", function()
3 local input = { 3 local input = {
4 1, 4 1,
5 2, 5 2,
@@ -36,4 +36,34 @@ return describe("loops", function()
36 6 36 6
37 }) 37 })
38 end) 38 end)
39 return it("continue in repeat", function()
40 local output = { }
41 local a = 0
42 repeat
43 local _cond_0 = false
44 local _continue_0 = false
45 repeat
46 a = a + 1
47 if a == 3 then
48 _cond_0 = a == 8
49 _continue_0 = true
50 break
51 end
52 if a == 5 then
53 break
54 end
55 output[#output + 1] = a
56 _cond_0 = a == 8
57 _continue_0 = true
58 until true
59 if not _continue_0 then
60 break
61 end
62 until _cond_0
63 return assert.same(output, {
64 1,
65 2,
66 4
67 })
68 end)
39end) 69end)