Re-enabled two unit tests for the type checker

This commit is contained in:
Tristan B. Kildaire 2021-11-02 09:34:40 +02:00
parent 71be300582
commit 36f073fbff
1 changed files with 74 additions and 74 deletions

View File

@ -1249,97 +1249,97 @@ public final class TypeChecker
}
// /* Test name colliding with container name (1/3) [module] */
// unittest
// {
// import std.file;
// import std.stdio;
// import compiler.lexer;
// import compiler.parsing.core;
/* Test name colliding with container name (1/3) [module] */
unittest
{
import std.file;
import std.stdio;
import compiler.lexer;
import compiler.parsing.core;
// string sourceFile = "source/tlang/testing/collide_container_module1.t";
string sourceFile = "source/tlang/testing/collide_container_module1.t";
// File sourceFileFile;
// sourceFileFile.open(sourceFile); /* TODO: Error handling with ANY file I/O */
// ulong fileSize = sourceFileFile.size();
// byte[] fileBytes;
// fileBytes.length = fileSize;
// fileBytes = sourceFileFile.rawRead(fileBytes);
// sourceFileFile.close();
File sourceFileFile;
sourceFileFile.open(sourceFile); /* TODO: Error handling with ANY file I/O */
ulong fileSize = sourceFileFile.size();
byte[] fileBytes;
fileBytes.length = fileSize;
fileBytes = sourceFileFile.rawRead(fileBytes);
sourceFileFile.close();
// string sourceCode = cast(string) fileBytes;
// Lexer currentLexer = new Lexer(sourceCode);
// currentLexer.performLex();
string sourceCode = cast(string) fileBytes;
Lexer currentLexer = new Lexer(sourceCode);
currentLexer.performLex();
// Parser parser = new Parser(currentLexer.getTokens());
// Module modulle = parser.parse();
// TypeChecker typeChecker = new TypeChecker(modulle);
Parser parser = new Parser(currentLexer.getTokens());
Module modulle = parser.parse();
TypeChecker typeChecker = new TypeChecker(modulle);
// /* Setup testing variables */
// Entity container = typeChecker.getResolver().resolveBest(typeChecker.getModule, "y");
// Entity colliderMember = typeChecker.getResolver().resolveBest(typeChecker.getModule, "y.y");
/* Setup testing variables */
Entity container = typeChecker.getResolver().resolveBest(typeChecker.getModule, "y");
Entity colliderMember = typeChecker.getResolver().resolveBest(typeChecker.getModule, "y.y");
// try
// {
// /* Perform test */
// typeChecker.beginCheck();
try
{
/* Perform test */
typeChecker.beginCheck();
// /* Shouldn't reach here, collision exception MUST occur */
// assert(false);
// }
// catch (CollidingNameException e)
// {
// /* Make sure the member y.y collided with root container (module) y */
// assert(e.defined == container);
// }
// }
/* Shouldn't reach here, collision exception MUST occur */
assert(false);
}
catch (CollidingNameException e)
{
/* Make sure the member y.y collided with root container (module) y */
assert(e.defined == container);
}
}
// /* Test name colliding with container name (2/3) [module, nested collider] */
// unittest
// {
// import std.file;
// import std.stdio;
// import compiler.lexer;
// import compiler.parsing.core;
/* Test name colliding with container name (2/3) [module, nested collider] */
unittest
{
import std.file;
import std.stdio;
import compiler.lexer;
import compiler.parsing.core;
// string sourceFile = "source/tlang/testing/collide_container_module2.t";
string sourceFile = "source/tlang/testing/collide_container_module2.t";
// File sourceFileFile;
// sourceFileFile.open(sourceFile); /* TODO: Error handling with ANY file I/O */
// ulong fileSize = sourceFileFile.size();
// byte[] fileBytes;
// fileBytes.length = fileSize;
// fileBytes = sourceFileFile.rawRead(fileBytes);
// sourceFileFile.close();
File sourceFileFile;
sourceFileFile.open(sourceFile); /* TODO: Error handling with ANY file I/O */
ulong fileSize = sourceFileFile.size();
byte[] fileBytes;
fileBytes.length = fileSize;
fileBytes = sourceFileFile.rawRead(fileBytes);
sourceFileFile.close();
// string sourceCode = cast(string) fileBytes;
// Lexer currentLexer = new Lexer(sourceCode);
// currentLexer.performLex();
string sourceCode = cast(string) fileBytes;
Lexer currentLexer = new Lexer(sourceCode);
currentLexer.performLex();
// Parser parser = new Parser(currentLexer.getTokens());
// Module modulle = parser.parse();
// TypeChecker typeChecker = new TypeChecker(modulle);
Parser parser = new Parser(currentLexer.getTokens());
Module modulle = parser.parse();
TypeChecker typeChecker = new TypeChecker(modulle);
// /* Setup testing variables */
// Entity container = typeChecker.getResolver().resolveBest(typeChecker.getModule, "y");
// Entity colliderMember = typeChecker.getResolver().resolveBest(typeChecker.getModule, "y.a.b.c.y");
/* Setup testing variables */
Entity container = typeChecker.getResolver().resolveBest(typeChecker.getModule, "y");
Entity colliderMember = typeChecker.getResolver().resolveBest(typeChecker.getModule, "y.a.b.c.y");
// try
// {
// /* Perform test */
// typeChecker.beginCheck();
try
{
/* Perform test */
typeChecker.beginCheck();
// /* Shouldn't reach here, collision exception MUST occur */
// assert(false);
// }
// catch (CollidingNameException e)
// {
// /* Make sure the member y.a.b.c.y collided with root container (module) y */
// assert(e.defined == container);
// }
// }
/* Shouldn't reach here, collision exception MUST occur */
assert(false);
}
catch (CollidingNameException e)
{
/* Make sure the member y.a.b.c.y collided with root container (module) y */
assert(e.defined == container);
}
}
// /* Test name colliding with container name (3/3) [container (non-module), nested collider] */
// unittest