about summary refs log tree commit diff stats
path: root/js/scripting-lang/scratch_tests/test_table_access_in_functions.txt
diff options
context:
space:
mode:
Diffstat (limited to 'js/scripting-lang/scratch_tests/test_table_access_in_functions.txt')
-rw-r--r--js/scripting-lang/scratch_tests/test_table_access_in_functions.txt22
1 files changed, 22 insertions, 0 deletions
diff --git a/js/scripting-lang/scratch_tests/test_table_access_in_functions.txt b/js/scripting-lang/scratch_tests/test_table_access_in_functions.txt
new file mode 100644
index 0000000..4817b23
--- /dev/null
+++ b/js/scripting-lang/scratch_tests/test_table_access_in_functions.txt
@@ -0,0 +1,22 @@
+/* Test table access in function definitions */
+
+/* Test basic table access */
+user : {role: "admin", active: true};
+test1 : user.role;
+test2 : user.active;
+..out test1;
+..out test2;
+
+/* Test table access in function */
+get_role : user -> user.role;
+test3 : get_role user;
+..out test3;
+
+/* Test table access inside when in function */
+classify_user : user ->
+  when user.role is
+    "admin" then "admin"
+    _ then "user";
+
+test4 : classify_user user;
+..out test4; 
\ No newline at end of file