blob: 6d05dfe8d66d3a2754a886d32248fb9fc3d49d26 (
plain) (
blame)
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
|
/* Unit Test: IO Operations */
/* Tests: ..out, ..assert, ..listen, ..emit operations */
/* Test basic output */
..out "Testing IO operations";
/* Test assertions */
x : 5;
y : 3;
sum : x + y;
..assert x = 5;
..assert y = 3;
..assert sum = 8;
..assert x > 3;
..assert y < 10;
..assert sum != 0;
/* Test string comparisons */
..assert "hello" = "hello";
..assert "world" != "hello";
/* Test complex assertions */
..assert (x + y) = 8;
..assert (x * y) = 15;
..assert (x > y) = true;
/* Test ..listen functionality */
state : ..listen;
..assert state.status = "placeholder";
..assert state.message = "State not available in standalone mode";
/* Test ..listen in when expression */
result : when ..listen is
{ status: "placeholder" } then "Placeholder detected"
{ status: "active" } then "Active state detected"
_ then "Unknown state";
..assert result = "Placeholder detected";
/* Test ..emit with different data types */
..emit "String value";
..emit 42;
..emit true;
..emit { key: "value", number: 123 };
/* Test ..emit with computed expressions */
computed_table : { a: 10, b: 20 };
computed_sum : computed_table.a + computed_table.b;
..emit computed_sum;
/* Test ..emit with conditional logic */
condition : 10 > 5;
message : when condition is
true then "Condition is true"
false then "Condition is false";
..emit message;
/* Test that ..emit doesn't interfere with ..out */
..out "This should appear via ..out";
..emit "This should appear via ..emit";
..out "Another ..out message";
..out "IO operations test completed";
|