diff options
author | Li Jin <dragon-fly@qq.com> | 2021-02-17 11:22:07 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2021-02-17 11:22:07 +0800 |
commit | 7066392d1c974065181d95d93274136dcd625d43 (patch) | |
tree | cf51eafc2c52cbc12246a306bca172d799193d30 /spec/inputs/with.yue | |
parent | 90cd12ad9ef465f3e435e1bd034dcfbe4e19d016 (diff) | |
download | yuescript-7066392d1c974065181d95d93274136dcd625d43.tar.gz yuescript-7066392d1c974065181d95d93274136dcd625d43.tar.bz2 yuescript-7066392d1c974065181d95d93274136dcd625d43.zip |
stop reusing variables, rename project.
Diffstat (limited to 'spec/inputs/with.yue')
-rw-r--r-- | spec/inputs/with.yue | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/spec/inputs/with.yue b/spec/inputs/with.yue new file mode 100644 index 0000000..d88e109 --- /dev/null +++ b/spec/inputs/with.yue | |||
@@ -0,0 +1,123 @@ | |||
1 | |||
2 | do | ||
3 | a = -> | ||
4 | with something | ||
5 | print .hello | ||
6 | print hi | ||
7 | print "world" | ||
8 | |||
9 | do | ||
10 | with leaf | ||
11 | .world! | ||
12 | .world 1,2,3 | ||
13 | |||
14 | g = .what.is.this | ||
15 | |||
16 | .hi 1,2,3 | ||
17 | |||
18 | \hi(1,2).world 2323 | ||
19 | |||
20 | \hi "yeah", "man" | ||
21 | .world = 200 | ||
22 | |||
23 | do | ||
24 | zyzyzy = with something | ||
25 | .set_state "hello world" | ||
26 | |||
27 | do | ||
28 | x = 5 + with Something! | ||
29 | \write "hello world" | ||
30 | |||
31 | |||
32 | do | ||
33 | x = { | ||
34 | hello: with yeah | ||
35 | \okay! | ||
36 | } | ||
37 | |||
38 | do | ||
39 | with foo | ||
40 | _ = \prop"something".hello | ||
41 | .prop\send(one) | ||
42 | .prop\send one | ||
43 | |||
44 | |||
45 | -- | ||
46 | |||
47 | do | ||
48 | with a, b -- b is lost | ||
49 | print .world | ||
50 | |||
51 | mod = with _M = {} | ||
52 | .Thing = "hi" | ||
53 | |||
54 | -- operate on a only | ||
55 | with a, b = something, pooh | ||
56 | print .world | ||
57 | |||
58 | x = with a, b = 1, 2 | ||
59 | print a + b | ||
60 | |||
61 | print with a, b = 1, 2 | ||
62 | print a + b | ||
63 | |||
64 | -- assignment lhs must be evaluated in the order they appear | ||
65 | p = with hello!.x, world!.y = 1, 2 | ||
66 | print a + b | ||
67 | |||
68 | -- | ||
69 | |||
70 | do | ||
71 | x = "hello" | ||
72 | with x | ||
73 | x\upper! | ||
74 | |||
75 | do | ||
76 | with k = "jo" | ||
77 | print \upper! | ||
78 | |||
79 | do | ||
80 | with a,b,c = "", "", "" | ||
81 | print \upper! | ||
82 | |||
83 | do | ||
84 | a = "bunk" | ||
85 | with a,b,c = "", "", "" | ||
86 | print \upper! | ||
87 | |||
88 | do | ||
89 | with j | ||
90 | print \upper! | ||
91 | |||
92 | do | ||
93 | with k.j = "jo" | ||
94 | print \upper! | ||
95 | |||
96 | do | ||
97 | with a | ||
98 | print .b | ||
99 | -- nested `with`s should change the scope correctly | ||
100 | with .c | ||
101 | print .d | ||
102 | |||
103 | do | ||
104 | with a | ||
105 | -- nested `with`s with assignments should change the scope correctly | ||
106 | with .b = 2 | ||
107 | print .c | ||
108 | |||
109 | do | ||
110 | _ = -> | ||
111 | with hi | ||
112 | return .a, .b | ||
113 | |||
114 | do | ||
115 | with tb | ||
116 | .x = item | ||
117 | .field | ||
118 | \func 123 | ||
119 | |||
120 | do | ||
121 | with dad | ||
122 | .if "yes" | ||
123 | y = .end.of.function | ||