PorygonLang/tests/integration/DiagnosticsTests.cpp

30 lines
989 B
C++
Raw Normal View History

#ifdef TESTS_BUILD
#define CATCH_CONFIG_MAIN
#include <catch.hpp>
#include "../src/Script.hpp"
using namespace Porygon;
TEST_CASE( "Diagnostic invalid character", "[integration]" ) {
2019-05-28 15:49:03 +00:00
auto script = Script::Create("1 + 1 @");
REQUIRE(script->Diagnostics -> HasErrors());
auto diags = script->Diagnostics -> GetDiagnostics();
REQUIRE(diags.size() == 1);
2019-06-18 14:39:36 +00:00
CHECK(diags[0].GetCode() == Diagnostics::DiagnosticCode::UnexpectedCharacter);
CHECK(diags[0].GetStartPosition() == 6);
CHECK(diags[0].GetLength() == 1);
2019-05-29 12:58:00 +00:00
delete script;
}
TEST_CASE( "Diagnostic invalid token", "[integration]" ) {
2019-05-28 15:49:03 +00:00
auto script = Script::Create("1 +/ 1");
REQUIRE(script->Diagnostics -> HasErrors());
auto diags = script->Diagnostics -> GetDiagnostics();
REQUIRE(diags.size() == 1);
2019-06-18 14:39:36 +00:00
CHECK(diags[0].GetCode() == Diagnostics::DiagnosticCode::UnexpectedToken);
CHECK(diags[0].GetStartPosition() == 3);
CHECK(diags[0].GetLength() == 1);
2019-05-29 12:58:00 +00:00
delete script;
}
#endif