diff --git a/src/main/kotlin/no/uio/microobject/main/MainKt.kt b/src/main/kotlin/no/uio/microobject/main/MainKt.kt index 485af0b..dd63044 100644 --- a/src/main/kotlin/no/uio/microobject/main/MainKt.kt +++ b/src/main/kotlin/no/uio/microobject/main/MainKt.kt @@ -50,6 +50,11 @@ data class Settings(var verbose : Boolean, //Verbosity return prefixMapCache as HashMap } + fun addPrefixes(prefixes: HashMap){ + prefixMapCache = null + extraPrefixes.putAll(prefixes) + } + fun replaceKnownPrefixes(string: String) : String{ var res = string.replace("domain:", "$domainPrefix:") .replace("prog:", "$progPrefix:") diff --git a/src/test/kotlin/no/uio/microobject/test/basic/ExtraPrefixTest.kt b/src/test/kotlin/no/uio/microobject/test/basic/ExtraPrefixTest.kt new file mode 100644 index 0000000..3d60e10 --- /dev/null +++ b/src/test/kotlin/no/uio/microobject/test/basic/ExtraPrefixTest.kt @@ -0,0 +1,17 @@ +package no.uio.microobject.test.basic + +import io.kotest.matchers.shouldBe +import no.uio.microobject.test.MicroObjectTest + +class ExtraPrefixTest: MicroObjectTest() { + fun prefixTest() { + val (interpreter,_) = initInterpreter("persons", StringLoad.RES) + + interpreter.settings.prefixMap().containsKey("ast") shouldBe false + interpreter.settings.addPrefixes(hashMapOf("ast" to "http://www.smolang.org/ast#")) + interpreter.settings.prefixMap().containsKey("ast") shouldBe true + } + init { + prefixTest() + } +} \ No newline at end of file