diff options
author | Li Jin <dragon-fly@qq.com> | 2021-10-12 10:04:44 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2021-10-12 10:04:44 +0800 |
commit | 60a979e224f26117f5be82bfca757a2483cef0fd (patch) | |
tree | 7c6af44f6dcada1f23979b820ba830251997b161 /spec/outputs/goto.lua | |
parent | a19b242cbaf53721b20a3163dd06f43e9ef2b487 (diff) | |
download | yuescript-60a979e224f26117f5be82bfca757a2483cef0fd.tar.gz yuescript-60a979e224f26117f5be82bfca757a2483cef0fd.tar.bz2 yuescript-60a979e224f26117f5be82bfca757a2483cef0fd.zip |
fix test.
Diffstat (limited to 'spec/outputs/goto.lua')
-rw-r--r-- | spec/outputs/goto.lua | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/spec/outputs/goto.lua b/spec/outputs/goto.lua new file mode 100644 index 0000000..d1f7b77 --- /dev/null +++ b/spec/outputs/goto.lua | |||
@@ -0,0 +1,67 @@ | |||
1 | do | ||
2 | local a = 0 | ||
3 | ::start:: | ||
4 | a = a + 1 | ||
5 | if a == 5 then | ||
6 | goto done | ||
7 | end | ||
8 | goto start | ||
9 | ::done:: | ||
10 | end | ||
11 | do | ||
12 | for z = 1, 10 do | ||
13 | for y = 1, 10 do | ||
14 | for x = 1, 10 do | ||
15 | if x ^ 2 + y ^ 2 == z ^ 2 then | ||
16 | print('found a Pythagorean triple:', x, y, z) | ||
17 | goto done | ||
18 | end | ||
19 | end | ||
20 | end | ||
21 | end | ||
22 | ::done:: | ||
23 | end | ||
24 | do | ||
25 | for z = 1, 10 do | ||
26 | for y = 1, 10 do | ||
27 | for x = 1, 10 do | ||
28 | if x ^ 2 + y ^ 2 == z ^ 2 then | ||
29 | print('found a Pythagorean triple:', x, y, z) | ||
30 | print('now trying next z...') | ||
31 | goto zcontinue | ||
32 | end | ||
33 | end | ||
34 | end | ||
35 | ::zcontinue:: | ||
36 | end | ||
37 | end | ||
38 | do | ||
39 | ::redo:: | ||
40 | for x = 1, 10 do | ||
41 | for y = 1, 10 do | ||
42 | if not f(x, y) then | ||
43 | goto continue | ||
44 | end | ||
45 | if not g(x, y) then | ||
46 | goto skip | ||
47 | end | ||
48 | if not h(x, y) then | ||
49 | goto redo | ||
50 | end | ||
51 | ::continue:: | ||
52 | end | ||
53 | end | ||
54 | ::skip:: | ||
55 | end | ||
56 | do | ||
57 | local _list_0 = t | ||
58 | for _index_0 = 1, #_list_0 do | ||
59 | local x = _list_0[_index_0] | ||
60 | if x % 2 == 0 then | ||
61 | print('list has even number') | ||
62 | goto has | ||
63 | end | ||
64 | end | ||
65 | print('list lacks even number') | ||
66 | ::has:: | ||
67 | end | ||