Skip to content

Commit

Permalink
update tests because of changes in LionWeb
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomassetti committed Sep 27, 2023
1 parent 75d97cf commit 9648a6c
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package com.strumenta.kolasu.kcp

import com.strumenta.kolasu.model.Node
import com.strumenta.kolasu.model.ReferenceByName
import org.jetbrains.kotlin.GeneratedDeclarationKey
import org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext
import org.jetbrains.kotlin.backend.common.extensions.FirIncompatiblePluginAPI
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
Expand Down Expand Up @@ -56,7 +55,7 @@ class FieldObservableExtension(val pluginContext: IrPluginContext) : IrElementTr
val anonymousInitializerSymbolImpl = IrFactoryImpl.createAnonymousInitializer(
declaration.startOffset,
declaration.endOffset,
IrDeclarationOrigin.GeneratedByPlugin(object : GeneratedDeclarationKey() {}),
IrDeclarationOrigin.GeneratedByPlugin(StarLasuGeneratedDeclarationKey),
IrAnonymousInitializerSymbolImpl(),
false
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import org.jetbrains.kotlin.ir.util.statements
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameOrNull

object StarLasuGeneratedDeclarationKey : GeneratedDeclarationKey()

/**
* Set the parent appropriately when modifying a containment value.
*/
Expand Down Expand Up @@ -88,7 +90,7 @@ class SettingParentExtension(val pluginContext: IrPluginContext, val messageColl
val anonymousInitializerSymbolImpl = IrFactoryImpl.createAnonymousInitializer(
-1,
-1,
IrDeclarationOrigin.GeneratedByPlugin(object : GeneratedDeclarationKey() {}),
IrDeclarationOrigin.GeneratedByPlugin(StarLasuGeneratedDeclarationKey),
IrAnonymousInitializerSymbolImpl(),
false
)
Expand Down
3 changes: 3 additions & 0 deletions lionweb/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ plugins {
val lionwebVersion = extra["lionwebVersion"]
val kotlinVersion = extra["kotlinVersion"]
val clikt_version = extra["clikt_version"]
val gson_version = extra["gson_version"]

dependencies {
implementation("com.github.ajalt.clikt:clikt:$clikt_version")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion")
testImplementation("com.google.code.gson:gson:$gson_version")
testImplementation("io.github.mkfl3x:json-delta:1.3")
implementation("io.lionweb.lioncore-java:lioncore-java-core:$lionwebVersion")
api(project(":core"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class LionWebModelConverter {
fun unserializeToNodes(json: String, useDynamicNodesIfNeeded: Boolean = true): List<LWNode> {
val js = JsonSerialization.getStandardSerialization()
languageConverter.knownLWLanguages().forEach {
js.conceptResolver.registerLanguage(it)
js.classifierResolver.registerLanguage(it)
}
if (useDynamicNodesIfNeeded) {
js.enableDynamicNodes()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class LionWebLanguageConverterTest {
assertEquals(false, simpleNodeBValue.isOptional)
assertEquals(LionCoreBuiltins.getString(), simpleNodeBValue.type)

val validationResult = LanguageValidator().validateLanguage(lwLanguage)
val validationResult = LanguageValidator().validate(lwLanguage)
assertEquals(true, validationResult.isSuccessful, validationResult.issues.toString())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import com.strumenta.kolasu.model.ReferenceByName
import com.strumenta.kolasu.model.assignParents
import com.strumenta.kolasu.testing.assertASTsAreEqual
import io.lionweb.lioncore.java.serialization.JsonSerialization
import org.mkfl3x.jsondelta.JsonDelta
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertSame
import kotlin.test.assertTrue

class LionWebModelConverterTest {

Expand Down Expand Up @@ -52,6 +54,7 @@ class LionWebModelConverterTest {
}
],
"references": [],
"annotations":[],
"parent": null
},
{
Expand All @@ -64,9 +67,9 @@ class LionWebModelConverterTest {
"properties": [
{
"property": {
"language": "LIonCore-builtins",
"language": "LionCore-builtins",
"version": "1",
"key": "LIonCore-builtins-INamed-name"
"key": "LionCore-builtins-INamed-name"
},
"value": "A1"
}
Expand Down Expand Up @@ -96,6 +99,7 @@ class LionWebModelConverterTest {
]
}
],
"annotations":[],
"parent": "UNKNOWN_SOURCE_root"
},
{
Expand All @@ -117,6 +121,7 @@ class LionWebModelConverterTest {
],
"children": [],
"references": [],
"annotations":[],
"parent": "UNKNOWN_SOURCE_root"
},
{
Expand All @@ -129,9 +134,9 @@ class LionWebModelConverterTest {
"properties": [
{
"property": {
"language": "LIonCore-builtins",
"language": "LionCore-builtins",
"version": "1",
"key": "LIonCore-builtins-INamed-name"
"key": "LionCore-builtins-INamed-name"
},
"value": "A3"
}
Expand Down Expand Up @@ -163,6 +168,7 @@ class LionWebModelConverterTest {
]
}
],
"annotations":[],
"parent": "UNKNOWN_SOURCE_root"
},
{
Expand All @@ -184,6 +190,7 @@ class LionWebModelConverterTest {
],
"children": [],
"references": [],
"annotations":[],
"parent": "UNKNOWN_SOURCE_root_childrez_2"
}
]
Expand Down Expand Up @@ -244,7 +251,9 @@ class LionWebModelConverterTest {
assertSame(child1, refValue3[0].referred)

val js = JsonSerialization.getStandardSerialization()
assertEquals(serialized, js.serializeTreeToJsonString(lwAST))

val report = JsonDelta().compare(serialized, js.serializeTreeToJsonString(lwAST))
assertTrue(report.success, message = "Mismatches: ${report.mismatches}")
}

@Test
Expand Down

0 comments on commit 9648a6c

Please sign in to comment.