Skip to content

Commit

Permalink
test: adjust tests according to new branch representation
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasfara committed Sep 29, 2023
1 parent 9b57ed0 commit 68d9e19
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,27 @@ package it.unibo.collektive.alignment
import io.kotest.core.spec.style.FreeSpec
import io.kotest.matchers.collections.shouldContainAll
import io.kotest.matchers.shouldBe
import it.unibo.collektive.aggregate
import it.unibo.collektive.stack.Path

class BranchAlignment : FreeSpec({
"The branch alignment" - {
"should occur also for nested functions" {
val result = it.unibo.collektive.aggregate {
val result = aggregate {
val condition = true
fun test() {
neighbouring("test")
}

fun test2() {
test()
}
fun test() { neighbouring("test") }
fun test2() { test() }

if (condition) {
test2()
}
if (condition) { test2() }
}

result.toSend.keys.size shouldBe 1 // 1 path of alignment
result.toSend.keys shouldContainAll setOf(
Path(listOf("alignedOn.1", "(condition, true)", "test2.1", "test.1", "neighbouring.1")),
result.toSend.keys shouldBe setOf(
Path(listOf("branch[condition, true]", "test2.1", "test.1", "neighbouring.1")),
)
}
"should not occur in non aggregate context" {
val result = it.unibo.collektive.aggregate {
val result = aggregate {
val condition = true
fun test(): String = "hello"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package it.unibo.collektive.alignment

import io.kotest.core.spec.style.FreeSpec
import io.kotest.matchers.collections.shouldContainAll
import io.kotest.matchers.shouldBe
import it.unibo.collektive.aggregate
import it.unibo.collektive.stack.Path
Expand All @@ -20,7 +19,7 @@ class TestAlignment : FreeSpec({

result.result shouldBe 5
result.toSend.keys.size shouldBe 4 // 4 paths of alignment
result.toSend.keys shouldContainAll setOf(
result.toSend.keys shouldBe setOf(
Path(listOf("neighbouring.1")),
Path(listOf("sharing.1", "neighbouring.2")),
Path(listOf("sharing.1")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class IfConditionTest {
result.toSend.keys.any {
it.path.toString().contains("customCondition1") &&
it.path.toString().contains("customCondition2") &&
it.path.toString().contains("AND") &&
it.path.toString().contains("&") &&
it.path.toString().contains("true")
},
)
Expand All @@ -75,7 +75,7 @@ class IfConditionTest {
result.toSend.keys.any {
it.path.toString().contains("customCondition1") &&
it.path.toString().contains("customCondition2") &&
it.path.toString().contains("OR") &&
it.path.toString().contains("|") &&
it.path.toString().contains("true")
},
)
Expand All @@ -92,7 +92,7 @@ class IfConditionTest {
result.toSend.keys.any {
it.path.toString().contains("customCondition1") &&
it.path.toString().contains("customCondition2") &&
it.path.toString().contains("AND") &&
it.path.toString().contains("&") &&
it.path.toString().contains("not") &&
it.path.toString().contains("true")
},
Expand Down

0 comments on commit 68d9e19

Please sign in to comment.