Fix compile errors in tests
This commit is contained in:
parent
449991d0c9
commit
15dab8a7a8
1 changed files with 9 additions and 9 deletions
|
@ -14,14 +14,14 @@ auto checkSourceFile(std::string Input) {
|
||||||
DiagnosticStore DS;
|
DiagnosticStore DS;
|
||||||
TextFile T { "#<anonymous>", Input };
|
TextFile T { "#<anonymous>", Input };
|
||||||
VectorStream<std::string, Char> Chars { Input, EOF };
|
VectorStream<std::string, Char> Chars { Input, EOF };
|
||||||
Scanner S(T, Chars);
|
Scanner S { DS, T, Chars };
|
||||||
Punctuator PT(S);
|
Punctuator PT(S);
|
||||||
Parser P(T, PT, DS);
|
Parser P { T, PT, DS };
|
||||||
LanguageConfig Config;
|
LanguageConfig Config;
|
||||||
auto SF = P.parseSourceFile();
|
auto SF = P.parseSourceFile();
|
||||||
SF->setParents();
|
SF->setParents();
|
||||||
Checker C(Config, DS);
|
Checker C { DS };
|
||||||
C.check(SF);
|
C.run(SF);
|
||||||
return std::make_tuple(SF, C, DS);
|
return std::make_tuple(SF, C, DS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,17 +37,17 @@ auto checkExpression(std::string Input) {
|
||||||
TEST(CheckerTest, InfersIntFromIntegerLiteral) {
|
TEST(CheckerTest, InfersIntFromIntegerLiteral) {
|
||||||
auto [Expr, Checker, DS] = checkExpression("1");
|
auto [Expr, Checker, DS] = checkExpression("1");
|
||||||
ASSERT_EQ(DS.countDiagnostics(), 0);
|
ASSERT_EQ(DS.countDiagnostics(), 0);
|
||||||
ASSERT_EQ(Checker.getType(Expr), Checker.getIntType());
|
ASSERT_EQ(*Checker.getTypeOfNode(Expr), *Checker.getIntType());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CheckerTest, TestIllegalTypingVariable) {
|
TEST(CheckerTest, TestIllegalTypingVariable) {
|
||||||
auto [SF, C, DS] = checkSourceFile("let a: Int = \"foo\"");
|
auto [SF, C, DS] = checkSourceFile("let a: Int = \"foo\"");
|
||||||
ASSERT_EQ(DS.countDiagnostics(), 1);
|
ASSERT_EQ(DS.countDiagnostics(), 1);
|
||||||
auto D1 = DS.Diagnostics[0];
|
auto D1 = DS.Diagnostics[0];
|
||||||
ASSERT_EQ(D1->getKind(), DiagnosticKind::UnificationError);
|
ASSERT_EQ(D1->getKind(), DiagnosticKind::TypeMismatchError);
|
||||||
auto Diag = static_cast<UnificationErrorDiagnostic*>(D1);
|
auto Diag = static_cast<TypeMismatchError*>(D1);
|
||||||
// TODO these types have to be sorted first
|
// TODO these types have to be sorted first
|
||||||
ASSERT_EQ(Diag->getLeft(), C.getIntType());
|
ASSERT_EQ(Diag->Left, C.getIntType());
|
||||||
ASSERT_EQ(Diag->getRight(), C.getStringType());
|
ASSERT_EQ(Diag->Right, C.getStringType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue