aboutsummaryrefslogtreecommitdiff
path: root/spec/inputs/test/export_spec.yue
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2026-01-26 06:38:38 +0000
committerLi Jin <dragon-fly@qq.com>2026-01-26 06:38:38 +0000
commit5d5b657f606b5939062983b1f90c3359d542672e (patch)
tree32132fd8908d6a8920d59362c572815a949f1a1f /spec/inputs/test/export_spec.yue
parentf5006f449a7be1a2f655f1b178ecf1d2f0569dd5 (diff)
downloadyuescript-5d5b657f606b5939062983b1f90c3359d542672e.tar.gz
yuescript-5d5b657f606b5939062983b1f90c3359d542672e.tar.bz2
yuescript-5d5b657f606b5939062983b1f90c3359d542672e.zip
Fixed compiler improvements and added comprehensive test suite
- Fixed makefile preprocessor macro definitions (removed spaces in -D flags) - Added null pointer check in compiler class declaration handling - Added comprehensive test specifications for various language features: - attrib, backcall, cond, config, existential, export, goto - import, literals, macro, metatable, operators, return - string, switch, vararg, with Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'spec/inputs/test/export_spec.yue')
-rw-r--r--spec/inputs/test/export_spec.yue99
1 files changed, 99 insertions, 0 deletions
diff --git a/spec/inputs/test/export_spec.yue b/spec/inputs/test/export_spec.yue
new file mode 100644
index 0000000..c6ea99b
--- /dev/null
+++ b/spec/inputs/test/export_spec.yue
@@ -0,0 +1,99 @@
1describe "export", ->
2 it "should export basic variables", ->
3 a = 1
4 b = 2
5 c = 3
6 assert.same a, 1
7 assert.same b, 2
8 assert.same c, 3
9
10 it "should export multiple variables at once", ->
11 x, y, z = 10, 20, 30
12 assert.same x, 10
13 assert.same y, 20
14 assert.same z, 30
15
16 it "should export class definitions", ->
17 MyClass = class
18 value: 100
19 assert.same MyClass.value, 100
20
21 it "should export function expressions", ->
22 my_func = -> 42
23 assert.same my_func!, 42
24
25 it "should export conditional expressions", ->
26 result = if true
27 "yes"
28 else
29 "no"
30 assert.same result, "yes"
31
32 it "should export switch expressions", ->
33 value = switch 5
34 when 5 then 100
35 else 0
36 assert.same value, 100
37
38 it "should export with do block", ->
39 result = do
40 x = 5
41 x * 2
42 assert.same result, 10
43
44 it "should export comprehension", ->
45 doubled = [i * 2 for i = 1, 5]
46 assert.same doubled, {2, 4, 6, 8, 10}
47
48 it "should export with pipe operator", ->
49 result = {1, 2, 3} |> table.concat
50 assert.same result, "123"
51
52 it "should export nil values", ->
53 empty = nil
54 assert.same empty, nil
55
56 it "should export tables", ->
57 config = {
58 key1: "value1"
59 key2: "value2"
60 }
61 assert.same config.key1, "value1"
62 assert.same config.key2, "value2"
63
64 it "should export string values", ->
65 message = "hello world"
66 assert.same message, "hello world"
67
68 it "should export boolean values", ->
69 flag_true = true
70 flag_false = false
71 assert.is_true flag_true
72 assert.is_false flag_false
73
74 it "should export number values", ->
75 count = 42
76 price = 19.99
77 assert.same count, 42
78 assert.same price, 19.99
79
80 it "should work in nested scope", ->
81 do
82 nested = "value"
83 assert.same nested, "value"
84
85 it "should export function with parameters", ->
86 add = (a, b) -> a + b
87 assert.same add(5, 3), 8
88
89 it "should maintain export order", ->
90 first = 1
91 second = 2
92 third = 3
93 assert.same first, 1
94 assert.same second, 2
95 assert.same third, 3
96
97 it "should work with complex expressions", ->
98 calc = (10 + 20) * 2
99 assert.same calc, 60