about summary refs log tree commit diff stats
path: root/js/scripting-lang/tests/integration_02_pattern_matching.txt
diff options
context:
space:
mode:
Diffstat (limited to 'js/scripting-lang/tests/integration_02_pattern_matching.txt')
-rw-r--r--js/scripting-lang/tests/integration_02_pattern_matching.txt64
1 files changed, 64 insertions, 0 deletions
diff --git a/js/scripting-lang/tests/integration_02_pattern_matching.txt b/js/scripting-lang/tests/integration_02_pattern_matching.txt
new file mode 100644
index 0000000..a67bf59
--- /dev/null
+++ b/js/scripting-lang/tests/integration_02_pattern_matching.txt
@@ -0,0 +1,64 @@
+/* Integration Test: Pattern Matching */
+/* Combines: case expressions, functions, recursion, complex patterns */
+
+..out "=== Integration Test: Pattern Matching ===";
+
+/* Recursive factorial with case expressions */
+factorial : n -> 
+  when n is
+    0 then 1
+    _ then n * (factorial (n - 1));
+
+/* Pattern matching with multiple parameters */
+classify : x y -> 
+  when x y is
+    0 0 then "both zero"
+    0 _ then "x is zero"
+    _ 0 then "y is zero"
+    _ _ then when x is
+            0 then "x is zero (nested)"
+            _ then when y is
+                  0 then "y is zero (nested)"
+                  _ then "neither zero";
+
+/* Test factorial */
+fact5 : factorial 5;
+fact3 : factorial 3;
+
+..assert fact5 = 120;
+..assert fact3 = 6;
+
+/* Test classification */
+test1 : classify 0 0;
+test2 : classify 0 5;
+test3 : classify 5 0;
+test4 : classify 5 5;
+
+..assert test1 = "both zero";
+..assert test2 = "x is zero";
+..assert test3 = "y is zero";
+..assert test4 = "neither zero";
+
+/* Complex nested case expressions */
+analyze : x y z -> 
+  when x y z is
+    0 0 0 then "all zero"
+    0 0 _ then "x and y zero"
+    0 _ 0 then "x and z zero"
+    _ 0 0 then "y and z zero"
+    0 _ _ then "only x zero"
+    _ 0 _ then "only y zero"
+    _ _ 0 then "only z zero"
+    _ _ _ then "none zero";
+
+result1 : analyze 0 0 0;
+result2 : analyze 0 1 1;
+result3 : analyze 1 0 1;
+result4 : analyze 1 1 1;
+
+..assert result1 = "all zero";
+..assert result2 = "only x zero";
+..assert result3 = "only y zero";
+..assert result4 = "none zero";
+
+..out "Pattern matching integration test completed"; 
\ No newline at end of file
ee9d4626aec7a44b5dbf1d1d92f010f'>734eef7c ^
dff1abb2 ^

78c50205 ^
734eef7c ^
dff1abb2 ^

ff16e04f ^







a7c3f156 ^


734eef7c ^
78c50205 ^
dff1abb2 ^




a7c3f156 ^



734eef7c ^
a7c3f156 ^
734eef7c ^
a7c3f156 ^
734eef7c ^
dff1abb2 ^
734eef7c ^
dff1abb2 ^

78c50205 ^
734eef7c ^
dff1abb2 ^

ff16e04f ^







a7c3f156 ^


734eef7c ^
78c50205 ^
dff1abb2 ^







734eef7c ^
dff1abb2 ^
734eef7c ^
dff1abb2 ^
734eef7c ^
dff1abb2 ^
734eef7c ^
dff1abb2 ^

dff1abb2 ^
734eef7c ^
dff1abb2 ^

10bbca64 ^

ff16e04f ^





10bbca64 ^



dff1abb2 ^


734eef7c ^
dff1abb2 ^





10bbca64 ^
dff1abb2 ^

10bbca64 ^
dff1abb2 ^






10bbca64 ^




dff1abb2 ^
fda86efe ^
dff1abb2 ^



10bbca64 ^
dff1abb2 ^

f4eee01a ^
f2043a73 ^
dff1abb2 ^

734eef7c ^
dff1abb2 ^
734eef7c ^
dff1abb2 ^
734eef7c ^
dff1abb2 ^
734eef7c ^
dff1abb2 ^

dff1abb2 ^
734eef7c ^
dff1abb2 ^

a621ef95 ^

dff1abb2 ^

ff16e04f ^



dff1abb2 ^


734eef7c ^
dff1abb2 ^






















734eef7c ^
dff1abb2 ^
734eef7c ^
dff1abb2 ^
734eef7c ^
dff1abb2 ^
734eef7c ^
dff1abb2 ^

dff1abb2 ^
734eef7c ^
dff1abb2 ^

ff16e04f ^







dff1abb2 ^


734eef7c ^
dff1abb2 ^




a7c3f156 ^

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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225