diff options
Diffstat (limited to 'js/scripting-lang/tests/05_io_operations.txt')
-rw-r--r-- | js/scripting-lang/tests/05_io_operations.txt | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/js/scripting-lang/tests/05_io_operations.txt b/js/scripting-lang/tests/05_io_operations.txt new file mode 100644 index 0000000..6d05dfe --- /dev/null +++ b/js/scripting-lang/tests/05_io_operations.txt @@ -0,0 +1,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"; \ No newline at end of file |