about summary refs log tree commit diff stats
path: root/js/scripting-lang/tests/10_standard_library.txt
diff options
context:
space:
mode:
Diffstat (limited to 'js/scripting-lang/tests/10_standard_library.txt')
-rw-r--r--js/scripting-lang/tests/10_standard_library.txt49
1 files changed, 49 insertions, 0 deletions
diff --git a/js/scripting-lang/tests/10_standard_library.txt b/js/scripting-lang/tests/10_standard_library.txt
new file mode 100644
index 0000000..e6f7160
--- /dev/null
+++ b/js/scripting-lang/tests/10_standard_library.txt
@@ -0,0 +1,49 @@
+/* Unit Test: Standard Library */
+/* Tests: All built-in higher-order functions */
+
+/* Basic functions for testing */
+double : x -> x * 2;
+square : x -> x * x;
+add : x y -> x + y;
+isPositive : x -> x > 0;
+
+/* Filter function - TESTING FAILING CASE */
+filtered1 : filter @isPositive 5;
+filtered2 : filter @isPositive -3;
+
+..out "filtered1 = ";
+..out filtered1;
+..out "filtered2 = ";
+..out filtered2;
+
+/* Map function */
+mapped1 : map @double 5;
+mapped2 : map @square 3;
+
+..assert mapped1 = 10;
+..assert mapped2 = 9;
+
+/* Compose function */
+composed : compose @double @square 3;
+..assert composed = 18;
+
+/* Pipe function */
+piped : pipe @double @square 2;
+..assert piped = 16;
+
+/* Apply function */
+applied : apply @double 7;
+..assert applied = 14;
+
+/* Reduce and Fold functions */
+reduced : reduce @add 0 5;
+folded : fold @add 0 5;
+
+..assert reduced = 5;
+..assert folded = 5;
+
+/* Curry function */
+curried : curry @add 3 4;
+..assert curried = 7;
+
+..out "Standard library test completed"; 
\ No newline at end of file