Skip to content

Commit

Permalink
Removed unused Transition.isValid.
Browse files Browse the repository at this point in the history
  • Loading branch information
clnhlzmn committed Mar 23, 2021
1 parent 6322755 commit 552ab70
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
3 changes: 0 additions & 3 deletions makina-compiler/src/xyz/colinholzman/makina/Transition.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ package xyz.colinholzman.makina
import xyz.colinholzman.makina.State.Companion.getLCCA

data class Transition(val source: State, val target: State) {
fun isValid(): Boolean {
return source.isLeafState() && target.isLeafState()
}
fun getEntrySet(): List<State> {
return (listOf(target) + target.getProperAncestors(listOf(source, target).getLCCA())).reversed()
}
Expand Down
30 changes: 15 additions & 15 deletions makina-compiler/test/xyz/colinholzman/makina/TransitionTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@ package xyz.colinholzman.makina
import org.junit.jupiter.api.Test

import org.junit.jupiter.api.Assertions.*
import xyz.colinholzman.makina.TestStates.Companion.s1
import xyz.colinholzman.makina.TestStates.Companion.s11
import xyz.colinholzman.makina.TestStates.Companion.s111
import xyz.colinholzman.makina.TestStates.Companion.s12
import xyz.colinholzman.makina.TestStates.Companion.s122
import xyz.colinholzman.makina.TestStates.Companion.s2
import xyz.colinholzman.makina.TestStates.Companion.s21

internal class TransitionTest {

@Test
fun isValid() {
assertFalse(Transition(TestStates.s111, TestStates.s2).isValid())
assertFalse(Transition(TestStates.s11, TestStates.s21).isValid())
assertTrue(Transition(TestStates.s111, TestStates.s21).isValid())
}

@Test
fun getEntrySet() {
var transition = Transition(TestStates.s111, TestStates.s122)
assertEquals(listOf(TestStates.s12, TestStates.s122), transition.getEntrySet())
transition = Transition(TestStates.s111, TestStates.s21)
assertEquals(listOf(TestStates.s2, TestStates.s21), transition.getEntrySet())
var transition = Transition(s111, s122)
assertEquals(listOf(s12, s122), transition.getEntrySet())
transition = Transition(s111, s21)
assertEquals(listOf(s2, s21), transition.getEntrySet())
}

@Test
fun getExitSet() {
var transition = Transition(TestStates.s111, TestStates.s122)
assertEquals(listOf(TestStates.s111, TestStates.s11), transition.getExitSet())
transition = Transition(TestStates.s111, TestStates.s21)
assertEquals(listOf(TestStates.s111, TestStates.s11, TestStates.s1), transition.getExitSet())
var transition = Transition(s111, s122)
assertEquals(listOf(s111, s11), transition.getExitSet())
transition = Transition(s111, s21)
assertEquals(listOf(s111, s11, s1), transition.getExitSet())
}
}

0 comments on commit 552ab70

Please sign in to comment.