about summary refs log tree commit diff stats
path: root/js/scripting-lang/scratch_tests/test_embedded_functions_partial.txt
diff options
context:
space:
mode:
Diffstat (limited to 'js/scripting-lang/scratch_tests/test_embedded_functions_partial.txt')
-rw-r--r--js/scripting-lang/scratch_tests/test_embedded_functions_partial.txt50
1 files changed, 50 insertions, 0 deletions
diff --git a/js/scripting-lang/scratch_tests/test_embedded_functions_partial.txt b/js/scripting-lang/scratch_tests/test_embedded_functions_partial.txt
new file mode 100644
index 0000000..7cc201c
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_embedded_functions_partial.txt
@@ -0,0 +1,50 @@
+/* Partial embedded functions test */
+
+/* Test 1: Basic arrow functions */
+basic : {
+    identity: x -> x,
+    double: x -> x * 2,
+    add: x y -> x + y,
+    multiply: x y -> x * y
+};
+
+/* Test 2: When expressions */
+classifier : {
+    classify: x -> when x is
+        0 then "zero"
+        1 then "one"
+        2 then "two"
+        _ then "other",
+    is_positive: x -> when x is
+        0 then false
+        _ then true
+};
+
+/* Output tests */
+..out "=== PARTIAL EMBEDDED FUNCTIONS TEST ===";
+
+..out "Basic functions:";
+id_result : basic.identity 42;
+..out id_result;
+double_result : basic.double 21;
+..out double_result;
+add_result : basic.add 10 20;
+..out add_result;
+mult_result : basic.multiply 6 7;
+..out mult_result;
+
+..out "Classifier functions:";
+class_zero : classifier.classify 0;
+..out class_zero;
+class_one : classifier.classify 1;
+..out class_one;
+class_two : classifier.classify 2;
+..out class_two;
+class_other : classifier.classify 99;
+..out class_other;
+
+..out "Positive test:";
+pos_test : classifier.is_positive 5;
+..out pos_test;
+neg_test : classifier.is_positive -3;
+..out neg_test; 
\ No newline at end of file