diff options
Diffstat (limited to 'js/scripting-lang/scratch_tests/test_minimal_enhanced.txt')
-rw-r--r-- | js/scripting-lang/scratch_tests/test_minimal_enhanced.txt | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/js/scripting-lang/scratch_tests/test_minimal_enhanced.txt b/js/scripting-lang/scratch_tests/test_minimal_enhanced.txt new file mode 100644 index 0000000..e4fe6d2 --- /dev/null +++ b/js/scripting-lang/scratch_tests/test_minimal_enhanced.txt @@ -0,0 +1,32 @@ +/* Minimal enhanced case statements test */ + +/* FizzBuzz */ +fizzbuzz : n -> + when (n % 3) (n % 5) is + 0 0 then "FizzBuzz" + 0 _ then "Fizz" + _ 0 then "Buzz" + _ _ then n; + +/* Table access */ +admin_user : {role: "admin"}; +access_level : user -> + when user.role is + "admin" then "full access" + _ then "no access"; + +/* Function calls */ +is_even : n -> n % 2 = 0; +classify_number : n -> + when (is_even n) is + true then "even" + false then "odd"; + +/* Test and output */ +result1 : fizzbuzz 15; +result2 : access_level admin_user; +result3 : classify_number 4; + +..out result1; +..out result2; +..out result3; \ No newline at end of file |