remove testcase that attempted to check invalid %import syntax.

we only allow unquoted names, without filename suffix, in %import.
This commit is contained in:
Irmen de Jong 2021-10-13 22:03:28 +02:00
parent 4d27c2901b
commit 0447b3e4cc
4 changed files with 3 additions and 34 deletions

View File

@ -69,8 +69,10 @@ class ModuleImporter(private val program: Program,
}
private fun executeImportDirective(import: Directive, importingModule: Module?): Module? {
if(import.directive!="%import" || import.args.size!=1 || import.args[0].name==null)
if(import.directive!="%import" || import.args.size!=1)
throw SyntaxError("invalid import directive", import.position)
if(!import.args[0].str.isNullOrEmpty() || import.args[0].name==null)
throw SyntaxError("%import requires unquoted module name", import.position)
val moduleName = import.args[0].name!!
if("$moduleName.p8" == import.position.file)
throw SyntaxError("cannot import self", import.position)

View File

@ -46,29 +46,6 @@ class TestCompilerOnImportsAndIncludes {
assertEquals("main", strLits[0].definingScope.name)
assertEquals("foo", strLits[1].definingScope.name)
}
@Test
@Disabled("TODO: why would we not accept string literals as argument to %import?")
fun testImportFromSameFolder_strLit() {
val filepath = assumeReadableFile(fixturesDir,"importFromSameFolder_strLit.p8")
val imported = assumeReadableFile(fixturesDir, "foo_bar.p8")
val platform = Cx16Target
val result = compileFile(platform, optimize = false, fixturesDir, filepath.name)
.assertSuccess()
val program = result.programAst
val startSub = program.entrypoint
val strLits = startSub.statements
.filterIsInstance<FunctionCallStatement>()
.map { it.args[0] as IdentifierReference }
.map { it.targetVarDecl(program)!!.value as StringLiteralValue }
assertEquals("main.bar", strLits[0].value)
assertEquals("foo.bar", strLits[1].value)
assertEquals("main", strLits[0].definingScope.name)
assertEquals("foo", strLits[1].definingScope.name)
}
}
@Nested

View File

@ -1,9 +0,0 @@
%import textio
%import "foo_bar.p8"
main {
str myBar = "main.bar"
sub start() {
txt.print(myBar)
txt.print(foo.bar)
}
}

View File

@ -344,7 +344,6 @@ class TestProg8Parser {
* TODO: this test is testing way too much at once
*/
@Test
//@Disabled("TODO: fix .position of nodes below Module - step 8, 'refactor AST gen'")
fun `of non-root Nodes parsed from a string`() {
val srcText = """
%zeropage basicsafe ; DirectiveArg directly inherits from Node - neither an Expression nor a Statement..?