Added nested lists test
All checks were successful
ci/woodpecker/push/workflow Pipeline was successful

This commit is contained in:
2025-10-03 22:29:40 +03:00
committed by Emin Arslan
parent 8a9655cdd5
commit ed791d96f2

View File

@@ -46,7 +46,22 @@ TEST_CASE("Parser parses correctly", "[Parser]") {
REQUIRE(get<Symbol>(pop_and_front(dq)).value == "-");
REQUIRE(get<Symbol>(pop_and_front(dq)).value == "-.");
REQUIRE(get<Symbol>(pop_and_front(dq)).value == ".-");
}
SECTION("Nested lists") {
Parser p(Lexer("((((0) (1) (2) (3))))"));
auto l0 = get<List>(*p.next()).list;
auto l1 = get<List>(pop_and_front(l0)).list;
auto l2 = get<List>(pop_and_front(l1)).list;
auto l20 = get<List>(pop_and_front(l2)).list;
auto l21 = get<List>(pop_and_front(l2)).list;
auto l22 = get<List>(pop_and_front(l2)).list;
auto l23 = get<List>(pop_and_front(l2)).list;
REQUIRE(get<Integer>(pop_and_front(l20)).value == 0);
REQUIRE(get<Integer>(pop_and_front(l21)).value == 1);
REQUIRE(get<Integer>(pop_and_front(l22)).value == 2);
REQUIRE(get<Integer>(pop_and_front(l23)).value == 3);
}
}