Skip to content

Commit

Permalink
refactor: 💡 move gumtree creation helper dsl to test package
Browse files Browse the repository at this point in the history
  • Loading branch information
Xanonymous-GitHub committed Jul 31, 2024
1 parent 9065687 commit d8270b8
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion core/src/test/kotlin/BasicTreeTest.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import helpers.gumTree
import org.junit.jupiter.api.assertDoesNotThrow
import org.junit.jupiter.api.parallel.Execution
import org.junit.jupiter.api.parallel.ExecutionMode
import tw.xcc.gumtree.helper.gumTree
import tw.xcc.gumtree.model.BasicTree
import java.util.UUID
import kotlin.test.BeforeTest
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/kotlin/GumTreeTest.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import helpers.gumTree
import org.junit.jupiter.api.parallel.Execution
import org.junit.jupiter.api.parallel.ExecutionMode
import tw.xcc.gumtree.helper.gumTree
import tw.xcc.gumtree.model.GumTree
import tw.xcc.gumtree.model.TreeType
import kotlin.test.BeforeTest
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/kotlin/HashSimilarityOrganizerTest.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import helpers.gumTree
import kotlinx.coroutines.runBlocking
import org.junit.jupiter.api.parallel.Execution
import org.junit.jupiter.api.parallel.ExecutionMode
import tw.xcc.gumtree.helper.createHashMemoOf
import tw.xcc.gumtree.helper.crossProductOf
import tw.xcc.gumtree.helper.gumTree
import tw.xcc.gumtree.matchers.HashSimilarityOrganizer
import kotlin.test.BeforeTest
import kotlin.test.Test
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/kotlin/NonFrozenGumTreePoolTest.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import helpers.gumTree
import org.junit.jupiter.api.assertThrows
import org.junit.jupiter.api.parallel.Execution
import org.junit.jupiter.api.parallel.ExecutionMode
import tw.xcc.gumtree.helper.gumTree
import tw.xcc.gumtree.model.NonFrozenGumTreeCachePool
import kotlin.test.BeforeTest
import kotlin.test.Test
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/kotlin/SharedFunctionTest.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import helpers.gumTree
import org.junit.jupiter.api.parallel.Execution
import org.junit.jupiter.api.parallel.ExecutionMode
import tw.xcc.gumtree.helper.gumTree
import tw.xcc.gumtree.matchers.comparator.calculateDiceValue
import tw.xcc.gumtree.matchers.comparator.hasSameParent
import tw.xcc.gumtree.matchers.comparator.numOfMappedDescendents
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package tw.xcc.gumtree.helper
package helpers

import org.jetbrains.annotations.TestOnly
import tw.xcc.gumtree.model.GumTree
import tw.xcc.gumtree.model.TreeType
import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.InvocationKind
import kotlin.contracts.contract

@TestOnly
@DslMarker
internal annotation class GumTreeMarker

@TestOnly
@OptIn(ExperimentalContracts::class)
@GumTreeMarker
internal class GumTreeBuilder(
Expand All @@ -19,6 +22,7 @@ internal class GumTreeBuilder(
) {
private val root by lazy { GumTree(TreeType(grammarName), label, pos, length) }

@TestOnly
internal inline fun child(
grammarName: String,
label: String = "",
Expand All @@ -36,6 +40,7 @@ internal class GumTreeBuilder(
return builder.build().also { root.addChild(it) }
}

@TestOnly
internal fun child(
grammarName: String,
label: String = "",
Expand All @@ -46,6 +51,7 @@ internal class GumTreeBuilder(
internal fun build(): GumTree = root
}

@TestOnly
@OptIn(ExperimentalContracts::class)
internal inline fun gumTree(
grammarName: String,
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/kotlin/matchers/RealWorldTrees.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package matchers

import tw.xcc.gumtree.helper.gumTree
import helpers.gumTree

/**
* The real-world tree 1.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package matchers

import helpers.gumTree
import kotlinx.coroutines.runBlocking
import org.junit.jupiter.api.parallel.Execution
import org.junit.jupiter.api.parallel.ExecutionMode
import tw.xcc.gumtree.helper.gumTree
import tw.xcc.gumtree.matchers.GreedyTopDownMatcher
import tw.xcc.gumtree.model.MappingStorage
import kotlin.test.BeforeTest
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/kotlin/matchers/TopDownMatcherTest1.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package matchers

import helpers.gumTree
import kotlinx.coroutines.runBlocking
import org.junit.jupiter.api.parallel.Execution
import org.junit.jupiter.api.parallel.ExecutionMode
import tw.xcc.gumtree.helper.gumTree
import tw.xcc.gumtree.matchers.GreedyTopDownMatcher
import tw.xcc.gumtree.model.GumTree
import tw.xcc.gumtree.model.MappingStorage
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/kotlin/matchers/TopDownMatcherTest2.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package matchers

import helpers.gumTree
import kotlinx.coroutines.runBlocking
import org.junit.jupiter.api.parallel.Execution
import org.junit.jupiter.api.parallel.ExecutionMode
import tw.xcc.gumtree.helper.gumTree
import tw.xcc.gumtree.matchers.GreedyTopDownMatcher
import tw.xcc.gumtree.model.GumTree
import tw.xcc.gumtree.model.MappingStorage
Expand Down

0 comments on commit d8270b8

Please sign in to comment.