diff options
Diffstat (limited to 'js/scripting-lang/scratch_tests/test_when_pattern_matching.txt')
-rw-r--r-- | js/scripting-lang/scratch_tests/test_when_pattern_matching.txt | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/js/scripting-lang/scratch_tests/test_when_pattern_matching.txt b/js/scripting-lang/scratch_tests/test_when_pattern_matching.txt new file mode 100644 index 0000000..a9efad0 --- /dev/null +++ b/js/scripting-lang/scratch_tests/test_when_pattern_matching.txt @@ -0,0 +1,25 @@ +/* Test when expression pattern matching with tables */ + +/* Test 1: Simple table pattern matching */ +test_value : { status: "placeholder", message: "test" }; + +result1 : when test_value is + { status: "placeholder" } then "Pattern 1 matched" + { status: "active" } then "Pattern 2 matched" + _ then "No pattern matched"; + +..out "Result 1:"; +..out result1; + +/* Test 2: ..listen pattern matching */ +state : ..listen; +..out "State:"; +..out state; + +result2 : when state is + { status: "placeholder" } then "Placeholder pattern matched" + { status: "active" } then "Active pattern matched" + _ then "No pattern matched"; + +..out "Result 2:"; +..out result2; \ No newline at end of file |