2023-08-23 21:28:19 +00:00
|
|
|
# transform
|
2023-08-24 12:05:51 +00:00
|
|
|
|
2023-08-23 21:28:19 +00:00
|
|
|
list = (1, 2, 3);
|
2023-08-22 18:26:49 +00:00
|
|
|
test = transform(list, 'input + 1');
|
|
|
|
assert_equal((2, 3, 4), test);
|
|
|
|
|
2023-08-23 21:28:19 +00:00
|
|
|
# string
|
2023-08-24 12:05:51 +00:00
|
|
|
|
2023-08-23 21:28:19 +00:00
|
|
|
test = string(42);
|
|
|
|
assert_equal("42", test);
|
|
|
|
|
|
|
|
test = string(42.42);
|
|
|
|
assert_equal("42.42", test);
|
|
|
|
|
|
|
|
test = string(false);
|
|
|
|
assert_equal("false", test);
|
|
|
|
|
2023-08-24 12:05:51 +00:00
|
|
|
# create_table
|
|
|
|
|
|
|
|
table = create_table(
|
|
|
|
("text", "num"),
|
|
|
|
(
|
|
|
|
("foo", 1),
|
|
|
|
("bar", 2)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
# rows
|
|
|
|
|
|
|
|
test = rows(table);
|
|
|
|
assert_equal(
|
|
|
|
(
|
|
|
|
("foo", 1),
|
|
|
|
("bar", 2)
|
|
|
|
),
|
|
|
|
test
|
|
|
|
);
|
|
|
|
|
|
|
|
# insert
|
|
|
|
|
|
|
|
test = insert(
|
|
|
|
table,
|
|
|
|
(
|
|
|
|
("foo", 1),
|
|
|
|
("bar", 2)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
assert_equal(
|
|
|
|
create_table(
|
|
|
|
("text", "num"),
|
|
|
|
(
|
|
|
|
("foo", 1),
|
|
|
|
("bar", 2),
|
|
|
|
("foo", 1),
|
|
|
|
("bar", 2)
|
|
|
|
)
|
|
|
|
),
|
|
|
|
test
|
|
|
|
);
|
|
|
|
|
|
|
|
# select
|
|
|
|
|
|
|
|
table = create_table(
|
|
|
|
("text", "number", "bool"),
|
|
|
|
(
|
|
|
|
("a", 1, true),
|
|
|
|
("b", 2, true),
|
|
|
|
("a", 3, true)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
test_table = create_table(
|
|
|
|
("text", "bool"),
|
|
|
|
(
|
|
|
|
("a", true),
|
|
|
|
("b", true),
|
|
|
|
("a", true)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
assert_equal(select(table, ("text", "bool")), test_table);
|
|
|
|
|
|
|
|
test_table = create_table(
|
|
|
|
("text", "number", "bool"),
|
|
|
|
(
|
|
|
|
("a", 1, true),
|
|
|
|
("a", 3, true)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
assert_equal(where(table, 'text == "a"'), test_table);
|
|
|
|
|
2023-08-23 21:28:19 +00:00
|
|
|
# count
|
|
|
|
|
2023-08-24 12:05:51 +00:00
|
|
|
table = create_table(
|
|
|
|
("text", "number", "bool"),
|
|
|
|
(
|
|
|
|
("a", 1, true),
|
|
|
|
("b", 2, true),
|
|
|
|
("a", 3, true)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
test = count(table);
|
|
|
|
assert_equal(3, test);
|
|
|
|
|
2023-08-23 21:28:19 +00:00
|
|
|
test = count("123");
|
|
|
|
assert_equal(3, test);
|
|
|
|
|
2023-08-24 12:05:51 +00:00
|
|
|
test = count(1, 2, 3);
|
|
|
|
assert_equal(3, test);
|
|
|
|
|
|
|
|
map.x.z.y = 1;
|
|
|
|
test = count(map);
|
|
|
|
assert_equal(1, test);
|