#include #include #include #include #include #include #include TestSuite(BasicIf); Test(BasicIf, OnlyIf) { std::cout << "----- IfLoops -----"; ast::PrettyPrinter print(std::cout); ast::Exp* test = parse::parse("if a > 5 then a"); cr_assert_not_null(test); print(test); cr_assert_eq(1, 1); } TestSuite(RealisticIf); Test(RealisticIf, IfElse) { ast::PrettyPrinter print(std::cout); ast::Exp* test = parse::parse("if a > 5 then a else b"); cr_assert_not_null(test); print(test); cr_assert_eq(1, 1); } Test(RealisticIf, IfsElses) { ast::PrettyPrinter print(std::cout); ast::Exp* test = parse::parse("if a > 5 then a else if a < 0 then b else c"); cr_assert_not_null(test); print(test); cr_assert_eq(1, 1); } Test(RealisticIf, DanglingElse) { ast::PrettyPrinter print(std::cout); ast::Exp* test = parse::parse("if a > 5 then if a < 0 then b else c else d"); cr_assert_not_null(test); print(test); cr_assert_eq(1, 1); }