aboutsummaryrefslogtreecommitdiff
path: root/spec/inputs
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2026-01-15 17:07:11 +0800
committerLi Jin <dragon-fly@qq.com>2026-01-15 17:07:11 +0800
commitfced0c4f4101ad7c8d81432a0e8c45d38b72616c (patch)
treeed673461c7ef3c614cb5d56905c437f6a6b27454 /spec/inputs
parent4177d237e3ed642b2bba5bec13127a44d2b0524d (diff)
downloadyuescript-fced0c4f4101ad7c8d81432a0e8c45d38b72616c.tar.gz
yuescript-fced0c4f4101ad7c8d81432a0e8c45d38b72616c.tar.bz2
yuescript-fced0c4f4101ad7c8d81432a0e8c45d38b72616c.zip
Added `import global` syntax.
Diffstat (limited to 'spec/inputs')
-rw-r--r--spec/inputs/import_global.yue86
1 files changed, 86 insertions, 0 deletions
diff --git a/spec/inputs/import_global.yue b/spec/inputs/import_global.yue
new file mode 100644
index 0000000..30a274e
--- /dev/null
+++ b/spec/inputs/import_global.yue
@@ -0,0 +1,86 @@
1
2do
3 import global
4 print "hello"
5 math.random 10
6
7do
8 import global
9 value = 1
10 value += 2
11 print value
12
13do
14 local print = (msg) ->
15 return msg
16 do
17 import global
18 print "local"
19 math.random 1
20
21do
22 import global
23 local tostring = (v) -> "local"
24 tostring "value"
25 print tostring 123
26
27do
28 func = (x, y) ->
29 import global
30 return type x, tostring y, print
31 func 1, 2
32
33do
34 import global
35 try
36 func "hello #{world}"
37 catch err
38 print err
39
40do
41 import global
42 global FLAG
43 print FLAG
44 FLAG = 123
45
46do
47 import global
48 global Foo = 10
49 print Foo
50 Foo += 2
51
52do
53 import global
54 global Bar, Baz
55 Bar = 1
56 Baz = 2
57 print Bar, Baz
58
59do
60 import global
61 global *
62 x = 3434
63 if y then
64 x = 10
65
66do
67 import global
68 global ^
69 foobar = "all #{lowercase}"
70 FooBar = "pascal case"
71 FOOBAR = "all #{Uppercase}"
72
73do
74 import global
75 global const class A
76 global const Flag = 1
77 global const const, x, y = "const", 1, 2
78 global const math, table
79 print math, table
80
81do
82 import global
83 with X
84 \func 1, 2, 3
85 .tag = "abc"
86