2019-05-21 13:11:00 +00:00
|
|
|
#ifdef TESTS_BUILD
|
|
|
|
#define CATCH_CONFIG_MAIN
|
|
|
|
#include <catch.hpp>
|
|
|
|
#include "../src/Script.hpp"
|
|
|
|
|
2019-06-17 16:35:12 +00:00
|
|
|
using namespace Porygon;
|
2019-05-21 13:11:00 +00:00
|
|
|
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();
|
2019-05-21 13:11:00 +00:00
|
|
|
REQUIRE(diags.size() == 1);
|
2019-06-18 14:39:36 +00:00
|
|
|
CHECK(diags[0].GetCode() == Diagnostics::DiagnosticCode::UnexpectedCharacter);
|
2019-05-21 13:11:00 +00:00
|
|
|
CHECK(diags[0].GetStartPosition() == 6);
|
|
|
|
CHECK(diags[0].GetLength() == 1);
|
2019-05-29 12:58:00 +00:00
|
|
|
delete script;
|
2019-05-21 13:11:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
2019-05-21 13:11:00 +00:00
|
|
|
REQUIRE(diags.size() == 1);
|
2019-06-18 14:39:36 +00:00
|
|
|
CHECK(diags[0].GetCode() == Diagnostics::DiagnosticCode::UnexpectedToken);
|
2019-05-21 13:11:00 +00:00
|
|
|
CHECK(diags[0].GetStartPosition() == 3);
|
|
|
|
CHECK(diags[0].GetLength() == 1);
|
2019-05-29 12:58:00 +00:00
|
|
|
delete script;
|
2019-05-21 13:11:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|