diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Atom.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Atom.kt index ab20b8b74..795e2e60f 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Atom.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Atom.kt @@ -25,7 +25,6 @@ interface Atom : Struct, Constant { override val isTrue: Boolean get() = Truth.TRUE_FUNCTOR == value - override val isFail: Boolean get() = Truth.FAIL_FUNCTOR == value diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Clause.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Clause.kt index 2e03509e1..06167dc06 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Clause.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Clause.kt @@ -111,5 +111,4 @@ interface Clause : Struct { */ internal val defaultPreparationForExecutionVisitor = preparationForExecutionVisitor() } - } diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/ClauseExtensions.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/ClauseExtensions.kt index 604ea038f..7d9467d20 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/ClauseExtensions.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/ClauseExtensions.kt @@ -5,8 +5,6 @@ package it.unibo.tuprolog.core import kotlin.js.JsName import kotlin.jvm.JvmName - - /** * Prepares the receiver Clause for execution, using the provided visitor * @@ -19,4 +17,4 @@ fun Clause.prepareForExecution(): Clause = @JsName("prepareForExecutionWithUnifier") fun Clause.prepareForExecution(unifier: Substitution.Unifier): Clause = - accept(Clause.preparationForExecutionVisitor(unifier)) as Clause \ No newline at end of file + accept(Clause.preparationForExecutionVisitor(unifier)) as Clause diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Collection.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Collection.kt index d31f55c6b..e4ec64046 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Collection.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Collection.kt @@ -28,4 +28,4 @@ interface Collection : Struct { @JsName("unfold") fun unfold(): Sequence -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Cons.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Cons.kt index e8fd92273..db16788e3 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Cons.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Cons.kt @@ -2,7 +2,6 @@ package it.unibo.tuprolog.core import it.unibo.tuprolog.core.impl.ConsImpl import kotlin.js.JsName -import kotlin.jvm.JvmField import kotlin.jvm.JvmStatic import it.unibo.tuprolog.core.List as LogicList diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Constant.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Constant.kt index 591b5801e..cbf355408 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Constant.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Constant.kt @@ -13,4 +13,4 @@ interface Constant : Term { * Empty companion aimed at letting extensions be injected through extension methods */ companion object -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Conversions.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Conversions.kt index 146479fca..1696ddae8 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Conversions.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Conversions.kt @@ -57,4 +57,4 @@ fun Sequence.toTerm(): List = this.asIterable().toTerm() fun Iterable.toTerm(): List = List.of(this) @JsName("arrayToTerm") -fun Array.toTerm(): List = List.of(*this) \ No newline at end of file +fun Array.toTerm(): List = List.of(*this) diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Empty.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Empty.kt index 4e9708cdf..3a0c2aae3 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Empty.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Empty.kt @@ -1,7 +1,6 @@ package it.unibo.tuprolog.core import kotlin.js.JsName -import kotlin.jvm.JvmField import kotlin.jvm.JvmStatic interface Empty : Atom { diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Formatter.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Formatter.kt index 69b22628b..217c90e77 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Formatter.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Formatter.kt @@ -15,4 +15,3 @@ interface Formatter { @JsName("format") fun format(value: T): String } - diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/FormatterExtensions.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/FormatterExtensions.kt index 9fa81b372..e9c720894 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/FormatterExtensions.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/FormatterExtensions.kt @@ -9,4 +9,3 @@ import kotlin.jvm.JvmName fun T.format(formatter: Formatter): String { return formatter.format(this) } - diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Indicator.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Indicator.kt index 7ed7437fa..7c00e9425 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Indicator.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Indicator.kt @@ -46,8 +46,8 @@ interface Indicator : Struct { @JsName("isWellFormed") val isWellFormed: Boolean get() = nameTerm is Atom && - arityTerm is Integer && - arityTerm.`as`().intValue.signum >= 0 + arityTerm is Integer && + arityTerm.`as`().intValue.signum >= 0 /** The indicated functor name, if well-formed */ @JsName("indicatedName") @@ -86,4 +86,4 @@ interface Indicator : Struct { @JsName("ofString") fun of(name: String, arity: Int): Indicator = of(Atom.of(name), Integer.of(arity)) } -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Integer.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Integer.kt index 9f74ee43d..3cbab936a 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Integer.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Integer.kt @@ -27,7 +27,8 @@ interface Integer : Numeric { companion object { @JvmField - val INTEGER_REGEX_PATTERN = """^[+\-]?(0[xXbBoO])?[0-9A-Fa-f]+$""".toRegex() + val INTEGER_REGEX_PATTERN = + """^[+\-]?(0[xXbBoO])?[0-9A-Fa-f]+$""".toRegex() @JvmStatic @JsName("ofBigInteger") diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/ListIterator.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/ListIterator.kt index 5ddb1ca88..2228a4dc2 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/ListIterator.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/ListIterator.kt @@ -37,4 +37,4 @@ sealed class ListIterator(list: List) : Iterator { return item } } -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Real.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Real.kt index 0bd4babca..f3bfca084 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Real.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Real.kt @@ -56,4 +56,3 @@ interface Real : Numeric { fun of(real: String): Real = of(BigDecimal.of(real)) } } - diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/RegexUtils.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/RegexUtils.kt index b2201bf76..21aae6e94 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/RegexUtils.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/RegexUtils.kt @@ -1,9 +1,12 @@ package it.unibo.tuprolog.core internal object RegexUtils { - const val INT = """([0-9]+)""" + const val INT = + """([0-9]+)""" - const val DEC = """(\.[0-9]+)""" + const val DEC = + """(\.[0-9]+)""" - const val EXP = """([eE][+\-]?[0-9]+)""" -} \ No newline at end of file + const val EXP = + """([eE][+\-]?[0-9]+)""" +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Rule.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Rule.kt index 989757a13..e930fb930 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Rule.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Rule.kt @@ -2,7 +2,6 @@ package it.unibo.tuprolog.core import it.unibo.tuprolog.core.impl.RuleImpl import kotlin.js.JsName -import kotlin.jvm.JvmField import kotlin.jvm.JvmStatic interface Rule : Clause { @@ -40,4 +39,4 @@ interface Rule : Clause { return of(Struct.template(functor, arity), Var.anonymous()) } } -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Scope.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Scope.kt index f5572dcf7..a10feaeff 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Scope.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Scope.kt @@ -211,4 +211,4 @@ interface Scope { @JsName("ofVarAndThen") fun of(vararg vars: Var, lambda: Scope.() -> R): R = of(*vars).with(lambda) } -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Set.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Set.kt index e07cc9e0e..7684cbaae 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Set.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Set.kt @@ -60,4 +60,3 @@ interface Set : Collection { fun of(terms: Sequence): Set = of(terms.toList()) } } - diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/SetIterator.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/SetIterator.kt index 3ac9b9bec..28658f388 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/SetIterator.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/SetIterator.kt @@ -31,5 +31,4 @@ class SetIterator(Set: Set) : Iterator { } } } - -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Struct.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Struct.kt index 5ea6edd5b..dcb8cd0b1 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Struct.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Struct.kt @@ -98,7 +98,8 @@ interface Struct : Term { /** The pattern of a well-formed functor for a Struct */ @JvmField - val STRUCT_FUNCTOR_REGEX_PATTERN = """^[a-z][A-Za-z_0-9]*$""".toRegex() + val STRUCT_FUNCTOR_REGEX_PATTERN = + """^[a-z][A-Za-z_0-9]*$""".toRegex() @JvmStatic @JsName("escapeFunctor") @@ -176,7 +177,6 @@ interface Struct : Term { } } - @JvmStatic @JsName("foldSequence") fun fold(operator: String, terms: Sequence, terminal: Term?): Struct = @@ -206,6 +206,5 @@ interface Struct : Term { @JsName("foldNullTerminated") fun fold(operator: String, vararg terms: Term): Struct = fold(operator, listOf(*terms)) - } } diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Substitution.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Substitution.kt index 73d277b9f..3e09bb15b 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Substitution.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Substitution.kt @@ -2,7 +2,6 @@ package it.unibo.tuprolog.core import kotlin.js.JsName import kotlin.jvm.JvmStatic - import kotlin.collections.Collection as KtCollection /** @@ -93,7 +92,8 @@ sealed class Substitution : Map { filter { (key, value) -> predicate(key, value) } /** Creates a new Successful Substitution (aka Unifier) with given mappings (after some checks) */ - class Unifier(mappings: Map) : Substitution(), + class Unifier(mappings: Map) : + Substitution(), Map by (mappings.trimVariableChains().withoutIdentityMappings()) { // NOTE: no check for contradictions is made upon object construction @@ -163,7 +163,6 @@ sealed class Substitution : Map { override fun toString(): String = "{Failed Substitution}" } - /** Substitution companion with factory functionality */ companion object { @@ -258,7 +257,6 @@ sealed class Substitution : Map { /** Utility function to trim all Map variable chains, i.e. all var keys will be bound to the last possible term */ private fun Map.trimVariableChains(): Map { - /** Utility function to trim a single variable chain against a provided map, returning the last term */ fun Var.trimVariableChain(mappings: Map): Term { val alreadyUsedKeys = mutableSetOf(this) // to prevent infinite loop @@ -272,9 +270,10 @@ sealed class Substitution : Map { return when { size < 2 -> this - else -> this.mapValues { (varKey, term) -> - term.takeIf { it !is Var } ?: varKey.trimVariableChain(this) - } + else -> + this.mapValues { (varKey, term) -> + term.takeIf { it !is Var } ?: varKey.trimVariableChain(this) + } } } diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Term.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Term.kt index 40dc7752f..bcfa2668b 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Term.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Term.kt @@ -43,7 +43,6 @@ interface Term : Comparable { override fun compareTo(other: Term): Int = TermComparator.DefaultComparator.compare(this, other) - /** * Checks whether an[other] term is _equals_ to the current one or not, * by explicitly letting the client decide whether to rely or not on [Var]riables @@ -387,4 +386,4 @@ interface Term : Comparable { override fun equals(other: Any?): Boolean override fun hashCode(): Int -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/TermComparator.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/TermComparator.kt index 6ad46e999..9eed0775e 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/TermComparator.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/TermComparator.kt @@ -86,4 +86,4 @@ interface TermComparator : Comparator { } } } -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/TermFormatter.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/TermFormatter.kt index 922de19c6..0903f0509 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/TermFormatter.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/TermFormatter.kt @@ -94,4 +94,4 @@ interface TermFormatter : Formatter, TermVisitor { return prettyExpressions(true, OperatorSet.DEFAULT) } } -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/TermVisitor.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/TermVisitor.kt index 03b3b30ff..69d2971ca 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/TermVisitor.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/TermVisitor.kt @@ -185,4 +185,4 @@ interface TermVisitor { @JsName("visitDirective") fun visitDirective(term: Directive): T = defaultValue(term) -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Tuple.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Tuple.kt index 69e643334..754bc129f 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Tuple.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Tuple.kt @@ -80,4 +80,4 @@ interface Tuple : Collection { .foldRight(terms.last()) { l, r -> TupleImpl(l, r) } as Tuple } } -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/TupleIterator.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/TupleIterator.kt index a7545a562..340ff0209 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/TupleIterator.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/TupleIterator.kt @@ -19,5 +19,4 @@ class TupleIterator(tuple: Tuple) : Iterator { } } } - -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Var.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Var.kt index 6bfed5d25..6555dd5af 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Var.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/Var.kt @@ -2,7 +2,6 @@ package it.unibo.tuprolog.core import it.unibo.tuprolog.core.impl.VarImpl import kotlin.js.JsName -import kotlin.jvm.JvmField import kotlin.jvm.JvmStatic interface Var : Term { diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/exception/InvalidClauseException.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/exception/InvalidClauseException.kt index e3bb26d2d..bcbd7434b 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/exception/InvalidClauseException.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/exception/InvalidClauseException.kt @@ -3,8 +3,9 @@ package it.unibo.tuprolog.core.exception import it.unibo.tuprolog.core.Term import kotlin.jvm.JvmOverloads -open class InvalidClauseException @JvmOverloads constructor(val term: Term, cause: Throwable? = null) - : TuPrologException(cause) { +open class InvalidClauseException +@JvmOverloads +constructor(val term: Term, cause: Throwable? = null) : TuPrologException(cause) { override val message: String? get() = "Term `$term` is not a valid clause" } diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/exception/TuPrologException.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/exception/TuPrologException.kt index ddf22ed38..77c5fbf8e 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/exception/TuPrologException.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/exception/TuPrologException.kt @@ -9,10 +9,10 @@ import kotlin.jvm.JvmOverloads * @param cause the cause of this exception. */ open class TuPrologException - @JvmOverloads constructor( - override val message: String? = null, - override val cause: Throwable? = null - ) : RuntimeException(message, cause) { +@JvmOverloads constructor( + override val message: String? = null, + override val cause: Throwable? = null +) : RuntimeException(message, cause) { // left this auxiliary constructor to initialize message when only cause is present constructor(cause: Throwable?) : this(cause?.toString(), cause) diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/AbstractTermFormatter.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/AbstractTermFormatter.kt index 6aa560c24..f65daec56 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/AbstractTermFormatter.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/AbstractTermFormatter.kt @@ -1,7 +1,16 @@ package it.unibo.tuprolog.core.impl -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Cons +import it.unibo.tuprolog.core.Directive +import it.unibo.tuprolog.core.EmptyList +import it.unibo.tuprolog.core.Fact +import it.unibo.tuprolog.core.Indicator +import it.unibo.tuprolog.core.Rule import it.unibo.tuprolog.core.Set +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.TermFormatter +import it.unibo.tuprolog.core.Tuple internal abstract class AbstractTermFormatter : TermFormatter { @@ -11,7 +20,7 @@ internal abstract class AbstractTermFormatter : TermFormatter { override fun visitStruct(term: Struct): String = (if (term.isFunctorWellFormed) term.functor else Struct.escapeFunctor(term.functor)) + - term.argsSequence.map { it.accept(childFormatter()) }.joinToString(", ", "(", ")") + term.argsSequence.map { it.accept(childFormatter()) }.joinToString(", ", "(", ")") override fun visitSet(term: Set): String = term.unfoldedList.joinToString(", ", "{", "}") { @@ -50,4 +59,4 @@ internal abstract class AbstractTermFormatter : TermFormatter { override fun visitIndicator(term: Indicator): String = visitStruct(term) -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/ClauseImpl.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/ClauseImpl.kt index 9a5b836b5..1f3f79832 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/ClauseImpl.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/ClauseImpl.kt @@ -19,4 +19,4 @@ internal abstract class ClauseImpl(override val head: Struct?, override val body null -> "$functor $body" else -> "$head $functor $body" } -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/CollectionImpl.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/CollectionImpl.kt index eb4c7e997..07a51db5b 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/CollectionImpl.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/CollectionImpl.kt @@ -3,7 +3,6 @@ package it.unibo.tuprolog.core.impl import it.unibo.tuprolog.core.Collection import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.core.Var -import it.unibo.tuprolog.utils.buffered import it.unibo.tuprolog.utils.dequeOf import it.unibo.tuprolog.utils.itemWiseHashCode @@ -28,4 +27,4 @@ internal abstract class CollectionImpl(functor: String, args: Array) : Str override val variables: Sequence by lazy { unfoldedSequence.flatMap { it.variables } } -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/ConsImpl.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/ConsImpl.kt index 24ddc559e..27aa7da79 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/ConsImpl.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/ConsImpl.kt @@ -1,9 +1,9 @@ package it.unibo.tuprolog.core.impl -import it.unibo.tuprolog.core.* -import it.unibo.tuprolog.utils.dequeOf +import it.unibo.tuprolog.core.Cons +import it.unibo.tuprolog.core.EmptyList +import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.core.ListIterator as LogicListIterator -import it.unibo.tuprolog.core.List as LogicList internal class ConsImpl(override val head: Term, override val tail: Term) : CollectionImpl(Cons.FUNCTOR, arrayOf(head, tail)), Cons { @@ -44,7 +44,7 @@ internal class ConsImpl(override val head: Term, override val tail: Term) : val (ending, take) = if (isWellFormed) { "]" to size } else { - " | ${last}]" to size - 1 + " | $last]" to size - 1 } return unfoldedSequence.take(take).joinToString(", ", "[", ending) } diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/DirectiveImpl.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/DirectiveImpl.kt index b90a63cf6..462e9f544 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/DirectiveImpl.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/DirectiveImpl.kt @@ -7,4 +7,4 @@ import it.unibo.tuprolog.core.Term internal class DirectiveImpl(override val body: Term) : ClauseImpl(null, body), Directive { override val head: Struct? = super.head -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/EmptyListImpl.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/EmptyListImpl.kt index b32ec6fea..9ff6f08cd 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/EmptyListImpl.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/EmptyListImpl.kt @@ -16,4 +16,4 @@ internal object EmptyListImpl : AtomImpl(Empty.EMPTY_LIST_FUNCTOR), EmptyList { override val last: Term get() = this -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/EmptySetImpl.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/EmptySetImpl.kt index 276f698a6..a4d62b729 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/EmptySetImpl.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/EmptySetImpl.kt @@ -17,4 +17,4 @@ internal object EmptySetImpl : SetImpl(null), EmptySet { override val size: Int get() = 0 override val variables: Sequence by lazy { super.variables } -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/FactImpl.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/FactImpl.kt index 1915df3f6..6d816b99f 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/FactImpl.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/FactImpl.kt @@ -10,4 +10,4 @@ internal class FactImpl(override val head: Struct) : RuleImpl(head, Truth.TRUE), override val isWellFormed: Boolean = true override val body: Term = super.body -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/ListUnfolder.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/ListUnfolder.kt index d329fe45f..90504fd53 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/ListUnfolder.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/ListUnfolder.kt @@ -28,5 +28,4 @@ internal class ListUnfolder(list: List) : Iterator { } } } - -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/ScopeImpl.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/ScopeImpl.kt index 2f8459c09..92c34bc14 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/ScopeImpl.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/ScopeImpl.kt @@ -1,6 +1,23 @@ package it.unibo.tuprolog.core.impl -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Clause +import it.unibo.tuprolog.core.Cons +import it.unibo.tuprolog.core.Directive +import it.unibo.tuprolog.core.EmptyList +import it.unibo.tuprolog.core.EmptySet +import it.unibo.tuprolog.core.Fact +import it.unibo.tuprolog.core.Indicator +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Numeric +import it.unibo.tuprolog.core.Real +import it.unibo.tuprolog.core.Rule +import it.unibo.tuprolog.core.Scope +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.Truth +import it.unibo.tuprolog.core.Tuple +import it.unibo.tuprolog.core.Var import org.gciatto.kt.math.BigDecimal import org.gciatto.kt.math.BigInteger import kotlin.jvm.Synchronized @@ -186,4 +203,4 @@ internal class ScopeImpl(private val _variables: MutableMap) : Scop override fun realOf(value: String): Real = Real.of(value) -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/SetImpl.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/SetImpl.kt index 8dc091430..72b00f55a 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/SetImpl.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/SetImpl.kt @@ -2,8 +2,6 @@ package it.unibo.tuprolog.core.impl import it.unibo.tuprolog.core.SetIterator import it.unibo.tuprolog.core.Term -import it.unibo.tuprolog.core.Tuple -import it.unibo.tuprolog.utils.dequeOf import it.unibo.tuprolog.core.Set as LogicSet internal open class SetImpl(private val item: Term?) : @@ -20,4 +18,4 @@ internal open class SetImpl(private val item: Term?) : Iterable { SetUnfolder(this) }.asSequence() override fun toString(): String = unfoldedSequence.joinToString(", ", "{", "}") -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/SetUnfolder.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/SetUnfolder.kt index 0ab59fe3d..e060fb2e1 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/SetUnfolder.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/SetUnfolder.kt @@ -44,5 +44,4 @@ internal class SetUnfolder(set: Set) : Iterator { } } } - -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/SimpleTermFormatter.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/SimpleTermFormatter.kt index d907f2895..c6a8a524d 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/SimpleTermFormatter.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/SimpleTermFormatter.kt @@ -1,3 +1,3 @@ package it.unibo.tuprolog.core.impl -internal object SimpleTermFormatter: AbstractTermFormatter() \ No newline at end of file +internal object SimpleTermFormatter : AbstractTermFormatter() diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/StructImpl.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/StructImpl.kt index c2b19cec1..4d843788e 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/StructImpl.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/StructImpl.kt @@ -19,10 +19,10 @@ internal open class StructImpl(override val functor: String, override val args: override val argsSequence: Sequence by lazy { super.argsSequence } override fun structurallyEquals(other: Term): Boolean = - other is StructImpl - && functor == other.functor - && arity == other.arity - && (0 until arity).all { args[it] structurallyEquals other[it] } + other is StructImpl && + functor == other.functor && + arity == other.arity && + (0 until arity).all { args[it] structurallyEquals other[it] } override val isFunctorWellFormed: Boolean by lazy { functor matches Struct.STRUCT_FUNCTOR_REGEX_PATTERN @@ -63,10 +63,9 @@ internal open class StructImpl(override val functor: String, override val args: override fun toString(): String { return ( - if (isFunctorWellFormed) functor else Struct.escapeFunctor(functor) - ) + ( - if (arity > 0) "(${args.joinToString(", ")})" else "" - ) + if (isFunctorWellFormed) functor else Struct.escapeFunctor(functor) + ) + ( + if (arity > 0) "(${args.joinToString(", ")})" else "" + ) } - -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/TermFormatterWithPrettyExpressions.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/TermFormatterWithPrettyExpressions.kt index 5adcff631..e0cae0d56 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/TermFormatterWithPrettyExpressions.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/TermFormatterWithPrettyExpressions.kt @@ -1,7 +1,18 @@ package it.unibo.tuprolog.core.impl -import it.unibo.tuprolog.core.* -import it.unibo.tuprolog.core.operators.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.EmptyList +import it.unibo.tuprolog.core.EmptySet +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Real +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.TermFormatter +import it.unibo.tuprolog.core.Tuple +import it.unibo.tuprolog.core.Var +import it.unibo.tuprolog.core.operators.OperatorSet +import it.unibo.tuprolog.core.operators.OperatorsIndex +import it.unibo.tuprolog.core.operators.Specifier +import it.unibo.tuprolog.core.operators.toOperatorsIndex import kotlin.collections.Set internal class TermFormatterWithPrettyExpressions( @@ -32,8 +43,8 @@ internal class TermFormatterWithPrettyExpressions( get() = decorations.suffix } - constructor(delegate: TermFormatter, operators: OperatorSet) - : this(Int.MAX_VALUE, delegate, operators.toOperatorsIndex(), emptySet()) + constructor(delegate: TermFormatter, operators: OperatorSet) : + this(Int.MAX_VALUE, delegate, operators.toOperatorsIndex(), emptySet()) override fun visitVar(term: Var): String = term.accept(delegate) @@ -176,4 +187,4 @@ internal class TermFormatterWithPrettyExpressions( 2 -> operators.getSpecifierAndIndexWithGreaterPriority(functor, priority) { isInfix } else -> null } -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/TermFormatterWithPrettyVariables.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/TermFormatterWithPrettyVariables.kt index e9798a9f5..b6d1fad7e 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/TermFormatterWithPrettyVariables.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/TermFormatterWithPrettyVariables.kt @@ -1,8 +1,6 @@ package it.unibo.tuprolog.core.impl -import it.unibo.tuprolog.core.* -import it.unibo.tuprolog.core.List -import it.unibo.tuprolog.core.Set +import it.unibo.tuprolog.core.Var internal class TermFormatterWithPrettyVariables : AbstractTermFormatter() { @@ -35,4 +33,4 @@ internal class TermFormatterWithPrettyVariables : AbstractTermFormatter() { return formatVar(term, "") } } -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/TupleImpl.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/TupleImpl.kt index ff5eb8a8e..d099820b4 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/TupleImpl.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/TupleImpl.kt @@ -20,4 +20,4 @@ internal class TupleImpl(override val left: Term, override val right: Term) : override val args: Array get() = super.args override fun toString(): String = unfoldedSequence.joinToString(", ", "(", ")") -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/TupleUnfolder.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/TupleUnfolder.kt index 996f2b3d7..71937caa3 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/TupleUnfolder.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/TupleUnfolder.kt @@ -1,6 +1,7 @@ package it.unibo.tuprolog.core.impl -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.Tuple internal class TupleUnfolder(tuple: Tuple) : Iterator { @@ -21,5 +22,4 @@ internal class TupleUnfolder(tuple: Tuple) : Iterator { } } } - -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/VarImpl.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/VarImpl.kt index 7e6e55b73..1ba307029 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/VarImpl.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/impl/VarImpl.kt @@ -13,7 +13,7 @@ internal class VarImpl(override val name: String, private val identifier: Long = @Synchronized private fun instanceId(name: String): Long { val count = nameToInstanceCount[name]?.let { it + 1 } ?: 0 - nameToInstanceCount[name] = count + nameToInstanceCount[name] = count return count } } diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/operators/Operator.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/operators/Operator.kt index fe838d64b..6d6fd0a88 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/operators/Operator.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/operators/Operator.kt @@ -1,6 +1,13 @@ package it.unibo.tuprolog.core.operators -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Numeric +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.ToTermConvertible +import it.unibo.tuprolog.core.Var +import it.unibo.tuprolog.core.toAtom +import it.unibo.tuprolog.core.toTerm import kotlin.js.JsName import kotlin.jvm.JvmField import kotlin.jvm.JvmStatic @@ -64,20 +71,19 @@ class Operator(val functor: String, val specifier: Specifier, val priority: Int) fun fromTerm(struct: Struct): Operator? = with(struct) { when { functor == FUNCTOR && arity == 3 && - args[0] is Integer && args[1] is Atom && args[2] is Atom -> try { - - Operator( - args[2].`as`().value, - Specifier.fromTerm(args[1]), - args[0].`as`().intValue.toInt() - ) - - } catch (ex: IllegalArgumentException) { - null - } catch (ex: IllegalStateException) { // Enum.valueOf throws IllegalStateException instead of IllegalArgumentException - null + args[0] is Integer && args[1] is Atom && args[2] is Atom -> { + try { + Operator( + args[2].`as`().value, + Specifier.fromTerm(args[1]), + args[0].`as`().intValue.toInt() + ) + } catch (ex: IllegalArgumentException) { + null + } catch (ex: IllegalStateException) { // Enum.valueOf throws IllegalStateException instead of IllegalArgumentException + null + } } - else -> null } } diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/operators/OperatorSet.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/operators/OperatorSet.kt index 40ec6e409..22456bcf5 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/operators/OperatorSet.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/operators/OperatorSet.kt @@ -56,16 +56,11 @@ class OperatorSet(operators: Sequence) : Set by operators.to /** Arithmetic Operator's OperatorSet */ @JvmField val ARITHMETIC = OperatorSet( - sequenceOf("+", "-", "\\") - .map { Operator(it, Specifier.FY, 200) } - + sequenceOf("^") - .map { Operator(it, Specifier.XFY, 200) } - + sequenceOf("**") - .map { Operator(it, Specifier.XFX, 200) } - + sequenceOf("*", "/", "//", "rem", "mod", "<<", ">>") - .map { Operator(it, Specifier.YFX, 400) } - + sequenceOf("+", "-", "\\/", "/\\") - .map { Operator(it, Specifier.YFX, 500) } + sequenceOf("+", "-", "\\").map { Operator(it, Specifier.FY, 200) } + + sequenceOf("^").map { Operator(it, Specifier.XFY, 200) } + + sequenceOf("**").map { Operator(it, Specifier.XFX, 200) } + + sequenceOf("*", "/", "//", "rem", "mod", "<<", ">>").map { Operator(it, Specifier.YFX, 400) } + + sequenceOf("+", "-", "\\/", "/\\").map { Operator(it, Specifier.YFX, 500) } ) /** Arithmetic Comparison Operator's OperatorSet */ @@ -78,50 +73,40 @@ class OperatorSet(operators: Sequence) : Set by operators.to /** Term Comparison Operator's OperatorSet */ @JvmField val TERM_COMPARISON = OperatorSet( - sequenceOf("=", "\\=") - .map { Operator(it, Specifier.XFX, 700) } - + sequenceOf("==", "\\==", "@<", "@=<", "@>", "@>=") - .map { Operator(it, Specifier.XFX, 700) } - + sequenceOf("=..") - .map { Operator(it, Specifier.XFX, 700) } - + sequenceOf("is") - .map { Operator(it, Specifier.XFX, 700) } + sequenceOf("=", "\\=").map { Operator(it, Specifier.XFX, 700) } + + sequenceOf("==", "\\==", "@<", "@=<", "@>", "@>=").map { Operator(it, Specifier.XFX, 700) } + + sequenceOf("=..").map { Operator(it, Specifier.XFX, 700) } + + sequenceOf("is").map { Operator(it, Specifier.XFX, 700) } ) /** Control Flow Operator's OperatorSet */ @JvmField val CONTROL_FLOW = OperatorSet( - sequenceOf(",") - .map { Operator(it, Specifier.XFY, 1000) } - + sequenceOf("->") - .map { Operator(it, Specifier.XFY, 1050) } - + sequenceOf(";") - .map { Operator(it, Specifier.XFY, 1100) } - + sequenceOf("\\+") - .map { Operator(it, Specifier.FY, 900) } + sequenceOf(",").map { Operator(it, Specifier.XFY, 1000) } + + sequenceOf("->").map { Operator(it, Specifier.XFY, 1050) } + + sequenceOf(";").map { Operator(it, Specifier.XFY, 1100) } + + sequenceOf("\\+").map { Operator(it, Specifier.FY, 900) } ) /** Clauses Operator's OperatorSet */ @JvmField val CLAUSES = OperatorSet( - sequenceOf(":-", "?-") - .map { Operator(it, Specifier.FX, 1200) } - + sequenceOf(":-", "-->") - .map { Operator(it, Specifier.XFX, 1200) } + sequenceOf(":-", "?-").map { Operator(it, Specifier.FX, 1200) } + + sequenceOf(":-", "-->").map { Operator(it, Specifier.XFX, 1200) } ) /** Standard OperatorSet */ @JvmField val STANDARD = OperatorSet( - ARITHMETIC.asSequence() - + ARITHMETIC_COMPARISON.asSequence() - + TERM_COMPARISON.asSequence() - + CONTROL_FLOW.asSequence() - + CLAUSES.asSequence() + ARITHMETIC.asSequence() + + ARITHMETIC_COMPARISON.asSequence() + + TERM_COMPARISON.asSequence() + + CONTROL_FLOW.asSequence() + + CLAUSES.asSequence() ) /** Default OperatorSet */ @JvmField val DEFAULT = STANDARD } -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/operators/OperatorsIndex.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/operators/OperatorsIndex.kt index 727fc915a..8367409a8 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/operators/OperatorsIndex.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/operators/OperatorsIndex.kt @@ -20,4 +20,4 @@ fun Iterable.toOperatorsIndex(): OperatorsIndex { } fun Sequence.toOperatorsIndex(): OperatorsIndex = - this.asIterable().toOperatorsIndex() \ No newline at end of file + this.asIterable().toOperatorsIndex() diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/operators/Specifier.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/operators/Specifier.kt index 598ba5c3b..053b66275 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/core/operators/Specifier.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/core/operators/Specifier.kt @@ -101,4 +101,4 @@ enum class Specifier : ToTermConvertible { else -> throw IllegalArgumentException("Argument `$term` must be an atom") } } -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/Cache.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/Cache.kt index 70295cb5b..a8ea48595 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/Cache.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/Cache.kt @@ -56,4 +56,4 @@ interface Cache { */ fun simpleLru(capacity: Int = 5): Cache = SimpleLRUCache(capacity) } -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/Cached.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/Cached.kt index d9f361451..f7ee8538c 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/Cached.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/Cached.kt @@ -31,4 +31,4 @@ interface Cached { Optional.none() } } -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/CursorExtensions.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/CursorExtensions.kt index 5739f9d2c..315176f86 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/CursorExtensions.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/CursorExtensions.kt @@ -7,12 +7,11 @@ import it.unibo.tuprolog.utils.impl.EmptyCursor import it.unibo.tuprolog.utils.impl.LazyCursor import kotlin.jvm.JvmName - operator fun Cursor.plus(other: Cursor): Cursor { if (other.hasNext) { return ConjunctionCursor(this, other) } else if (hasNext) { - return this; + return this } else { return EmptyCursor } @@ -40,4 +39,4 @@ fun Array.cursor(): Cursor { fun Collection.cursor(): Cursor { return this.iterator().toCursor() -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/Indexed.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/Indexed.kt index 02bfc6535..5d045ad3c 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/Indexed.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/Indexed.kt @@ -11,4 +11,3 @@ interface Indexed { fun map(mapper: (T) -> R): Indexed } - diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/IntIndexed.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/IntIndexed.kt index f90835c63..8467b1ffe 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/IntIndexed.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/IntIndexed.kt @@ -16,4 +16,3 @@ interface IntIndexed : Indexed, Comparable> { } } } - diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/IterUtils.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/IterUtils.kt index 445fc13dc..59b124118 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/IterUtils.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/IterUtils.kt @@ -179,7 +179,6 @@ fun itemWiseHashCode(sequence: Sequence): Int { return itemWiseHashCode(sequence.asIterable()) } - fun Iterable.subsequences(): Sequence> { return asSequence().subsequences() } @@ -230,4 +229,4 @@ fun List.permutations(): Sequence> = .map { listOf(head) + it } } } - } \ No newline at end of file + } diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/LongIndexed.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/LongIndexed.kt index 59801cf83..d55a5a601 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/LongIndexed.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/LongIndexed.kt @@ -4,7 +4,6 @@ import it.unibo.tuprolog.utils.impl.LongIndexedImpl interface LongIndexed : Indexed, Comparable> { - override fun compareTo(other: LongIndexed): Int { return (index - other.index).toInt() } @@ -17,4 +16,3 @@ interface LongIndexed : Indexed, Comparable> { } } } - diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/Optional.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/Optional.kt index c1882313e..2a6f23b33 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/Optional.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/Optional.kt @@ -69,4 +69,4 @@ sealed class Optional { abstract fun toSequence(): Sequence abstract override fun toString(): String -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/AbstractCursor.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/AbstractCursor.kt index 92ad74df9..b90bad8d6 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/AbstractCursor.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/AbstractCursor.kt @@ -11,4 +11,3 @@ internal abstract class AbstractCursor : Cursor { } } } - diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/CachedImpl.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/CachedImpl.kt index 99e95c4aa..263cbf580 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/CachedImpl.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/CachedImpl.kt @@ -28,4 +28,4 @@ data class CachedImpl(private val generator: () -> T) : Cached { override fun invalidate() { cached = Optional.none() } -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/ConjunctionCursor.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/ConjunctionCursor.kt index dcf49d824..2bb8ff12f 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/ConjunctionCursor.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/ConjunctionCursor.kt @@ -21,4 +21,4 @@ internal data class ConjunctionCursor(val first: Cursor, val second: C override fun toString(): String { return super.toString() } -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/EmptyCursor.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/EmptyCursor.kt index bff4661c3..850613f57 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/EmptyCursor.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/EmptyCursor.kt @@ -18,4 +18,4 @@ internal object EmptyCursor : AbstractCursor() { override fun toString(): String { return super.toString() } -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/IndexedImpl.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/IndexedImpl.kt index 6ba3f398d..592a140a2 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/IndexedImpl.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/IndexedImpl.kt @@ -9,4 +9,4 @@ internal data class IndexedImpl( override fun map(mapper: (T) -> R): LongIndexed { return IndexedImpl(index, mapper(value)) } -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/IntIndexedImpl.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/IntIndexedImpl.kt index b338f094a..45e596926 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/IntIndexedImpl.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/IntIndexedImpl.kt @@ -9,4 +9,4 @@ internal data class IntIndexedImpl( override fun map(mapper: (T) -> R): IntIndexed { return IntIndexedImpl(index, mapper(value)) } -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/LRUCache.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/LRUCache.kt index dac205a94..36cd1eac9 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/LRUCache.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/LRUCache.kt @@ -93,14 +93,4 @@ internal class LRUCache(override val capacity: Int) : Cache { override fun toString(): String { return "LRUCache(${toSequence().map { "${it.first} = ${it.second}" }.joinToString(", ")})" } - - // private fun getKeyToEvict(): K? = -// insertionOrder[(nextFreeIndex + size) % capacity].value -// -// private fun pop(): K { -// val leastRecentIndex = (nextFreeIndex + capacity + 1) % capacity -// val result = insertionOrder[leastRecentIndex] -// insertionOrder[leastRecentIndex] = Optional.empty() -// cache.remove(result) -// } -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/LazyCursor.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/LazyCursor.kt index 90058c578..66031ef57 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/LazyCursor.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/LazyCursor.kt @@ -25,4 +25,4 @@ internal data class LazyCursor(val iterator: Iterator) : AbstractCursor override fun toString(): String { return super.toString() } -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/LongIndexedImpl.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/LongIndexedImpl.kt index 58e22f439..0c4d6c388 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/LongIndexedImpl.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/LongIndexedImpl.kt @@ -13,4 +13,4 @@ internal data class LongIndexedImpl( override fun map(mapper: (T) -> R): LongIndexed { return LongIndexedImpl(index, mapper(value)) } -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/MapperCursor.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/MapperCursor.kt index 895269d30..bacf08cf5 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/MapperCursor.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/MapperCursor.kt @@ -23,4 +23,4 @@ internal data class MapperCursor(val wrapped: Cursor, val mapper: ( override fun toString(): String { return super.toString() } -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/NonLastCursor.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/NonLastCursor.kt index 0189798c2..4d9665d78 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/NonLastCursor.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/NonLastCursor.kt @@ -20,4 +20,4 @@ internal data class NonLastCursor(val iterator: Iterator) : AbstractCursor override fun toString(): String { return super.toString() } -} \ No newline at end of file +} diff --git a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/SimpleLRUCache.kt b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/SimpleLRUCache.kt index c284beaf9..7d71fdad2 100644 --- a/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/SimpleLRUCache.kt +++ b/core/src/commonMain/kotlin/it/unibo/tuprolog/utils/impl/SimpleLRUCache.kt @@ -79,4 +79,4 @@ internal class SimpleLRUCache(override val capacity: Int) : Cache { override val size: Int @Synchronized get() = cache.size -} \ No newline at end of file +} diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/ClauseTest.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/ClauseTest.kt index 851931387..efa49767b 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/ClauseTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/ClauseTest.kt @@ -18,15 +18,15 @@ internal class ClauseTest { private val correctInstances = RuleUtils.mixedRules.map { (head, body) -> Rule.of(head, body) } + - DirectiveUtils.mixedDirectives.map { Directive.of(it) } + DirectiveUtils.mixedDirectives.map { Directive.of(it) } private val wellFormedClauseInstances = RuleUtils.wellFormedRules.map { (head, body) -> Rule.of(head, body) } + - DirectiveUtils.wellFormedDirectives.map { Directive.of(it) } + DirectiveUtils.wellFormedDirectives.map { Directive.of(it) } private val nonWellFormedClauseInstances = RuleUtils.nonWellFormedRules.map { (head, body) -> Rule.of(head, body) } + - DirectiveUtils.nonWellFormedDirectives.map { Directive.of(it) } + DirectiveUtils.nonWellFormedDirectives.map { Directive.of(it) } /** * A function replacing correctly variables with call structure where needed @@ -115,11 +115,13 @@ internal class ClauseTest { val aRuleWithVarInHeadAfterPreparation = Rule.of(Tuple.of(aVar, aVar), Tuple.of(Struct.of("call", aVar), Struct.of("call", aVar))) - val toBeTested = (correctInstances.filter { it.isWellFormed } + listOf( - aFactWithVarInHead, - aRuleWithVarInHead, - aRuleWithVarInHeadAfterPreparation - )).map { it.accept(Clause.defaultPreparationForExecutionVisitor) } + val toBeTested = ( + correctInstances.filter { it.isWellFormed } + listOf( + aFactWithVarInHead, + aRuleWithVarInHead, + aRuleWithVarInHeadAfterPreparation + ) + ).map { it.accept(Clause.defaultPreparationForExecutionVisitor) } val correct = wellFormedClausesCorrectlyPreparedForExecution + listOf( aFactWithVarInHead, @@ -147,5 +149,4 @@ internal class ClauseTest { onCorrespondingItems(correct, toBeTested) { expected, actual -> assertEquals(expected, actual) } } - } diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/ConsTest.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/ConsTest.kt index 8c6678ee0..271971b36 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/ConsTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/ConsTest.kt @@ -30,4 +30,4 @@ internal class ConsTest { assertEqualities(correctInstance, toBeTested) } -} +} diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/ConversionsTest.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/ConversionsTest.kt index 3a9d79caf..75ec0623b 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/ConversionsTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/ConversionsTest.kt @@ -80,8 +80,10 @@ internal class ConversionsTest { @Test fun numberToTerm() { @Suppress("USELESS_CAST") - val numberValues = (with(IntegerUtils) { onlyBytes + onlyInts + onlyShorts + onlyLongs } + - with(RealUtils) { decimalsAsDoubles + decimalsAsFloats }).map { it as Number } + val numberValues = ( + with(IntegerUtils) { onlyBytes + onlyInts + onlyShorts + onlyLongs } + + with(RealUtils) { decimalsAsDoubles + decimalsAsFloats } + ).map { it as Number } val correct = numberValues.map { Numeric.of(it) } val toBeTested = numberValues.map { it.toTerm() } diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/IndicatorTest.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/IndicatorTest.kt index 1931ca85a..ce38a432a 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/IndicatorTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/IndicatorTest.kt @@ -35,5 +35,4 @@ internal class IndicatorTest { onCorrespondingItems(correctInstances.filter { it.isWellFormed }, toBeTested, ::assertEqualities) } - } diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/NumericTest.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/NumericTest.kt index 35a2248dd..0fdc60d2d 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/NumericTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/NumericTest.kt @@ -35,11 +35,11 @@ internal class NumericTest { .map { BigDecimal.of(it) } .map { BigDecimal.of(it.unscaledValue.toLong(), it.scale) to - BigDecimal.of(it.unscaledValue.toLong() * 10, it.scale + 1) + BigDecimal.of(it.unscaledValue.toLong() * 10, it.scale + 1) } + - RealUtils.stringNumbers - .filterNot { "E" in it || "e" in it } - .map { BigDecimal.of(it) to BigDecimal.of(it + "00") } + RealUtils.stringNumbers + .filterNot { "E" in it || "e" in it } + .map { BigDecimal.of(it) to BigDecimal.of(it + "00") } } @Test diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/StructTest.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/StructTest.kt index 5b66d1ac0..d356875b8 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/StructTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/StructTest.kt @@ -169,14 +169,15 @@ internal class StructTest { Struct.fold("f", sequenceOf(Var.anonymous()), Var.anonymous()) } - private val arbitraryFoldedStructElements = listOf(Atom.of("hello"), Atom.of("world"), Atom.of("!")) private val arbitraryFoldedStructCorrectInstance = StructImpl( - "f", arrayOf( + "f", + arrayOf( Atom.of("hello"), StructImpl( - "f", arrayOf( + "f", + arrayOf( Atom.of("world"), Atom.of("!") ) diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/SubstitutionUnifierTest.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/SubstitutionUnifierTest.kt index 9a9da16b7..6781fd464 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/SubstitutionUnifierTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/SubstitutionUnifierTest.kt @@ -21,7 +21,7 @@ internal class SubstitutionUnifierTest { private val substitutions by lazy { SubstitutionUtils.mixedSubstitutions.map(Substitution::Unifier) + - listOf(aVarToXAtomSubstitution, bVarToXAtomSubstitution) + listOf(aVarToXAtomSubstitution, bVarToXAtomSubstitution) } @Test diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/TermComparisonTest.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/TermComparisonTest.kt index 0d9abd132..18594761b 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/TermComparisonTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/TermComparisonTest.kt @@ -60,4 +60,4 @@ class TermComparisonTest { val reordered = unordered.sortedWith(TermComparator.DefaultComparator) assertEquals(ordered, reordered) } -} \ No newline at end of file +} diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/TermFormatterWithPrettyExpressionsTest.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/TermFormatterWithPrettyExpressionsTest.kt index 291e6b0fd..57600b945 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/TermFormatterWithPrettyExpressionsTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/TermFormatterWithPrettyExpressionsTest.kt @@ -2,7 +2,6 @@ package it.unibo.tuprolog.core import it.unibo.tuprolog.core.testutils.TermFormatterUtils import it.unibo.tuprolog.core.testutils.TermFormatterUtils.assertProperlyFormats -import kotlin.test.Ignore import kotlin.test.Test class TermFormatterWithPrettyExpressionsTest { @@ -12,4 +11,4 @@ class TermFormatterWithPrettyExpressionsTest { TermFormatter.prettyExpressions().assertProperlyFormats(it) } } -} \ No newline at end of file +} diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/TermFormatterWithPrettyVariablesTest.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/TermFormatterWithPrettyVariablesTest.kt index 7d5f7c6b2..18c29bb89 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/TermFormatterWithPrettyVariablesTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/TermFormatterWithPrettyVariablesTest.kt @@ -11,4 +11,4 @@ class TermFormatterWithPrettyVariablesTest { TermFormatter.prettyVariables().assertProperlyFormats(it) } } -} \ No newline at end of file +} diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/TruthTest.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/TruthTest.kt index 6191d0324..52b31f731 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/TruthTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/TruthTest.kt @@ -40,5 +40,4 @@ internal class TruthTest { fun failTruthRetrieval() { assertEquals(FAIL, Truth.FAIL) } - } diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/DirectiveImplTest.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/DirectiveImplTest.kt index a414666d2..8a2ce9fcf 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/DirectiveImplTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/DirectiveImplTest.kt @@ -9,7 +9,6 @@ import it.unibo.tuprolog.core.testutils.StructUtils import it.unibo.tuprolog.core.testutils.TermTypeAssertionUtils import kotlin.test.* - /** * Test class for [DirectiveImpl] and [Directive] * diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/FactImplTest.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/FactImplTest.kt index 89821caa7..4dc094f0e 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/FactImplTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/FactImplTest.kt @@ -10,7 +10,6 @@ import it.unibo.tuprolog.core.testutils.StructUtils import it.unibo.tuprolog.core.testutils.TermTypeAssertionUtils import kotlin.test.* - /** * Test class for [FactImpl] and [Fact] * diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/IndicatorImplTest.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/IndicatorImplTest.kt index 8ce3d023b..71bd9257b 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/IndicatorImplTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/IndicatorImplTest.kt @@ -137,5 +137,4 @@ internal class IndicatorImplTest { fun freshCopyMergesDifferentVariablesWithSameName() { StructUtils.assertFreshCopyMergesDifferentVariablesWithSameName(::IndicatorImpl) } - } diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/ScopeImplTest.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/ScopeImplTest.kt index 8ec4e67dc..5c706e38e 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/ScopeImplTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/ScopeImplTest.kt @@ -29,9 +29,9 @@ internal class ScopeImplTest { mixedScopeInstances = ScopeUtils.mixedScopes.map(::ScopeImpl) } - //////////////////// + // ////////////////// // Scope specific // - //////////////////// + // ////////////////// @Test fun containsVarWorksAsExpected() { @@ -65,7 +65,6 @@ internal class ScopeImplTest { emptyScopeInstance.varOf("Test") assertEquals(1, emptyScopeInstance.variables.count()) - val scopeVarInitialCounts = ScopeUtils.nonEmptyScopeVarNames.map { it.count() } val newVarNames = ScopeUtils.nonEmptyScopeVarNames.map { scopeVarNames -> scopeVarNames.map { it + "x" } } onCorrespondingItems(newVarNames, nonEmptyScopeInstances) { toBeAddedVars, nonEmptyScope -> @@ -137,9 +136,9 @@ internal class ScopeImplTest { assertNotEquals(mixedScopeInstances, toTestMixedScopes) } - /////////////////////// + // ///////////////////// // General Factories // - /////////////////////// + // ///////////////////// @Test fun setOfIterable() { @@ -381,5 +380,4 @@ internal class ScopeImplTest { onCorrespondingItems(correctInstances, toBeTested, ::assertEqualities) } - -} \ No newline at end of file +} diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/StructImplTest.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/StructImplTest.kt index 99863f2ad..0937545ba 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/StructImplTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/StructImplTest.kt @@ -31,7 +31,8 @@ internal class StructImplTest { fun functorCorrect() { onCorrespondingItems( StructUtils.mixedStructFunctors, - mixedStructInstances.map { it.functor }) { expected, actual -> + mixedStructInstances.map { it.functor } + ) { expected, actual -> assertEquals(expected, actual) } } @@ -103,7 +104,7 @@ internal class StructImplTest { fun toStringWorksAsExpected() { val correctToStrings = mixedStructInstances.map { (if (it.isFunctorWellFormed) it.functor else "'${it.functor}'") + - (if (it.arity > 0) "(${it.args.joinToString(", ")})" else "") + (if (it.arity > 0) "(${it.args.joinToString(", ")})" else "") } onCorrespondingItems(correctToStrings, mixedStructInstances.map { it.toString() }) { expected, actual -> assertEquals(expected, actual) @@ -188,7 +189,7 @@ internal class StructImplTest { val isList: (Struct) -> Boolean = { aStruct -> aStruct.functor == Cons.FUNCTOR && aStruct.arity == 2 || - aStruct.functor == Empty.EMPTY_LIST_FUNCTOR && aStruct.arity == 0 + aStruct.functor == Empty.EMPTY_LIST_FUNCTOR && aStruct.arity == 0 } mixedStructInstances.filter(isList).forEach { assertTrue { it.isList } } @@ -200,7 +201,7 @@ internal class StructImplTest { val isSet: (Struct) -> Boolean = { aStruct -> aStruct.functor == LogicSet.FUNCTOR && aStruct.arity == 1 || - aStruct.functor == Empty.EMPTY_SET_FUNCTOR && aStruct.arity == 0 + aStruct.functor == Empty.EMPTY_SET_FUNCTOR && aStruct.arity == 0 } mixedStructInstances.filter(isSet).forEach { assertTrue { it.isSet } } diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/integrationtests/TestFail.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/integrationtests/TestFail.kt index ff504760d..514e9b5b6 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/integrationtests/TestFail.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/integrationtests/TestFail.kt @@ -36,4 +36,4 @@ class TestFail { val notFailAtom = Atom.of(notCorrectAtom) heterogeneousCreatedInstances.forEach { correct -> assertNoEqualities(notFailAtom, correct) } } -} \ No newline at end of file +} diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/integrationtests/TestFalse.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/integrationtests/TestFalse.kt index ad66d1c45..6bf88cb66 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/integrationtests/TestFalse.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/integrationtests/TestFalse.kt @@ -37,4 +37,4 @@ class TestFalse { val notFailAtom = Atom.of(notCorrectAtom) heterogeneousCreatedInstances.forEach { correct -> assertNoEqualities(notFailAtom, correct) } } -} \ No newline at end of file +} diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/integrationtests/TestTrue.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/integrationtests/TestTrue.kt index cd3dfc4a8..6cd8e8e15 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/integrationtests/TestTrue.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/integrationtests/TestTrue.kt @@ -37,4 +37,4 @@ class TestTrue { val notTrueAtom = Atom.of(notCorrectAtom) heterogeneousCreatedInstances.forEach { correct -> assertNoEqualities(notTrueAtom, correct) } } -} \ No newline at end of file +} diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/operators/OperatorSetTest.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/operators/OperatorSetTest.kt index 9824c63ef..f07c2319e 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/operators/OperatorSetTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/operators/OperatorSetTest.kt @@ -90,15 +90,18 @@ internal class OperatorSetTest { OperatorSet.DEFAULT.single { it == Operator(expectedFunctor, expectedSpecifier, expectedPriority) } assertEquals( - expectedFunctor, actualOperator.functor, + expectedFunctor, + actualOperator.functor, "$actualOperator functor expected to be: $expectedFunctor" ) assertEquals( - expectedSpecifier, actualOperator.specifier, + expectedSpecifier, + actualOperator.specifier, "$actualOperator specifier expected to be: $expectedSpecifier" ) assertEquals( - expectedPriority, actualOperator.priority, + expectedPriority, + actualOperator.priority, "$actualOperator priority expected to be: $expectedPriority" ) } diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/operators/OperatorTest.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/operators/OperatorTest.kt index 79ea09f71..92dbc2390 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/operators/OperatorTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/operators/OperatorTest.kt @@ -109,8 +109,10 @@ internal class OperatorTest { fun fromTermReturnsNullIfNotCorrectOperator() { /** Utility function to help testing fromTerm method */ fun testFromTerm( - functor: String = Operator.FUNCTOR, priority: Term = plusPriority.toTerm(), - specifier: Term = plusSpecifier.toTerm(), opFunctor: Term = plusFunctor.toTerm() + functor: String = Operator.FUNCTOR, + priority: Term = plusPriority.toTerm(), + specifier: Term = plusSpecifier.toTerm(), + opFunctor: Term = plusFunctor.toTerm() ) = Operator.fromTerm(Struct.of(functor, priority, specifier, opFunctor)) assertEquals(plusOperator, testFromTerm()) @@ -123,4 +125,4 @@ internal class OperatorTest { assertNull(testFromTerm(specifier = "a".toTerm())) assertNull(testFromTerm(opFunctor = Var.anonymous())) } -} \ No newline at end of file +} diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/operators/SpecifierTest.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/operators/SpecifierTest.kt index efacc3fbd..439bac7cf 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/operators/SpecifierTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/operators/SpecifierTest.kt @@ -98,5 +98,4 @@ internal class SpecifierTest { fun fromTermThatIsNotAtom() { assertFailsWith { Specifier.fromTerm(Var.of("XFX")) } } - } diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/AssertionUtils.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/AssertionUtils.kt index 102b72b1a..c27f3fa11 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/AssertionUtils.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/AssertionUtils.kt @@ -54,7 +54,6 @@ internal object AssertionUtils { actual structurallyEquals expected ) - /** Asserts all types of equalities (normal, strict and structural) for two [Term]s */ fun assertEqualities(expected: Term, actual: Term) { assertStructurallyEquals(expected, actual) @@ -84,4 +83,4 @@ internal object AssertionUtils { onCorrespondingItems(repeatedElementsSequence, repeatedSequenceOfElements, assertion) } -} \ No newline at end of file +} diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/AtomUtils.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/AtomUtils.kt index f42dc2f74..2901b06c3 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/AtomUtils.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/AtomUtils.kt @@ -53,5 +53,4 @@ internal object AtomUtils { assertTrue(atom.argsList.isEmpty()) assertTrue(atom.argsSequence.toList().isEmpty()) } - } diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/ConsUtils.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/ConsUtils.kt index cc2752a52..c6d7d6f8d 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/ConsUtils.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/ConsUtils.kt @@ -16,7 +16,6 @@ internal object ConsUtils { /** Constructs a non ground Cons with one Term */ internal fun oneElementList(constructor: (Term, Term) -> Cons) = constructor(headOfFirstList, tailOfFirstList) - private val headOfSecondList = Var.of("H") private val tailOfSecondListElement = Var.of("T") private fun tailOfSecondList(constructor: (Term, Term) -> Cons) = constructor(tailOfSecondListElement, Empty.list()) @@ -25,7 +24,6 @@ internal object ConsUtils { internal fun twoElementList(constructor: (Term, Term) -> Cons) = constructor(headOfSecondList, tailOfSecondList(constructor)) - private val headOfThirdList = Atom.of("bigList") private val tailOfThirdListFirstElement = Integer.of(4) private val tailOfThirdListSecondElement = Real.of(1.5) @@ -37,7 +35,6 @@ internal object ConsUtils { internal fun threeElementList(constructor: (Term, Term) -> Cons) = constructor(headOfThirdList, tailOfThirdList(constructor)) - private val headOfFourthList = Var.of("Head") private val tailOfFourthList = Var.of("Tail") private val elementsOfFourthList = listOf(headOfFourthList, tailOfFourthList) @@ -56,7 +53,6 @@ internal object ConsUtils { internal fun threeElementListWithPipe(constructor: (Term, Term) -> Cons) = constructor(headOfFifthList, tailOfFifthList(constructor)) - /** Returns only those Cons that are terminated with an EmptyList */ internal fun onlyConsEmptyListTerminated(constructor: (Term, Term) -> Cons) = listOf( @@ -72,12 +68,10 @@ internal object ConsUtils { threeElementListWithPipe(constructor) ) - /** Returns all Cons mixing [onlyConsEmptyListTerminated] and [onlyConsPipeTerminated] */ internal fun mixedConsInstances(constructor: (Term, Term) -> Cons) = onlyConsEmptyListTerminated(constructor) + onlyConsPipeTerminated(constructor) - /** All Cons heads */ internal val mixedConsInstancesHeads by lazy { listOf(headOfFirstList, headOfSecondList, headOfThirdList, headOfFourthList, headOfFifthList) @@ -96,7 +90,7 @@ internal object ConsUtils { /** All Cons correct toString representations */ internal val mixedConsInstancesCorrectToString by lazy { onlyConsEmptyListTerminatedElementLists.map { it.joinToString(prefix = "[", postfix = "]") } + - onlyConsPipeTerminatedElementLists.map { it.dropLast().joinToString(prefix = "[") + " | ${it.last()}]" } + onlyConsPipeTerminatedElementLists.map { it.dropLast().joinToString(prefix = "[") + " | ${it.last()}]" } } internal val onlyConsEmptyListTerminatedElementLists by lazy { diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/DirectiveUtils.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/DirectiveUtils.kt index 0641a1ae1..fd33f116f 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/DirectiveUtils.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/DirectiveUtils.kt @@ -52,5 +52,4 @@ internal object DirectiveUtils { val mixedDirectives by lazy { groundWellFormedDirectives + groundNonWellFormedDirectives + nonGroundWellFormedDirectives + nonGroundNonWellFormedDirectives } - } diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/FactUtils.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/FactUtils.kt index 0fe48988e..2c7854777 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/FactUtils.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/FactUtils.kt @@ -28,5 +28,4 @@ internal object FactUtils { /** Contains mixed [groundFacts] and [nonGroundFacts] */ val mixedFacts by lazy { groundFacts + nonGroundFacts } - } diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/IndicatorUtils.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/IndicatorUtils.kt index 3afd3625c..80ca230e6 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/IndicatorUtils.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/IndicatorUtils.kt @@ -54,5 +54,4 @@ internal object IndicatorUtils { /** Contains well-formed and non-well-formed indicators */ internal val mixedIndicators by lazy { wellFormedIndicators + nonWellFormedIndicators } - } diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/RuleUtils.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/RuleUtils.kt index 52d2c5eec..4225115b5 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/RuleUtils.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/RuleUtils.kt @@ -13,7 +13,7 @@ internal object RuleUtils { val groundWellFormedRules by lazy { listOf( Struct.of("parent", Atom.of("bob"), Atom.of("jack")) - to Struct.of("son", Atom.of("jack"), Atom.of("bob")), + to Struct.of("son", Atom.of("jack"), Atom.of("bob")), Struct.of("money", Integer.of(100)) to Atom.of("win"), Atom.of("a") to Struct.of("?", Integer.of(1), Integer.of(2)), Atom.of("b") to Struct.of(",", Real.of(0.5), Real.of(0.6), Real.of(0.7)), diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/ScopeUtils.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/ScopeUtils.kt index cbc82debc..74acb2640 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/ScopeUtils.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/ScopeUtils.kt @@ -25,7 +25,6 @@ internal object ScopeUtils { mutableMapOf("A" to Var.of("A"), "B" to Var.of("B"), "C" to Var.of("C")) ) - /** Contains the variables inside [nonEmptyScopes] */ internal val nonEmptyScopeVars get() = nonEmptyScopes.map { it.values.toList() } diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/SubstitutionUtils.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/SubstitutionUtils.kt index 3145e4d8a..613934b09 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/SubstitutionUtils.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/SubstitutionUtils.kt @@ -41,8 +41,10 @@ internal object SubstitutionUtils { ktListOf( ktListOf(varOf("A") to atomOf("a"), varOf("A") to atomOf("a")), ktListOf( - varOf("A") to atomOf("a"), varOf("A") to atomOf("a"), - varOf("B") to atomOf("b"), varOf("B") to atomOf("b") + varOf("A") to atomOf("a"), + varOf("A") to atomOf("a"), + varOf("B") to atomOf("b"), + varOf("B") to atomOf("b") ) ) } diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/TermFormatterUtils.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/TermFormatterUtils.kt index 24c9ae72c..a6e4163d3 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/TermFormatterUtils.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/TermFormatterUtils.kt @@ -35,7 +35,8 @@ object TermFormatterUtils { Indicator.of(Var.of("A"), Var.of("B")) to "'/'(A, B)", Rule.of( Tuple.of(Var.of("A"), Var.of("B")), - Tuple.of(Var.of("C"), Var.of("D"))) to "':-'(','(A, B), ','(C, D))", + Tuple.of(Var.of("C"), Var.of("D")) + ) to "':-'(','(A, B), ','(C, D))", Fact.of( Tuple.of(Var.of("A"), Var.of("B"), Var.of("A"), Var.of("B")) ) to "':-'(','(A, ','(B, ','(A1, B1))), true)", @@ -61,16 +62,21 @@ object TermFormatterUtils { items = listOf(Tuple.of(Var.of("A"), Var.of("B")), Var.of("A"), Var.of("B")), last = Tuple.of(Var.of("A"), Var.of("B")) ) to "[(A, B), A1, B1 | (A2, B2)]", - Struct.of("+", + Struct.of( + "+", Struct.of("+", Var.of("A"), Var.of("B")), - Struct.of("+", Var.of("C"), Var.of("D"))) to "A + B + C + D", - Struct.of("+", + Struct.of("+", Var.of("C"), Var.of("D")) + ) to "A + B + C + D", + Struct.of( + "+", Struct.of("-", Var.of("A"), Var.of("B")), - Struct.of("-", Var.of("C"), Var.of("D"))) to "A - B + C - D", + Struct.of("-", Var.of("C"), Var.of("D")) + ) to "A - B + C - D", Indicator.of(Var.of("A"), Var.of("B")) to "A / B", Rule.of( Tuple.of(Var.of("A"), Var.of("B")), - Tuple.of(Var.of("C"), Var.of("D"))) to "A, B :- C, D", + Tuple.of(Var.of("C"), Var.of("D")) + ) to "A, B :- C, D", Fact.of( Tuple.of(Var.of("A"), Var.of("B"), Var.of("A"), Var.of("B")) ) to "A, B, A1, B1 :- true", @@ -85,7 +91,11 @@ object TermFormatterUtils { fun TermFormatter.assertProperlyFormats(expected: String, actual: Term) { val formatted = actual.format(this) - assertEquals(expected, formatted, message = """ + assertEquals( + expected, + formatted, + message = + """ |Formatting | $actual |with ${this::class} should result in @@ -94,6 +104,7 @@ object TermFormatterUtils { | $formatted |is produced instead | - """.trimMargin()) + """.trimMargin() + ) } -} \ No newline at end of file +} diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/TermTypeAssertionUtils.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/TermTypeAssertionUtils.kt index b94c2b293..6a1f9546e 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/TermTypeAssertionUtils.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/TermTypeAssertionUtils.kt @@ -261,7 +261,6 @@ internal object TermTypeAssertionUtils { ) } - /** Checks passed term to be an Indicator or fails otherwise */ fun assertIsIndicator(any: Any) { assertTrue(any is Term) diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/TupleUtils.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/TupleUtils.kt index 3fe4302a6..5c018d31f 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/TupleUtils.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/TupleUtils.kt @@ -16,7 +16,6 @@ internal object TupleUtils { internal fun twoElementTuple(constructor: (Term, Term) -> Tuple) = constructor(firstOfFirstTuple, secondOfFirstTuple) - private val firstOfSecondTuple = Atom.of("bigTuple") private val secondOfSecondTuple = Integer.of(4) private val thirdOfSecondTuple = Real.of(1.5) @@ -28,7 +27,6 @@ internal object TupleUtils { internal fun threeElementTuple(constructor: (Term, Term) -> Tuple) = constructor(firstOfSecondTuple, rightOfSecondTuple(constructor)) - /** Returns all constructed Tuples (of 2, 3 elements respectively) */ internal fun tupleInstances(constructor: (Term, Term) -> Tuple) = listOf( diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/utils/CacheTest.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/utils/CacheTest.kt index 80b84d4db..593024355 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/utils/CacheTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/utils/CacheTest.kt @@ -54,4 +54,4 @@ interface CacheTest { } } } -} \ No newline at end of file +} diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/utils/CursorTest.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/utils/CursorTest.kt index 2a74c91f7..c1a973933 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/utils/CursorTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/utils/CursorTest.kt @@ -1,4 +1,3 @@ package it.unibo.tuprolog.utils -class CursorTest { -} \ No newline at end of file +class CursorTest diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/utils/LRUCacheTest.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/utils/LRUCacheTest.kt index 21e1e201e..98cd050b5 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/utils/LRUCacheTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/utils/LRUCacheTest.kt @@ -9,4 +9,4 @@ class LRUCacheTest : CacheTest by CacheTest.prototype(::LRUCache) { override fun testKeysCaching() { super.testKeysCaching() } -} \ No newline at end of file +} diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/utils/SimpleLRUCacheTest.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/utils/SimpleLRUCacheTest.kt index 415243ef0..e827ad490 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/utils/SimpleLRUCacheTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/utils/SimpleLRUCacheTest.kt @@ -9,4 +9,4 @@ class SimpleLRUCacheTest : CacheTest by CacheTest.prototype(::SimpleLRUCache) { override fun testKeysCaching() { super.testKeysCaching() } -} \ No newline at end of file +} diff --git a/core/src/jvmMain/kotlin/it/unibo/tuprolog/utils/Deque.kt b/core/src/jvmMain/kotlin/it/unibo/tuprolog/utils/Deque.kt index 3b5ab847e..e41ceb57c 100644 --- a/core/src/jvmMain/kotlin/it/unibo/tuprolog/utils/Deque.kt +++ b/core/src/jvmMain/kotlin/it/unibo/tuprolog/utils/Deque.kt @@ -1,6 +1,6 @@ package it.unibo.tuprolog.utils -import java.util.* +import java.util.LinkedList actual fun dequeOf(vararg items: T): MutableList { return dequeOf(items.asIterable()) diff --git a/core/src/jvmTest/kotlin/LRUCacheTest.kt b/core/src/jvmTest/kotlin/LRUCacheTest.kt index a1a79afc8..67603fd51 100644 --- a/core/src/jvmTest/kotlin/LRUCacheTest.kt +++ b/core/src/jvmTest/kotlin/LRUCacheTest.kt @@ -32,4 +32,4 @@ class LRUCacheTest { println(cache) println(cache.toMap()) } -} \ No newline at end of file +} diff --git a/core/src/jvmTest/kotlin/ListExample.kt b/core/src/jvmTest/kotlin/ListExample.kt index 15b7ccbdf..aafffd250 100644 --- a/core/src/jvmTest/kotlin/ListExample.kt +++ b/core/src/jvmTest/kotlin/ListExample.kt @@ -3,8 +3,6 @@ import it.unibo.tuprolog.core.List import it.unibo.tuprolog.core.Var fun main() { - - val l3 = List.from(sequenceOf(Atom.of("1"), Atom.of("2")), Var.of("Tail")) println(l3) println(l3.freshCopy()) @@ -21,7 +19,6 @@ fun main() { println(e.message) } - val ll3 = List.from(sequenceOf(Atom.of("1"), Atom.of("2"), Var.of("Tail"))) println(ll3) println(ll3.freshCopy()) @@ -36,5 +33,4 @@ fun main() { println(ll1) println(ll2.freshCopy()) println(ll2.freshCopy() == ll2) - -} \ No newline at end of file +} diff --git a/core/src/jvmTest/kotlin/ScopeExample.kt b/core/src/jvmTest/kotlin/ScopeExample.kt index 17a04e456..08d0e4612 100644 --- a/core/src/jvmTest/kotlin/ScopeExample.kt +++ b/core/src/jvmTest/kotlin/ScopeExample.kt @@ -48,4 +48,4 @@ fun main() { println(x.head[3] === y.head[3]) println(x.head[3] == y.head[3]) -} \ No newline at end of file +} diff --git a/core/src/jvmTest/kotlin/SetExample.kt b/core/src/jvmTest/kotlin/SetExample.kt index 2fa8184c2..f8f73e168 100644 --- a/core/src/jvmTest/kotlin/SetExample.kt +++ b/core/src/jvmTest/kotlin/SetExample.kt @@ -1,9 +1,10 @@ -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Numeric import it.unibo.tuprolog.core.Set +import it.unibo.tuprolog.core.Tuple +import it.unibo.tuprolog.core.Var fun main() { - - val s = Set.of(Atom.of("first"), Numeric.of(2), Var.of("Third")) println(s) @@ -22,5 +23,4 @@ fun main() { println(s.unfoldedArray.contentEquals(s.toArray())) println(s.unfoldedSequence) println(s.unfoldedSequence == s.toSequence()) - -} \ No newline at end of file +} diff --git a/core/src/jvmTest/kotlin/TupleExample.kt b/core/src/jvmTest/kotlin/TupleExample.kt index 653ad37a3..7b2958ae7 100644 --- a/core/src/jvmTest/kotlin/TupleExample.kt +++ b/core/src/jvmTest/kotlin/TupleExample.kt @@ -4,8 +4,6 @@ import it.unibo.tuprolog.core.Tuple import it.unibo.tuprolog.core.Var fun main() { - - val tuple = Tuple.of(Atom.of("first"), Numeric.of(2), Var.of("Third")) println(tuple) @@ -25,5 +23,4 @@ fun main() { println(Tuple.wrapIfNeeded(Atom.of("first"), Numeric.of(2))) println(Tuple.wrapIfNeeded(Atom.of("first"))) println(Tuple.wrapIfNeeded()) - -} \ No newline at end of file +} diff --git a/core/src/jvmTest/kotlin/VisitorExample.kt b/core/src/jvmTest/kotlin/VisitorExample.kt index ee4fbdfd8..fcdbb9724 100644 --- a/core/src/jvmTest/kotlin/VisitorExample.kt +++ b/core/src/jvmTest/kotlin/VisitorExample.kt @@ -1,4 +1,9 @@ -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Constant +import it.unibo.tuprolog.core.Scope +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.TermVisitor +import it.unibo.tuprolog.core.Var fun main() { val term: Term = Scope.empty { @@ -10,20 +15,24 @@ fun main() { println(term.toString()) - println(term.accept(object : TermVisitor { + println( + term.accept( + object : TermVisitor { - override fun defaultValue(term: Term): String = "__ERROR__" + override fun defaultValue(term: Term): String = "__ERROR__" - override fun visit(term: Var): String { - return term.name - } + override fun visit(term: Var): String { + return term.name + } - override fun visit(term: Constant): String { - return term.value.toString() - } + override fun visit(term: Constant): String { + return term.value.toString() + } - override fun visit(term: Struct): String { - return "'${term.functor}'(${term.argsSequence.map { it.accept(this) }.joinToString(", ")})" - } - })) -} \ No newline at end of file + override fun visit(term: Struct): String { + return "'${term.functor}'(${term.argsSequence.map { it.accept(this) }.joinToString(", ")})" + } + } + ) + ) +}