about summary refs log tree commit diff stats
path: root/js/scripting-lang/tests/15_performance_stress.txt
diff options
context:
space:
mode:
Diffstat (limited to 'js/scripting-lang/tests/15_performance_stress.txt')
-rw-r--r--js/scripting-lang/tests/15_performance_stress.txt131
1 files changed, 131 insertions, 0 deletions
diff --git a/js/scripting-lang/tests/15_performance_stress.txt b/js/scripting-lang/tests/15_performance_stress.txt
new file mode 100644
index 0000000..7dab1f5
--- /dev/null
+++ b/js/scripting-lang/tests/15_performance_stress.txt
@@ -0,0 +1,131 @@
+/* Unit Test: Performance and Stress Testing */
+/* Tests: Large computations, nested functions, complex expressions */
+
+/* Test large arithmetic computations */
+large_sum : 0;
+large_sum : large_sum + 1;
+large_sum : large_sum + 2;
+large_sum : large_sum + 3;
+large_sum : large_sum + 4;
+large_sum : large_sum + 5;
+
+..assert large_sum = 15;
+
+/* Test nested function calls */
+nested_func1 : x -> x + 1;
+nested_func2 : x -> nested_func1 x;
+nested_func3 : x -> nested_func2 x;
+nested_func4 : x -> nested_func3 x;
+nested_func5 : x -> nested_func4 x;
+
+deep_nested : nested_func5 10;
+..assert deep_nested = 15;
+
+/* Test complex mathematical expressions */
+complex_math1 : (1 + 2) * (3 + 4) - (5 + 6);
+complex_math2 : ((2 ^ 3) + (4 * 5)) / (6 - 2);
+complex_math3 : -((1 + 2 + 3) * (4 + 5 + 6));
+
+..assert complex_math1 = 10;
+..assert complex_math2 = 7;
+..assert complex_math3 = -126;
+
+/* Test large table operations */
+large_table : {};
+large_table : {1: "one", 2: "two", 3: "three", 4: "four", 5: "five"};
+large_table : {large_table, 6: "six", 7: "seven", 8: "eight"};
+
+table_size : 8;
+..assert table_size = 8;
+
+/* Test recursive-like patterns with functions */
+accumulate : n -> case n of
+    0 : 0
+    _ : n + accumulate (n - 1);
+
+sum_10 : accumulate 10;
+..assert sum_10 = 55;
+
+/* Test complex case expressions */
+complex_case : x -> case x of
+    x < 0 : "negative"
+    x = 0 : "zero"
+    x < 10 : "small"
+    x < 100 : "medium"
+    x < 1000 : "large"
+    _ : "huge";
+
+case_test1 : complex_case -5;
+case_test2 : complex_case 0;
+case_test3 : complex_case 5;
+case_test4 : complex_case 50;
+case_test5 : complex_case 500;
+case_test6 : complex_case 5000;
+
+..assert case_test1 = "negative";
+..assert case_test2 = "zero";
+..assert case_test3 = "small";
+..assert case_test4 = "medium";
+..assert case_test5 = "large";
+..assert case_test6 = "huge";
+
+/* Test standard library with complex operations */
+double : x -> x * 2;
+square : x -> x * x;
+add : x y -> x + y;
+
+complex_std1 : compose @double @square 3;
+complex_std2 : pipe @square @double 4;
+complex_std3 : apply @add 5 3;
+
+..assert complex_std1 = 18;
+..assert complex_std2 = 32;
+..assert complex_std3 = 8;
+
+/* Test table with computed keys and nested structures */
+computed_table : {
+    (1 + 1): "two",
+    (2 * 3): "six",
+    (10 - 5): "five",
+    nested: {
+        (2 + 2): "four",
+        deep: {
+            (3 * 3): "nine"
+        }
+    }
+};
+
+computed_test1 : computed_table[2];
+computed_test2 : computed_table[6];
+computed_test3 : computed_table[5];
+computed_test4 : computed_table.nested[4];
+computed_test5 : computed_table.nested.deep[9];
+
+..assert computed_test1 = "two";
+..assert computed_test2 = "six";
+..assert computed_test3 = "five";
+..assert computed_test4 = "four";
+..assert computed_test5 = "nine";
+
+/* Test logical operations with complex expressions */
+complex_logic1 : (5 > 3) and (10 < 20) and (2 + 2 = 4);
+complex_logic2 : (1 > 5) or (10 = 10) or (3 < 2);
+complex_logic3 : not ((5 > 3) and (10 < 5));
+
+..assert complex_logic1 = true;
+..assert complex_logic2 = true;
+..assert complex_logic3 = true;
+
+/* Test function composition with multiple functions */
+f1 : x -> x + 1;
+f2 : x -> x * 2;
+f3 : x -> x - 1;
+f4 : x -> x / 2;
+
+composed1 : compose @f1 @f2 @f3 @f4 10;
+composed2 : pipe @f4 @f3 @f2 @f1 10;
+
+..assert composed1 = 10;
+..assert composed2 = 10;
+
+..out "Performance and stress test completed successfully"; 
\ No newline at end of file