about summary refs log tree commit diff stats
path: root/js/scripting-lang/c/tests/17_table_enhancements_minimal.txt
blob: bdb1c96ede13e31760738f0f55ea070be76c80eb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* Minimal Unit Test: Table Enhancements */

/* Enhanced map with tables */
numbers : {1, 2, 3, 4, 5};
double : x -> x * 2;

/* Test map with single table */
doubled : map @double numbers;
first : doubled[1];
second : doubled[2];
..assert first = 2;
..assert second = 4;

/* Test t.map */
t_doubled : t.map @double numbers;
t_first : t_doubled[1];
..assert t_first = 2;

/* Test each */
each_add : each @add numbers 10;
each_1 : each_add[1];
..assert each_1 = 11;

/* Test embedded functions */
calculator : {
    add: x y -> x + y
};
add_result : calculator.add 5 3;
..assert add_result = 8;

..out "Minimal table enhancements test completed";