Skip to content

Commit

Permalink
Merge branch 'develop' into feature/examples
Browse files Browse the repository at this point in the history
  • Loading branch information
gciatto committed May 19, 2020
2 parents 892e895 + b907908 commit eaf7c6b
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 32 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ configure<GithubReleaseExtension> {
allowUploadToExisting { true }
prerelease { false }
draft { false }
// overwrite { false }
try {
body(
"""|## CHANGELOG
Expand Down
6 changes: 3 additions & 3 deletions core/src/commonMain/kotlin/it/unibo/tuprolog/core/Truth.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ interface Truth : Atom {
val FAIL_FUNCTOR = "fail"

@JvmField
val TRUE: Truth = TruthImpl.True
val TRUE: Truth = TruthImpl(TRUE_FUNCTOR, true)

@JvmField
val FAIL: Truth = TruthImpl.Fail
val FAIL: Truth = TruthImpl(FAIL_FUNCTOR, false)

@JvmField
val FALSE: Truth = TruthImpl.False
val FALSE: Truth = TruthImpl(FALSE_FUNCTOR, false)

@JvmStatic
@JsName("of")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package it.unibo.tuprolog.core.impl
import it.unibo.tuprolog.core.Fact
import it.unibo.tuprolog.core.Struct
import it.unibo.tuprolog.core.Term
import it.unibo.tuprolog.core.Truth

internal class FactImpl(override val head: Struct) : RuleImpl(head, TruthImpl.True), Fact {
internal class FactImpl(override val head: Struct) : RuleImpl(head, Truth.TRUE), Fact {

override val isWellFormed: Boolean = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,7 @@ package it.unibo.tuprolog.core.impl

import it.unibo.tuprolog.core.Truth

internal sealed class TruthImpl(value: String, override val isTrue: Boolean) : Truth, AtomImpl(value) {
object True : TruthImpl(Truth.TRUE_FUNCTOR, true) {
override fun toString(): String = value
}
object Fail : TruthImpl(Truth.FAIL_FUNCTOR, false) {
override fun toString(): String = value
}
object False : TruthImpl(Truth.FALSE_FUNCTOR, false) {
override fun toString(): String = value
}
internal class TruthImpl(value: String, override val isTrue: Boolean) : Truth, AtomImpl(value) {

override fun toString(): String = value
}
20 changes: 13 additions & 7 deletions core/src/commonTest/kotlin/it/unibo/tuprolog/core/TruthTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package it.unibo.tuprolog.core

import it.unibo.tuprolog.core.impl.TruthImpl
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertSame

/**
Expand All @@ -11,28 +12,33 @@ import kotlin.test.assertSame
*/
internal class TruthTest {

private val TRUE = TruthImpl(Truth.TRUE_FUNCTOR, true)
private val FAIL = TruthImpl(Truth.FAIL_FUNCTOR, false)
private val FALSE = TruthImpl(Truth.FALSE_FUNCTOR, false)

@Test
fun trueTruthCreation() {
assertSame(TruthImpl.True, Truth.of(true))
assertSame(Truth.TRUE, Truth.of(true))
}

@Test
fun trueTruthRetrieval() {
assertSame(TruthImpl.True, Truth.TRUE)
assertEquals(TRUE, Truth.TRUE)
}

@Test
fun falseTruthCreation() {
assertSame(TruthImpl.False, Truth.of(false))
assertSame(Truth.FALSE, Truth.of(false))
}

@Test
fun failTruthRetrieval() {
assertSame(TruthImpl.Fail, Truth.FAIL)
fun falseTruthRetrieval() {
assertEquals(FALSE, Truth.FALSE)
}

@Test
fun falseTruthRetrieval() {
assertSame(TruthImpl.False, Truth.FALSE)
fun failTruthRetrieval() {
assertEquals(FAIL, Truth.FAIL)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,24 @@ import kotlin.test.assertTrue
*/
internal class TruthImplTest {

private val `true` = TruthImpl.True
private val fail = TruthImpl.Fail

private val truthInstances = listOf(`true`, fail)
private val truthInstances = listOf(Truth.TRUE, Truth.FAIL, Truth.FALSE)

@Test
fun truthFunctor() {
assertEquals("true", `true`.functor)
assertEquals("fail", fail.functor)
assertEquals("true", Truth.TRUE.functor)
assertEquals("fail", Truth.FAIL.functor)
}

@Test
fun testIsPropertiesAndTypesForTrue() {
TermTypeAssertionUtils.assertIsTruth(`true`)
assertTrue(`true`.isTrue)
TermTypeAssertionUtils.assertIsTruth(Truth.TRUE)
assertTrue(Truth.TRUE.isTrue)
}

@Test
fun testIsPropertiesAndTypesForFail() {
TermTypeAssertionUtils.assertIsTruth(fail)
assertTrue(fail.isFail)
TermTypeAssertionUtils.assertIsTruth(Truth.FAIL)
assertTrue(Truth.FAIL.isFail)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class ClassicSolverSystemTesting : SolverFactory, SolverTest {

private val prototype = SolverTest.prototype(this)

override val defaultBuiltins: AliasedLibrary = DefaultBuiltins
override val defaultBuiltins: AliasedLibrary
get() = DefaultBuiltins

override fun solverOf(
libraries: Libraries,
Expand Down

0 comments on commit eaf7c6b

Please sign in to comment.