about summary refs log tree commit diff stats
path: root/js/scripting-lang/tests/unit/05_io_operations.txt
diff options
context:
space:
mode:
Diffstat (limited to 'js/scripting-lang/tests/unit/05_io_operations.txt')
-rw-r--r--js/scripting-lang/tests/unit/05_io_operations.txt60
1 files changed, 60 insertions, 0 deletions
diff --git a/js/scripting-lang/tests/unit/05_io_operations.txt b/js/scripting-lang/tests/unit/05_io_operations.txt
new file mode 100644
index 0000000..7ef92ad
--- /dev/null
+++ b/js/scripting-lang/tests/unit/05_io_operations.txt
@@ -0,0 +1,60 @@
+/* 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 */
+listen_handler : state -> when state is { status: "placeholder" } then "Placeholder detected" { status: "active" } then "Active state detected" _ then "Unknown state";
+result : listen_handler ..listen;
+..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;
+condition_handler : cond -> when cond is true then "Condition is true" false then "Condition is false";
+message : condition_handler condition;
+..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