using test suites

This commit is contained in:
Karma Riuk
2025-07-08 10:36:08 +02:00
parent ef624de4ef
commit 2dfff61346
3 changed files with 192 additions and 186 deletions

View File

@@ -6,6 +6,7 @@
#include <sstream>
#include <string>
TEST_SUITE("Lexer") {
TEST_CASE("Single character token") {
struct test {
token::type expectedType;
@@ -159,3 +160,4 @@ if (5 < 10) {\
REQUIRE(tok.literal == t.expectedLiteral);
}
};
}

View File

@@ -57,6 +57,7 @@ void test_failing_let_parsing(
delete program;
}
TEST_SUITE("Parser: let") {
TEST_CASE("Malformed let statement (checking for memory leaks)") {
SUBCASE("Second token not identifier") {
test_failing_let_parsing("let 5 = 5;", {token::type::IDENTIFIER});
@@ -82,7 +83,7 @@ TEST_CASE("Malformed let statement (checking for memory leaks)") {
}
}
TEST_CASE("Parse let statement") {
TEST_CASE("Parse well formed let statements") {
std::stringstream input("\
let x = 5;\
let y = 10;\
@@ -120,3 +121,4 @@ let foobar = 103213;\
delete program;
}
}

View File

@@ -6,6 +6,7 @@
#include <doctest.h>
#include <sstream>
TEST_SUITE("Parser: return") {
TEST_CASE("Parse return statement") {
std::stringstream input("\
return 5;\
@@ -37,3 +38,4 @@ return 103213;\
delete program;
}
}