about summary refs log tree commit diff stats
path: root/js/scripting-lang/scratch_tests/test_predicate_functions.txt
diff options
context:
space:
mode:
Diffstat (limited to 'js/scripting-lang/scratch_tests/test_predicate_functions.txt')
-rw-r--r--js/scripting-lang/scratch_tests/test_predicate_functions.txt35
1 files changed, 35 insertions, 0 deletions
diff --git a/js/scripting-lang/scratch_tests/test_predicate_functions.txt b/js/scripting-lang/scratch_tests/test_predicate_functions.txt
new file mode 100644
index 0000000..e1cba80
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_predicate_functions.txt
@@ -0,0 +1,35 @@
+/* Test predicate functions */
+
+/* Test basic predicate functions */
+is_fizzbuzz : n -> (n % 3 = 0) and (n % 5 = 0);
+is_fizz : n -> n % 3 = 0;
+is_buzz : n -> n % 5 = 0;
+
+/* Test the functions */
+test1 : is_fizzbuzz 15;
+test2 : is_fizz 3;
+test3 : is_buzz 5;
+test4 : is_fizzbuzz 7;
+
+..out test1;
+..out test2;
+..out test3;
+..out test4;
+
+/* Test simple when with boolean */
+simple_test : n ->
+  when true is
+    true then "true"
+    _ then "false";
+
+result1 : simple_test 15;
+..out result1;
+
+/* Test function call in when */
+func_test : n ->
+  when is_fizzbuzz n is
+    true then "FizzBuzz"
+    _ then n;
+
+result2 : func_test 15;
+..out result2; 
\ No newline at end of file