Skip to content

Commit

Permalink
Merge pull request #48 from sievericcardo/add-prefixes
Browse files Browse the repository at this point in the history
Add prefixes to prefixMap for the interpreter
  • Loading branch information
Edkamb authored May 3, 2024
2 parents 338f7da + 775f238 commit 60e9424
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/kotlin/no/uio/microobject/main/MainKt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ data class Settings(var verbose : Boolean, //Verbosity
return prefixMapCache as HashMap<String, String>
}

fun addPrefixes(prefixes: HashMap<String, String>){
prefixMapCache = null
extraPrefixes.putAll(prefixes)
}

fun replaceKnownPrefixes(string: String) : String{
var res = string.replace("domain:", "$domainPrefix:")
.replace("prog:", "$progPrefix:")
Expand Down
17 changes: 17 additions & 0 deletions src/test/kotlin/no/uio/microobject/test/basic/ExtraPrefixTest.kt
Original file line number Diff line number Diff line change
@@ -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()
}
}

0 comments on commit 60e9424

Please sign in to comment.