Skip to content

Commit

Permalink
Merge branch 'feature/testing' of gitlab.com:pika-lab/theses/thesis-g…
Browse files Browse the repository at this point in the history
…reco-aa1920 into feature/testing
  • Loading branch information
gciatto committed Aug 28, 2020
2 parents b6d6847 + 36d9b69 commit 8849a05
Show file tree
Hide file tree
Showing 16 changed files with 1,289 additions and 0 deletions.
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()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package it.unibo.tuprolog.solve.systemtest

import it.unibo.tuprolog.solve.*
import it.unibo.tuprolog.solve.channel.InputChannel
import it.unibo.tuprolog.solve.channel.OutputChannel
import it.unibo.tuprolog.solve.exception.PrologWarning
import it.unibo.tuprolog.solve.library.AliasedLibrary
import it.unibo.tuprolog.solve.library.Libraries
import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins
import it.unibo.tuprolog.theory.Theory
import kotlin.test.Test

class TestClassicInteger : TestInteger, SolverFactory by ClassicSolverFactory {

private val prototype = TestInteger.prototype(this)

@Test
override fun testIntPositiveNum() {
prototype.testIntPositiveNum()
}

@Test
override fun testIntNegativeNum() {
prototype.testIntNegativeNum()
}

@Test
override fun testIntDecNum() {
prototype.testIntDecNum()
}

@Test
override fun testIntX() {
prototype.testIntX()
}

@Test
override fun testIntAtom() {
prototype.testIntAtom()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package it.unibo.tuprolog.solve.systemtest

import it.unibo.tuprolog.solve.ClassicSolverFactory
import it.unibo.tuprolog.solve.SolverFactory
import it.unibo.tuprolog.solve.TestNumber
import kotlin.test.Test

class TestClassicNumber : TestNumber, SolverFactory by ClassicSolverFactory {

private val prototype = TestNumber.prototype(this)

@Test
override fun testBasicNum() {
prototype.testBasicNum()
}

@Test
override fun testDecNum() {
prototype.testDecNum()
}

@Test
override fun testNegNum() {
prototype.testNegNum()
}

@Test
override fun testLetterNum() {
prototype.testLetterNum()
}

@Test
override fun testXNum() {
prototype.testXNum()
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package it.unibo.tuprolog.solve.systemtest

import it.unibo.tuprolog.solve.ClassicSolverFactory
import it.unibo.tuprolog.solve.SolverFactory
import it.unibo.tuprolog.solve.TestInteger
import it.unibo.tuprolog.solve.TestTerm
import kotlin.test.Test

class TestClassicTerm : TestTerm, SolverFactory by ClassicSolverFactory {

private val prototype = TestTerm.prototype(this)

@Test
override fun testTermDiff() {
prototype.testTermDiff()
}

@Test
override fun testTermEq() {
prototype.testTermEq()
}

@Test
override fun testTermGreaterThan() {
prototype.testTermGreaterThan()
}

@Test
override fun testTermGreaterThanEq() {
prototype.testTermGreaterThanEq()
}

@Test
override fun testTermLessThan() {
prototype.testTermLessThan()
}

@Test
override fun testTermLessThanEq() {
prototype.testTermLessThanEq()
}
}
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()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package it.unibo.tuprolog.solve.systemtest

import it.unibo.tuprolog.solve.*
import it.unibo.tuprolog.solve.channel.InputChannel
import it.unibo.tuprolog.solve.channel.OutputChannel
import it.unibo.tuprolog.solve.exception.PrologWarning
import it.unibo.tuprolog.solve.library.AliasedLibrary
import it.unibo.tuprolog.solve.library.Libraries
import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins
import it.unibo.tuprolog.theory.Theory
import kotlin.test.Test

class TestStreamsInteger : TestInteger, SolverFactory by StreamsSolverFactory {

private val prototype = TestInteger.prototype(this)

@Test
override fun testIntPositiveNum() {
prototype.testIntPositiveNum()
}

@Test
override fun testIntNegativeNum() {
prototype.testIntNegativeNum()
}

@Test
override fun testIntDecNum() {
prototype.testIntDecNum()
}

@Test
override fun testIntX() {
prototype.testIntX()
}

@Test
override fun testIntAtom() {
prototype.testIntAtom()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package it.unibo.tuprolog.solve.systemtest

import it.unibo.tuprolog.solve.SolverFactory
import it.unibo.tuprolog.solve.StreamsSolverFactory
import it.unibo.tuprolog.solve.TestNumber
import kotlin.test.Test

class TestStreamsNumber : TestNumber, SolverFactory by StreamsSolverFactory {

private val prototype = TestNumber.prototype(this)

@Test
override fun testBasicNum() {
prototype.testBasicNum()
}

@Test
override fun testDecNum() {
prototype.testDecNum()
}

@Test
override fun testNegNum() {
prototype.testNegNum()
}

@Test
override fun testLetterNum() {
prototype.testLetterNum()
}

@Test
override fun testXNum() {
prototype.testXNum()
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package it.unibo.tuprolog.solve.systemtest

import it.unibo.tuprolog.solve.StreamsSolverFactory
import it.unibo.tuprolog.solve.SolverFactory
import it.unibo.tuprolog.solve.TestInteger
import it.unibo.tuprolog.solve.TestTerm
import kotlin.test.Test

class TestStreamsTerm : TestTerm, SolverFactory by StreamsSolverFactory {

private val prototype = TestTerm.prototype(this)

@Test
override fun testTermDiff() {
prototype.testTermDiff()
}

@Test
override fun testTermEq() {
prototype.testTermEq()
}

@Test
override fun testTermGreaterThan() {
prototype.testTermGreaterThan()
}

@Test
override fun testTermGreaterThanEq() {
prototype.testTermGreaterThanEq()
}

@Test
override fun testTermLessThan() {
prototype.testTermLessThan()
}

@Test
override fun testTermLessThanEq() {
prototype.testTermLessThanEq()
}
}
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()
}
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
)
}
}
}
Loading

0 comments on commit 8849a05

Please sign in to comment.