mirror of
https://github.com/irmen/prog8.git
synced 2024-11-03 13:07:54 +00:00
remove testcase that attempted to check invalid %import syntax.
we only allow unquoted names, without filename suffix, in %import.
This commit is contained in:
parent
4d27c2901b
commit
0447b3e4cc
@ -69,8 +69,10 @@ class ModuleImporter(private val program: Program,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun executeImportDirective(import: Directive, importingModule: Module?): Module? {
|
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)
|
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!!
|
val moduleName = import.args[0].name!!
|
||||||
if("$moduleName.p8" == import.position.file)
|
if("$moduleName.p8" == import.position.file)
|
||||||
throw SyntaxError("cannot import self", import.position)
|
throw SyntaxError("cannot import self", import.position)
|
||||||
|
@ -46,29 +46,6 @@ class TestCompilerOnImportsAndIncludes {
|
|||||||
assertEquals("main", strLits[0].definingScope.name)
|
assertEquals("main", strLits[0].definingScope.name)
|
||||||
assertEquals("foo", strLits[1].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
|
@Nested
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
%import textio
|
|
||||||
%import "foo_bar.p8"
|
|
||||||
main {
|
|
||||||
str myBar = "main.bar"
|
|
||||||
sub start() {
|
|
||||||
txt.print(myBar)
|
|
||||||
txt.print(foo.bar)
|
|
||||||
}
|
|
||||||
}
|
|
@ -344,7 +344,6 @@ class TestProg8Parser {
|
|||||||
* TODO: this test is testing way too much at once
|
* TODO: this test is testing way too much at once
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
//@Disabled("TODO: fix .position of nodes below Module - step 8, 'refactor AST gen'")
|
|
||||||
fun `of non-root Nodes parsed from a string`() {
|
fun `of non-root Nodes parsed from a string`() {
|
||||||
val srcText = """
|
val srcText = """
|
||||||
%zeropage basicsafe ; DirectiveArg directly inherits from Node - neither an Expression nor a Statement..?
|
%zeropage basicsafe ; DirectiveArg directly inherits from Node - neither an Expression nor a Statement..?
|
||||||
|
Loading…
Reference in New Issue
Block a user