using test suites
This commit is contained in:
@@ -6,7 +6,8 @@
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
TEST_CASE("Single character token") {
|
||||
TEST_SUITE("Lexer") {
|
||||
TEST_CASE("Single character token") {
|
||||
struct test {
|
||||
token::type expectedType;
|
||||
std::string expectedLiteral;
|
||||
@@ -34,9 +35,9 @@ TEST_CASE("Single character token") {
|
||||
REQUIRE(tok.type == t.expectedType);
|
||||
REQUIRE(tok.literal == t.expectedLiteral);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
TEST_CASE("More tokens") {
|
||||
TEST_CASE("More tokens") {
|
||||
struct test {
|
||||
token::type expectedType;
|
||||
std::string expectedLiteral;
|
||||
@@ -158,4 +159,5 @@ if (5 < 10) {\
|
||||
REQUIRE(tok.type == t.expectedType);
|
||||
REQUIRE(tok.literal == t.expectedLiteral);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@@ -57,7 +57,8 @@ void test_failing_let_parsing(
|
||||
delete program;
|
||||
}
|
||||
|
||||
TEST_CASE("Malformed let statement (checking for memory leaks)") {
|
||||
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});
|
||||
}
|
||||
@@ -80,9 +81,9 @@ TEST_CASE("Malformed let statement (checking for memory leaks)") {
|
||||
1
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Parse let statement") {
|
||||
TEST_CASE("Parse well formed let statements") {
|
||||
std::stringstream input("\
|
||||
let x = 5;\
|
||||
let y = 10;\
|
||||
@@ -119,4 +120,5 @@ let foobar = 103213;\
|
||||
}
|
||||
|
||||
delete program;
|
||||
}
|
||||
}
|
||||
|
@@ -6,7 +6,8 @@
|
||||
#include <doctest.h>
|
||||
#include <sstream>
|
||||
|
||||
TEST_CASE("Parse return statement") {
|
||||
TEST_SUITE("Parser: return") {
|
||||
TEST_CASE("Parse return statement") {
|
||||
std::stringstream input("\
|
||||
return 5;\
|
||||
return 10;\
|
||||
@@ -36,4 +37,5 @@ return 103213;\
|
||||
}
|
||||
|
||||
delete program;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user