summaryrefslogtreecommitdiff
path: root/spec/inputs/import_global.yue
blob: d9e5c7f80de04b1256a428d905d5d83570066ec0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110

do
	import global
	print "hello"
	math.random 10

do
	import global
	value = 1
	value += 2
	print value

do
	local print = (msg) ->
		return msg
	do
		import global
		print "local"
		math.random 1

do
	import global
	local tostring = (v) -> "local"
	tostring "value"
	print tostring 123

do
	func = (x, y) ->
		import global
		return type x, tostring y, print
	func 1, 2

do
	import global
	try
		func "hello #{world}"
	catch err
		print err

do
	import global
	global FLAG
	print FLAG
	FLAG = 123

do
	import global
	global Foo = 10
	print Foo
	Foo += 2

do
	import global
	global Bar, Baz
	Bar = 1
	Baz = 2
	print Bar, Baz

do
	import global
	global *
	x = 3434
	if y then
		x = 10

do
	import global
	global ^
	foobar = "all #{lowercase}"
	FooBar = "pascal case"
	FOOBAR = "all #{Uppercase}"

do
	import global
	global const class A
	global const Flag = 1
	global const const, x, y = "const", 1, 2
	global const math, table
	print math, table

do
	import global
	with X
		\func 1, 2, 3
		.tag = "abc"

do
	import global

	f = ->
		func!
		try func

do
	import global
	f = ->
		if result := try? func!
			print result

	switch Item
		when 1
			print "one"
		when 2
			print "two"

import global
f = ->
	if a! < b! < c!
		print "OK"