about summary refs log tree commit diff stats
path: root/js/scripting-lang/tests/12_advanced_tables.txt
diff options
context:
space:
mode:
Diffstat (limited to 'js/scripting-lang/tests/12_advanced_tables.txt')
-rw-r--r--js/scripting-lang/tests/12_advanced_tables.txt85
1 files changed, 85 insertions, 0 deletions
diff --git a/js/scripting-lang/tests/12_advanced_tables.txt b/js/scripting-lang/tests/12_advanced_tables.txt
new file mode 100644
index 0000000..3b2a326
--- /dev/null
+++ b/js/scripting-lang/tests/12_advanced_tables.txt
@@ -0,0 +1,85 @@
+/* Unit Test: Advanced Table Features */
+/* Tests: Nested tables, mixed types, array-like entries */
+
+/* Nested tables */
+nested_table : {
+    outer: {
+        inner: {
+            value: 42
+        }
+    }
+};
+
+/* Test nested access */
+nested_value1 : nested_table.outer.inner.value;
+..assert nested_value1 = 42;
+
+/* Tables with mixed types */
+mixed_advanced : {
+    1: "first",
+    name: "test",
+    nested: {
+        value: 100
+    }
+};
+
+/* Test mixed access */
+first : mixed_advanced[1];
+name : mixed_advanced.name;
+nested_value2 : mixed_advanced.nested.value;
+
+..assert first = "first";
+..assert name = "test";
+..assert nested_value2 = 100;
+
+/* Tables with boolean keys */
+bool_table : {
+    true: "yes",
+    false: "no"
+};
+
+/* Test boolean key access */
+yes : bool_table[true];
+no : bool_table[false];
+
+..assert yes = "yes";
+..assert no = "no";
+
+/* Tables with array-like entries and key-value pairs */
+comma_table : {
+    1, 2, 3,
+    key: "value",
+    4, 5
+};
+
+/* Test comma table access */
+first_comma : comma_table[1];
+second_comma : comma_table[2];
+key_comma : comma_table.key;
+fourth_comma : comma_table[4];
+
+..assert first_comma = 1;
+..assert second_comma = 2;
+..assert key_comma = "value";
+..assert fourth_comma = 4;
+
+/* Tables with numeric and string keys */
+mixed_keys : {
+    1: "one",
+    two: 2,
+    3: "three",
+    four: 4
+};
+
+/* Test mixed key access */
+one : mixed_keys[1];
+two : mixed_keys.two;
+three : mixed_keys[3];
+four : mixed_keys.four;
+
+..assert one = "one";
+..assert two = 2;
+..assert three = "three";
+..assert four = 4;
+
+..out "Advanced tables test completed"; 
\ No newline at end of file