diff --git a/codeCore/src/prog8/code/core/Position.kt b/codeCore/src/prog8/code/core/Position.kt index 3efb8f1d7..f4b7032c7 100644 --- a/codeCore/src/prog8/code/core/Position.kt +++ b/codeCore/src/prog8/code/core/Position.kt @@ -11,6 +11,6 @@ data class Position(val file: String, val line: Int, val startCol: Int, val endC } companion object { - val DUMMY = Position("", 0, 0, 0) + val DUMMY = Position("~dummy~", 0, 0, 0) } } \ No newline at end of file diff --git a/codeCore/src/prog8/code/core/SourceCode.kt b/codeCore/src/prog8/code/core/SourceCode.kt index ba60e1edb..3c2e5a82d 100644 --- a/codeCore/src/prog8/code/core/SourceCode.kt +++ b/codeCore/src/prog8/code/core/SourceCode.kt @@ -34,7 +34,7 @@ sealed class SourceCode { * Where this [SourceCode] instance came from. * This can be one of the following: * * a normal string representation of a [java.nio.file.Path], if it originates from a file (see [File]) - * * `$stringSourcePrefix44c56085>` if was created via [String] + * * `string:44c56085` if was created via [String] * * `library:/x/y/z.ext` if it is a library file that was loaded from resources (see [Resource]) */ abstract val origin: String @@ -55,7 +55,7 @@ sealed class SourceCode { * filename prefix to designate library files that will be retreived from internal resources rather than disk */ const val libraryFilePrefix = "library:" - const val stringSourcePrefix = "`. + * [origin] will be something like `string:44c56085`. */ class Text(override val text: String): SourceCode() { override val isFromResources = false override val isFromFilesystem = false - override val origin = "$stringSourcePrefix${System.identityHashCode(text).toString(16)}>" + override val origin = "$stringSourcePrefix${System.identityHashCode(text).toString(16)}" override val name = "" } diff --git a/compiler/test/ast/TestProg8Parser.kt b/compiler/test/ast/TestProg8Parser.kt index 521983e53..54b34b69b 100644 --- a/compiler/test/ast/TestProg8Parser.kt +++ b/compiler/test/ast/TestProg8Parser.kt @@ -204,7 +204,7 @@ class TestProg8Parser: FunSpec( { val module = parseModule(SourceCode.Text(srcText)) // Note: assertContains has *actual* as first param - module.name shouldContain Regex("^$") + module.name shouldContain Regex("^string:[0-9a-f\\-]+$") } test("parsed from a file") { @@ -267,7 +267,7 @@ class TestProg8Parser: FunSpec( { val srcText = "bad * { }\n" val e = shouldThrow { parseModule(SourceCode.Text(srcText)) } - assertPosition(e.position, Regex("^$"), 1, 4, 4) + assertPosition(e.position, Regex("^string:[0-9a-f\\-]+$"), 1, 4, 4) } test("in ParseError from bad file source code") { @@ -283,7 +283,7 @@ class TestProg8Parser: FunSpec( { } """ val module = parseModule(SourceCode.Text(srcText)) - assertPositionOf(module, Regex("^$"), 1, 0) + assertPositionOf(module, Regex("^string:[0-9a-f\\-]+$"), 1, 0) } test("of Module parsed from a file") { diff --git a/compiler/test/ast/TestSourceCode.kt b/compiler/test/ast/TestSourceCode.kt index 3bd0c427d..8bb3e9abe 100644 --- a/compiler/test/ast/TestSourceCode.kt +++ b/compiler/test/ast/TestSourceCode.kt @@ -19,7 +19,7 @@ class TestSourceCode: AnnotationSpec() { """ val src = SourceCode.Text(text) - src.origin shouldContain Regex("^$") + src.origin shouldContain Regex("^string:[0-9a-f\\-]+$") src.text shouldBe text src.isFromResources shouldBe false src.isFromFilesystem shouldBe false