summary refs log tree commit diff stats
path: root/tests/proc/tlambdadonotation.nim
Commit message (Collapse)AuthorAgeFilesLines
* some test cleanups & category reorganization (#22010)metagn2023-06-061-0/+78
* clean up some test categories * mention exact slice issue * magics into system * move trangechecks into overflow * move tmemory to system * try fix CI * try fix CI * final CI fix
41'>41 42 43 44 45 46 47 48 49 50
/* Unit Test: Tables */
/* Tests: Table literals, access, mixed types */

/* Empty table */
empty : {};

/* Array-like table */
numbers : {1, 2, 3, 4, 5};

/* Key-value table */
person : {name: "Alice", age: 30, active: true};

/* Mixed table */
mixed : {1, name: "Bob", 2, active: false};

/* Test array access */
first : numbers[1];
second : numbers[2];
last : numbers[5];

..assert first = 1;
..assert second = 2;
..assert last = 5;

/* Test object access */
name : person.name;
age : person.age;
active : person.active;

..assert name = "Alice";
..assert age = 30;
..assert active = true;

/* Test mixed table access */
first_mixed : mixed[1];
name_mixed : mixed.name;
second_mixed : mixed[2];

..assert first_mixed = 1;
..assert name_mixed = "Bob";
..assert second_mixed = 2;

/* Test bracket notation */
name_bracket : person["name"];
age_bracket : person["age"];

..assert name_bracket = "Alice";
..assert age_bracket = 30;

..out "Tables test completed";