-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1d23525
commit 36d9b69
Showing
4 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicCut.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package it.unibo.tuprolog.solve.systemtest | ||
|
||
import it.unibo.tuprolog.solve.ClassicSolverFactory | ||
import it.unibo.tuprolog.solve.SolverFactory | ||
import it.unibo.tuprolog.solve.TestCut | ||
import kotlin.test.Test | ||
|
||
class TestClassicCut: TestCut, SolverFactory by ClassicSolverFactory { | ||
|
||
private val prototype = TestCut.prototype(this) | ||
|
||
@Test | ||
override fun testCut() { | ||
prototype.testCut() | ||
} | ||
|
||
@Test | ||
override fun testCutFailTrue() { | ||
prototype.testCutFailTrue() | ||
} | ||
|
||
@Test | ||
override fun testCallCutFailTrue() { | ||
prototype.testCallCutFailTrue() | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCut.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package it.unibo.tuprolog.solve.systemtest | ||
|
||
import it.unibo.tuprolog.solve.SolverFactory | ||
import it.unibo.tuprolog.solve.StreamsSolverFactory | ||
import it.unibo.tuprolog.solve.TestCut | ||
import kotlin.test.Test | ||
|
||
class TestStreamsCut: TestCut, SolverFactory by StreamsSolverFactory { | ||
|
||
private val prototype = TestCut.prototype(this) | ||
|
||
@Test | ||
override fun testCut() { | ||
prototype.testCut() | ||
} | ||
|
||
@Test | ||
override fun testCutFailTrue() { | ||
prototype.testCutFailTrue() | ||
} | ||
|
||
@Test | ||
override fun testCallCutFailTrue() { | ||
prototype.testCallCutFailTrue() | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCut.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package it.unibo.tuprolog.solve | ||
|
||
import it.unibo.tuprolog.solve.SolverTest | ||
|
||
interface TestCut : SolverTest { | ||
companion object { | ||
fun prototype(solverFactory: SolverFactory): TestCut = | ||
TestCutImpl(solverFactory) | ||
} | ||
|
||
/** | ||
* Tests the queries | ||
* ```prolog | ||
* ?- !. | ||
* ``` | ||
* succeeds on a solver initialized with default built-ins and with and empty theory. | ||
*/ | ||
fun testCut() | ||
|
||
/** | ||
* Tests the queries | ||
* ```prolog | ||
* ?- (!,fail;true). | ||
* ``` | ||
* succeeds on a solver initialized with default built-ins and with and empty theory. | ||
*/ | ||
fun testCutFailTrue() | ||
|
||
/** | ||
* Tests the queries | ||
* ```prolog | ||
* ?- (call(!),fail;true). | ||
* ``` | ||
* succeeds on a solver initialized with default built-ins and with and empty theory. | ||
*/ | ||
fun testCallCutFailTrue() | ||
} |
47 changes: 47 additions & 0 deletions
47
test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCutImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package it.unibo.tuprolog.solve | ||
|
||
import it.unibo.tuprolog.dsl.theory.prolog | ||
|
||
internal class TestCutImpl(private val solverFactory: SolverFactory) : TestCut{ | ||
override fun testCut() { | ||
prolog { | ||
val solver = solverFactory.solverWithDefaultBuiltins() | ||
|
||
val query = atomOf("!") | ||
val solutions = solver.solve(query, mediumDuration).toList() | ||
|
||
assertSolutionEquals( | ||
kotlin.collections.listOf(query.yes()), | ||
solutions | ||
) | ||
} | ||
} | ||
|
||
override fun testCutFailTrue() { | ||
prolog { | ||
val solver = solverFactory.solverWithDefaultBuiltins() | ||
|
||
val query = ("!" and fail or true) | ||
val solutions = solver.solve(query, mediumDuration).toList() | ||
|
||
assertSolutionEquals( | ||
kotlin.collections.listOf(query.no()), | ||
solutions | ||
) | ||
} | ||
} | ||
|
||
override fun testCallCutFailTrue() { | ||
prolog { | ||
val solver = solverFactory.solverWithDefaultBuiltins() | ||
|
||
val query = (call("!") and fail or true ) | ||
val solutions = solver.solve(query, mediumDuration).toList() | ||
|
||
assertSolutionEquals( | ||
kotlin.collections.listOf(query.yes()), | ||
solutions | ||
) | ||
} | ||
} | ||
} |