Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

Commit

Permalink
Add tests for EGL serialization and deserialization
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomassetti committed Feb 14, 2024
1 parent 45c2e6b commit 1777ee4
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
ktorVersion=2.3.8
lionwebVersion=0.2.6
kolasuVersion=1.5.42
kolasuVersion=1.5.43-SNAPSHOT
version=0.0.3-SNAPSHOT
okhttpVersion=4.12.0
jvmVersion=1.8
rpgParserVersion=2.1.42
javaModuleVersion=0.9.15
eglParserVersion=0.0.1
eglParserVersion=0.0.2-SNAPSHOT
1 change: 0 additions & 1 deletion starlasu-client/src/main/kotlin/KolasuClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class KolasuClient(val hostname: String = "localhost", val port: Int = 3005, val
kolasuLanguage.enumClasses.forEach { enumClass ->
val enumeration = lionwebLanguage.elements.filterIsInstance<Enumeration>().find { it.name == enumClass.simpleName }!!
val ec = enumClass
println("HANDLE ENUMERATION $enumeration")
lionWebClient.registerPrimitiveSerializer(
enumeration.id!!
) { value -> (value as Enum<*>).name }
Expand Down
18 changes: 18 additions & 0 deletions starlasu-demo/src/test/kotlin/AbstractLionWebConversion.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import com.strumenta.kolasu.language.KolasuLanguage
import com.strumenta.kolasu.parsing.ParsingResult
import com.strumenta.kolasu.testing.assertASTsAreEqual
import com.strumenta.kolasu.traversing.children
import com.strumenta.kolasu.traversing.walk
import com.strumenta.lwrepoclient.kolasu.KolasuClient
import java.io.InputStream
import com.strumenta.kolasu.model.Node as KNode
Expand All @@ -19,6 +21,22 @@ abstract class AbstractLionWebConversion<R : KNode>(val kolasuLanguage: KolasuLa
) {
val result = parse(inputStream)
val ast = result.root ?: throw IllegalStateException()
val encounteredNodes = mutableListOf<KNode>()
ast.walk().forEach { descendant ->
val encounteredChildren = mutableListOf<KNode>()
descendant.children.forEach { child ->
if (encounteredChildren.any { encounteredChild -> encounteredChild === child }) {
throw IllegalStateException("Duplicate child: $child in $descendant")
} else {
encounteredChildren.add(child)
}
}
if (encounteredNodes.any { encounteredNode -> encounteredNode === descendant }) {
throw IllegalStateException("Duplicate node: $descendant")
} else {
encounteredNodes.add(descendant)
}
}
astChecker.invoke(ast)

val client = KolasuClient()
Expand Down
8 changes: 6 additions & 2 deletions starlasu-demo/src/test/kotlin/EGLLionWebConversion.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import com.strumenta.egl.ast.EglCompilationUnit
import com.strumenta.egl.ast.kLanguage
import com.strumenta.egl.parser.EGLKolasuParser
import com.strumenta.kolasu.parsing.ParsingResult
import org.apache.commons.io.input.BOMInputStream
import java.io.InputStream
import kotlin.test.Ignore
import kotlin.test.Test

class EGLLionWebConversion : AbstractLionWebConversion<EglCompilationUnit>(kLanguage) {
Expand All @@ -14,6 +12,12 @@ class EGLLionWebConversion : AbstractLionWebConversion<EglCompilationUnit>(kLang
return parser.parse(inputStream)
}

@Test
fun sqlBatchSimplified() {
val inputStream = this.javaClass.getResourceAsStream("/egl/SQLBatch_simplified.egl") ?: throw IllegalStateException()
checkSerializationAndDeserialization(inputStream)
}

@Test
fun sqlBatch() {
val inputStream = this.javaClass.getResourceAsStream("/egl/SQLBatch.egl") ?: throw IllegalStateException()
Expand Down
15 changes: 15 additions & 0 deletions starlasu-demo/src/test/resources/egl/SQLBatch_simplified.egl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.CompanyB.CustomerPackage;
program SQLBatch type basicProgram

dept Department;

function main()
try
clearTable();
onException (ex SQLException)
sqlFailure();
end
end


end

0 comments on commit 1777ee4

Please sign in to comment.