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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
/* Unit Test: Advanced Table Features */
/* Tests: Nested tables, mixed types, array-like entries */
/* Nested tables */
nested_table : {
outer: {
inner: {
value: 42
}
}
};
/* Test nested access */
nested_value1 : nested_table.outer.inner.value;
..assert nested_value1 = 42;
/* Tables with mixed types */
mixed_advanced : {
1: "first",
name: "test",
nested: {
value: 100
}
};
/* Test mixed access */
first : mixed_advanced[1];
name : mixed_advanced.name;
nested_value2 : mixed_advanced.nested.value;
..assert first = "first";
..assert name = "test";
..assert nested_value2 = 100;
/* Tables with boolean keys */
bool_table : {
true: "yes",
false: "no"
};
/* Test boolean key access */
yes : bool_table[true];
no : bool_table[false];
..assert yes = "yes";
..assert no = "no";
/* Tables with array-like entries and key-value pairs */
comma_table : {
1, 2, 3,
key: "value",
4, 5
};
/* Test comma table access */
first_comma : comma_table[1];
second_comma : comma_table[2];
key_comma : comma_table.key;
fourth_comma : comma_table[4];
..assert first_comma = 1;
..assert second_comma = 2;
..assert key_comma = "value";
..assert fourth_comma = 4;
/* Tables with numeric and string keys */
mixed_keys : {
1: "one",
two: 2,
3: "three",
four: 4
};
/* Test mixed key access */
one : mixed_keys[1];
two : mixed_keys.two;
three : mixed_keys[3];
four : mixed_keys.four;
..assert one = "one";
..assert two = 2;
..assert three = "three";
..assert four = 4;
..out "Advanced tables test completed";
|