## expand-list-comprehension-syntax-unit-test.pkg
# Compiled by:
#
src/lib/test/unit-tests.lib# Run by:
#
src/lib/test/all-unit-tests.pkgpackage expand_list_comprehension_syntax_unit_test {
include package unit_test; # unit_test is from
src/lib/src/unit-test.pkg name = "src/lib/compiler/front/parser/raw-syntax/expand-list-comprehension-syntax-unit-test.pkg";
fun run ()
=
{
printf "\nDoing %s:\n" name;
assert ( [ i*i for i in (1..99) where int::is_prime i ]
==
[ 1, 4, 9, 25, 49, 121, 169, 289, 361, 529, 841, 961, 1369,
1681, 1849, 2209, 2809, 3481, 3721, 4489, 5041, 5329, 6241,
6889, 7921, 9409
]
);
assert ( [ (i,j) for i in (0..4) for j in (5..9) ]
==
[ (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (1, 5),
(1, 6), (1, 7), (1, 8), (1, 9), (2, 5), (2, 6),
(2, 7), (2, 8), (2, 9), (3, 5), (3, 6), (3, 7),
(3, 8), (3, 9), (4, 5), (4, 6), (4, 7), (4, 8),
(4, 9)
]
);
assert ( [ (x,y,z) for x in 1..20 for y in x..20 for z in y..20 where x*x + y*y == z*z ]
==
[ (3, 4, 5), (5, 12, 13), (6, 8, 10), (8, 15, 17), (9, 12, 15), (12, 16, 20)]
);
summarize_unit_tests name;
};
};