From d6ee26691000c5f1c194af265f24aef1a6b476ee Mon Sep 17 00:00:00 2001 From: Giovanni Ciatto Date: Fri, 11 Sep 2020 15:15:09 +0200 Subject: [PATCH 01/34] add link to documentation in readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index fda6fe70d..ee10e4ca3 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ Some quick links: * [GitHub Repository](https://github.com/tuProlog/2p-kt) (where JVM releases are hosted) * [NPM Repository](https://www.npmjs.com/org/tuprolog) (where JS releases are hosted) * [Maven Repository](https://bintray.com/pika-lab/tuprolog) (where all releases are hosted) +* [Documentation](http://pika-lab.gitlab.io/tuprolog/2p-in-kotlin/) ## Intro From 99d608c2db1250b2e02142ed8c1fab4b13db4376 Mon Sep 17 00:00:00 2001 From: Giovanni Ciatto Date: Fri, 11 Sep 2020 21:15:23 +0200 Subject: [PATCH 02/34] fix presentation of variables in :repl --- .../it/unibo/tuprolog/ui/repl/TuPrologCmd.kt | 25 ++++++++++++------- .../unibo/tuprolog/ui/repl/TuPrologUtils.kt | 15 +++++------ 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/repl/src/commonMain/kotlin/it/unibo/tuprolog/ui/repl/TuPrologCmd.kt b/repl/src/commonMain/kotlin/it/unibo/tuprolog/ui/repl/TuPrologCmd.kt index d452c584e..ffa2cb990 100644 --- a/repl/src/commonMain/kotlin/it/unibo/tuprolog/ui/repl/TuPrologCmd.kt +++ b/repl/src/commonMain/kotlin/it/unibo/tuprolog/ui/repl/TuPrologCmd.kt @@ -12,6 +12,7 @@ import it.unibo.tuprolog.core.parsing.ParseException import it.unibo.tuprolog.core.parsing.parse import it.unibo.tuprolog.solve.Solver import it.unibo.tuprolog.solve.TimeDuration +import it.unibo.tuprolog.solve.channel.OutputChannel import it.unibo.tuprolog.solve.classicWithDefaultBuiltins import it.unibo.tuprolog.theory.Theory @@ -43,7 +44,6 @@ class TuPrologCmd : CliktCommand( if (subcommand == null) { readEvalPrintLoop(solve) } - // nota: se subcommand รจ diverso da null, il controllo fluisce automaticamente al metodo run di subcommand } private fun loadTheory(): Theory { @@ -55,13 +55,15 @@ class TuPrologCmd : CliktCommand( TermUi.echo("# Successfully loaded ${t.size} clauses from $file") theory += t } catch (e: ParseException) { - TermUi.echo(""" - |Error while parsing theory file: $file - | Message: ${e.message} - | Line : ${e.line} - | Column : ${e.column} - | Clause : ${e.clauseIndex} - """.trimMargin(), err = true) + TermUi.echo( + """ + |# Error while parsing theory file: $file + |# Message: ${e.message} + |# Line : ${e.line} + |# Column : ${e.column} + |# Clause : ${e.clauseIndex} + """.trimMargin(), err = true + ) } } } @@ -91,7 +93,12 @@ class TuPrologCmd : CliktCommand( fun getSolver(): Solver { TermUi.echo("# 2P-Kt version ${Info.VERSION}") val theory: Theory = this.loadTheory() - return Solver.classicWithDefaultBuiltins(staticKb = theory) + return Solver.classicWithDefaultBuiltins( + staticKb = theory, + warnings = OutputChannel.of { + TermUi.echo("# ${it.message}", err = true) + } + ) } } diff --git a/repl/src/commonMain/kotlin/it/unibo/tuprolog/ui/repl/TuPrologUtils.kt b/repl/src/commonMain/kotlin/it/unibo/tuprolog/ui/repl/TuPrologUtils.kt index f8b3bc11a..d7d74d730 100644 --- a/repl/src/commonMain/kotlin/it/unibo/tuprolog/ui/repl/TuPrologUtils.kt +++ b/repl/src/commonMain/kotlin/it/unibo/tuprolog/ui/repl/TuPrologUtils.kt @@ -29,12 +29,12 @@ object TuPrologUtils { } private fun printYesSolution(sol: Solution.Yes, operatorSet: OperatorSet) { - TermUi.echo("yes: ${sol.solvedQuery.format(prettyExpressions(operatorSet))}.") + val formatter = prettyExpressions(operatorSet) + TermUi.echo("yes: ${sol.solvedQuery.format(formatter)}.") if (sol.substitution.isNotEmpty()) { - val sep = "\n " - val substitutions = sol.substitution.entries.joinToString(sep) { - val prettyVariable = it.key.format(TermFormatter.prettyVariables()) - val prettyValue = it.value.format(prettyExpressions(operatorSet)) + val substitutions = sol.substitution.entries.joinToString("\n ") { + val prettyVariable = it.key.format(formatter) + val prettyValue = it.value.format(formatter) "$prettyVariable = $prettyValue" } TermUi.echo(" $substitutions") @@ -57,14 +57,15 @@ object TuPrologUtils { TermUi.echo("halt: ${ex.message?.trim()}") } val sep = "\n at " - val stacktrace = ex.prologStackTrace.joinToString(sep) { it.format(prettyExpressions(operatorSet)) } + val formatter = prettyExpressions(operatorSet) + val stacktrace = ex.prologStackTrace.joinToString(sep) { it.format(formatter) } TermUi.echo(" at $stacktrace") } } } fun printParseException(e: ParseException) { - TermUi.echo(e.message?.capitalize(), err = true) + TermUi.echo("# ${e.message?.capitalize()}", err = true) } private fun printEndOfSolutions() { From cd6a158ded1a86a3927d15dba04e76c082cc42c5 Mon Sep 17 00:00:00 2001 From: Giovanni Ciatto Date: Fri, 11 Sep 2020 22:54:34 +0200 Subject: [PATCH 03/34] + ktlint-gradle plugin --- build.gradle.kts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index c850e8d6f..b6e4de8e0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -22,6 +22,7 @@ plugins { id("org.danilopianini.git-sensitive-semantic-versioning") version Versions.org_danilopianini_git_sensitive_semantic_versioning_gradle_plugin id("de.fayard.buildSrcVersions") version Versions.de_fayard_buildsrcversions_gradle_plugin id("com.github.breadmoirai.github-release") version Versions.com_github_breadmoirai_github_release_gradle_plugin + id("org.jlleitschuh.gradle.ktlint") version "9.4.0" } repositories { @@ -175,6 +176,7 @@ ktSubprojects.forEachProject { } } + configureKtLint() configureDokka("jvm", "js") configureMavenPublications("packDokka") configureUploadToMavenCentral() @@ -192,6 +194,7 @@ jvmSubprojects.forEachProject { apply(plugin = "org.jetbrains.dokka") apply(plugin = "com.jfrog.bintray") + configureKtLint() configureDokka() createMavenPublications("jvm", "java", docArtifact = "packDokka") configureUploadToMavenCentral() @@ -207,6 +210,7 @@ jsSubprojects.forEachProject { apply(plugin = "org.jetbrains.dokka") apply(plugin = "com.jfrog.bintray") + configureKtLint() configureDokka() createMavenPublications("js", "kotlin", docArtifact = "packDokka") configureUploadToMavenCentral() @@ -214,7 +218,7 @@ jsSubprojects.forEachProject { configureSigning() } -configure { +githubRelease { if (githubToken != null) { token(githubToken) owner(githubOwner) @@ -237,6 +241,20 @@ configure { } } +fun Project.configureKtLint() { + apply(plugin = "org.jlleitschuh.gradle.ktlint") + + ktlint { + debug.set(false) + ignoreFailures.set(false) + enableExperimentalRules.set(true) + filter { + exclude("**/generated/**") + include("**/kotlin/**") + } + } +} + fun Project.configureUploadToGithub( jarTaskPositiveFilter: (String) -> Boolean = { "jar" in it }, jarTaskNegativeFilter: (String) -> Boolean = { "dokka" in it || "source" in it } From 9b2569d03262e754291bed69025e23be941daae0 Mon Sep 17 00:00:00 2001 From: Giovanni Ciatto Date: Fri, 11 Sep 2020 23:14:23 +0200 Subject: [PATCH 04/34] format :core code through ktlint --- .../kotlin/it/unibo/tuprolog/core/Atom.kt | 1 - .../kotlin/it/unibo/tuprolog/core/Clause.kt | 1 - .../unibo/tuprolog/core/ClauseExtensions.kt | 4 +- .../it/unibo/tuprolog/core/Collection.kt | 2 +- .../kotlin/it/unibo/tuprolog/core/Cons.kt | 1 - .../kotlin/it/unibo/tuprolog/core/Constant.kt | 2 +- .../it/unibo/tuprolog/core/Conversions.kt | 2 +- .../kotlin/it/unibo/tuprolog/core/Empty.kt | 1 - .../it/unibo/tuprolog/core/Formatter.kt | 1 - .../tuprolog/core/FormatterExtensions.kt | 1 - .../it/unibo/tuprolog/core/Indicator.kt | 6 +- .../kotlin/it/unibo/tuprolog/core/Integer.kt | 3 +- .../it/unibo/tuprolog/core/ListIterator.kt | 2 +- .../kotlin/it/unibo/tuprolog/core/Real.kt | 1 - .../it/unibo/tuprolog/core/RegexUtils.kt | 11 ++-- .../kotlin/it/unibo/tuprolog/core/Rule.kt | 3 +- .../kotlin/it/unibo/tuprolog/core/Scope.kt | 2 +- .../kotlin/it/unibo/tuprolog/core/Set.kt | 1 - .../it/unibo/tuprolog/core/SetIterator.kt | 3 +- .../kotlin/it/unibo/tuprolog/core/Struct.kt | 5 +- .../it/unibo/tuprolog/core/Substitution.kt | 13 ++--- .../kotlin/it/unibo/tuprolog/core/Term.kt | 3 +- .../it/unibo/tuprolog/core/TermComparator.kt | 2 +- .../it/unibo/tuprolog/core/TermFormatter.kt | 2 +- .../it/unibo/tuprolog/core/TermVisitor.kt | 2 +- .../kotlin/it/unibo/tuprolog/core/Tuple.kt | 2 +- .../it/unibo/tuprolog/core/TupleIterator.kt | 3 +- .../kotlin/it/unibo/tuprolog/core/Var.kt | 1 - .../core/exception/InvalidClauseException.kt | 5 +- .../core/exception/TuPrologException.kt | 8 +-- .../core/impl/AbstractTermFormatter.kt | 15 ++++- .../it/unibo/tuprolog/core/impl/ClauseImpl.kt | 2 +- .../tuprolog/core/impl/CollectionImpl.kt | 3 +- .../it/unibo/tuprolog/core/impl/ConsImpl.kt | 8 +-- .../unibo/tuprolog/core/impl/DirectiveImpl.kt | 2 +- .../unibo/tuprolog/core/impl/EmptyListImpl.kt | 2 +- .../unibo/tuprolog/core/impl/EmptySetImpl.kt | 2 +- .../it/unibo/tuprolog/core/impl/FactImpl.kt | 2 +- .../unibo/tuprolog/core/impl/ListUnfolder.kt | 3 +- .../it/unibo/tuprolog/core/impl/ScopeImpl.kt | 21 ++++++- .../it/unibo/tuprolog/core/impl/SetImpl.kt | 4 +- .../unibo/tuprolog/core/impl/SetUnfolder.kt | 3 +- .../tuprolog/core/impl/SimpleTermFormatter.kt | 2 +- .../it/unibo/tuprolog/core/impl/StructImpl.kt | 19 +++---- .../TermFormatterWithPrettyExpressions.kt | 21 +++++-- .../impl/TermFormatterWithPrettyVariables.kt | 6 +- .../it/unibo/tuprolog/core/impl/TupleImpl.kt | 2 +- .../unibo/tuprolog/core/impl/TupleUnfolder.kt | 6 +- .../it/unibo/tuprolog/core/impl/VarImpl.kt | 2 +- .../unibo/tuprolog/core/operators/Operator.kt | 34 ++++++----- .../tuprolog/core/operators/OperatorSet.kt | 57 +++++++------------ .../tuprolog/core/operators/OperatorsIndex.kt | 2 +- .../tuprolog/core/operators/Specifier.kt | 2 +- .../kotlin/it/unibo/tuprolog/utils/Cache.kt | 2 +- .../kotlin/it/unibo/tuprolog/utils/Cached.kt | 2 +- .../unibo/tuprolog/utils/CursorExtensions.kt | 5 +- .../kotlin/it/unibo/tuprolog/utils/Indexed.kt | 1 - .../it/unibo/tuprolog/utils/IntIndexed.kt | 1 - .../it/unibo/tuprolog/utils/IterUtils.kt | 3 +- .../it/unibo/tuprolog/utils/LongIndexed.kt | 2 - .../it/unibo/tuprolog/utils/Optional.kt | 2 +- .../tuprolog/utils/impl/AbstractCursor.kt | 1 - .../unibo/tuprolog/utils/impl/CachedImpl.kt | 2 +- .../tuprolog/utils/impl/ConjunctionCursor.kt | 2 +- .../unibo/tuprolog/utils/impl/EmptyCursor.kt | 2 +- .../unibo/tuprolog/utils/impl/IndexedImpl.kt | 2 +- .../tuprolog/utils/impl/IntIndexedImpl.kt | 2 +- .../it/unibo/tuprolog/utils/impl/LRUCache.kt | 12 +--- .../unibo/tuprolog/utils/impl/LazyCursor.kt | 2 +- .../tuprolog/utils/impl/LongIndexedImpl.kt | 2 +- .../unibo/tuprolog/utils/impl/MapperCursor.kt | 2 +- .../tuprolog/utils/impl/NonLastCursor.kt | 2 +- .../tuprolog/utils/impl/SimpleLRUCache.kt | 2 +- .../it/unibo/tuprolog/core/ClauseTest.kt | 19 ++++--- .../kotlin/it/unibo/tuprolog/core/ConsTest.kt | 2 +- .../it/unibo/tuprolog/core/ConversionsTest.kt | 6 +- .../it/unibo/tuprolog/core/IndicatorTest.kt | 1 - .../it/unibo/tuprolog/core/NumericTest.kt | 8 +-- .../it/unibo/tuprolog/core/StructTest.kt | 7 ++- .../tuprolog/core/SubstitutionUnifierTest.kt | 2 +- .../unibo/tuprolog/core/TermComparisonTest.kt | 2 +- .../TermFormatterWithPrettyExpressionsTest.kt | 3 +- .../TermFormatterWithPrettyVariablesTest.kt | 2 +- .../it/unibo/tuprolog/core/TruthTest.kt | 1 - .../tuprolog/core/impl/DirectiveImplTest.kt | 1 - .../unibo/tuprolog/core/impl/FactImplTest.kt | 1 - .../tuprolog/core/impl/IndicatorImplTest.kt | 1 - .../unibo/tuprolog/core/impl/ScopeImplTest.kt | 12 ++-- .../tuprolog/core/impl/StructImplTest.kt | 9 +-- .../core/integrationtests/TestFail.kt | 2 +- .../core/integrationtests/TestFalse.kt | 2 +- .../core/integrationtests/TestTrue.kt | 2 +- .../core/operators/OperatorSetTest.kt | 9 ++- .../tuprolog/core/operators/OperatorTest.kt | 8 ++- .../tuprolog/core/operators/SpecifierTest.kt | 1 - .../tuprolog/core/testutils/AssertionUtils.kt | 3 +- .../tuprolog/core/testutils/AtomUtils.kt | 1 - .../tuprolog/core/testutils/ConsUtils.kt | 8 +-- .../tuprolog/core/testutils/DirectiveUtils.kt | 1 - .../tuprolog/core/testutils/FactUtils.kt | 1 - .../tuprolog/core/testutils/IndicatorUtils.kt | 1 - .../tuprolog/core/testutils/RuleUtils.kt | 2 +- .../tuprolog/core/testutils/ScopeUtils.kt | 1 - .../core/testutils/SubstitutionUtils.kt | 6 +- .../core/testutils/TermFormatterUtils.kt | 29 +++++++--- .../core/testutils/TermTypeAssertionUtils.kt | 1 - .../tuprolog/core/testutils/TupleUtils.kt | 2 - .../it/unibo/tuprolog/utils/CacheTest.kt | 2 +- .../it/unibo/tuprolog/utils/CursorTest.kt | 3 +- .../it/unibo/tuprolog/utils/LRUCacheTest.kt | 2 +- .../tuprolog/utils/SimpleLRUCacheTest.kt | 2 +- .../kotlin/it/unibo/tuprolog/utils/Deque.kt | 2 +- core/src/jvmTest/kotlin/LRUCacheTest.kt | 2 +- core/src/jvmTest/kotlin/ListExample.kt | 6 +- core/src/jvmTest/kotlin/ScopeExample.kt | 2 +- core/src/jvmTest/kotlin/SetExample.kt | 10 ++-- core/src/jvmTest/kotlin/TupleExample.kt | 5 +- core/src/jvmTest/kotlin/VisitorExample.kt | 37 +++++++----- 118 files changed, 293 insertions(+), 302 deletions(-) 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(", ")})" + } + } + ) + ) +} From 0bca846d3f1cf219faf6e2ac5a24cb870504baaf Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 14 Sep 2020 12:16:21 +0200 Subject: [PATCH 05/34] format commonMain in :core --- core/build.gradle.kts | 8 +++++--- .../tuprolog/core/exception/InvalidClauseException.kt | 6 +++--- .../it/unibo/tuprolog/core/exception/TuPrologException.kt | 3 +-- .../kotlin/it/unibo/tuprolog/serialize/Objectifier.kt | 3 ++- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 97d221261..3cc52844b 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -15,13 +15,15 @@ kotlin { val createInfoKt by tasks.creating { doLast { - infoKtFile.writeText(""" + infoKtFile.writeText( + """ |package $tuPrologPackage | |object Info { | const val VERSION = "${rootProject.version}" |} - """.trimMargin()) + |""".trimMargin() + ) } outputs.file(infoKtFile) } @@ -32,4 +34,4 @@ kotlin { } } } -} \ No newline at end of file +} 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 bcbd7434b..3ccf6c8f3 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,9 +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 77c5fbf8e..9a9717140 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 @@ -8,8 +8,7 @@ import kotlin.jvm.JvmOverloads * @param message the detail message string. * @param cause the cause of this exception. */ -open class TuPrologException -@JvmOverloads constructor( +open class TuPrologException @JvmOverloads constructor( override val message: String? = null, override val cause: Throwable? = null ) : RuntimeException(message, cause) { diff --git a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/Objectifier.kt b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/Objectifier.kt index 1c71e96ef..6c0d73000 100644 --- a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/Objectifier.kt +++ b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/Objectifier.kt @@ -16,4 +16,5 @@ interface Objectifier { @JsName("objectifyManySequence") fun objectifyMany(values: Sequence): Any = objectifyMany(values.asIterable()) -} \ No newline at end of file +} + From 51f65473e7bc9f01405bbab3612dbea1f4ed3a4a Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 14 Sep 2020 12:27:09 +0200 Subject: [PATCH 06/34] format commonTest in :core --- .../it/unibo/tuprolog/core/ClauseTest.kt | 6 ++- .../it/unibo/tuprolog/core/ConversionsTest.kt | 6 ++- .../unibo/tuprolog/core/SubstitutionTest.kt | 6 ++- .../tuprolog/core/SubstitutionUnifierTest.kt | 6 ++- .../kotlin/it/unibo/tuprolog/core/VarTest.kt | 7 +++- .../tuprolog/core/impl/DirectiveImplTest.kt | 6 ++- .../unibo/tuprolog/core/impl/FactImplTest.kt | 6 ++- .../tuprolog/core/impl/IntegerImplTest.kt | 12 +++++- .../unibo/tuprolog/core/impl/RealImplTest.kt | 6 ++- .../unibo/tuprolog/core/impl/ScopeImplTest.kt | 38 +++++++++++++++++-- .../unibo/tuprolog/core/impl/SetImplTest.kt | 6 ++- .../tuprolog/core/impl/StructImplTest.kt | 11 +++++- .../unibo/tuprolog/core/impl/VarImplTest.kt | 7 +++- .../tuprolog/core/operators/OperatorTest.kt | 8 +++- .../tuprolog/core/operators/SpecifierTest.kt | 16 +++++++- .../tuprolog/core/testutils/ConsUtils.kt | 8 +++- .../tuprolog/core/testutils/DirectiveUtils.kt | 7 +++- .../tuprolog/core/testutils/FactUtils.kt | 8 +++- .../tuprolog/core/testutils/IndicatorUtils.kt | 8 +++- .../tuprolog/core/testutils/RuleUtils.kt | 12 +++++- .../unibo/tuprolog/core/testutils/SetUtils.kt | 9 ++++- .../tuprolog/core/testutils/StructUtils.kt | 16 +++++++- .../core/testutils/SubstitutionUtils.kt | 8 +++- .../core/testutils/TermFormatterUtils.kt | 35 +++++++++++------ .../core/testutils/TermTypeAssertionUtils.kt | 20 +++++++++- .../tuprolog/core/testutils/TupleUtils.kt | 7 +++- 26 files changed, 245 insertions(+), 40 deletions(-) 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 efa49767b..6044ca6f0 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/ClauseTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/ClauseTest.kt @@ -5,7 +5,11 @@ import it.unibo.tuprolog.core.testutils.AssertionUtils.onCorrespondingItems import it.unibo.tuprolog.core.testutils.DirectiveUtils import it.unibo.tuprolog.core.testutils.FactUtils import it.unibo.tuprolog.core.testutils.RuleUtils -import kotlin.test.* +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith +import kotlin.test.assertFalse +import kotlin.test.assertTrue /** * Test class for [Clause] companion object 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 75ec0623b..38e4d5e36 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/ConversionsTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/ConversionsTest.kt @@ -1,8 +1,12 @@ package it.unibo.tuprolog.core -import it.unibo.tuprolog.core.testutils.* import it.unibo.tuprolog.core.testutils.AssertionUtils.assertEqualities import it.unibo.tuprolog.core.testutils.AssertionUtils.onCorrespondingItems +import it.unibo.tuprolog.core.testutils.AtomUtils +import it.unibo.tuprolog.core.testutils.ConsUtils +import it.unibo.tuprolog.core.testutils.IntegerUtils +import it.unibo.tuprolog.core.testutils.RealUtils +import it.unibo.tuprolog.core.testutils.VarUtils import it.unibo.tuprolog.core.testutils.VarUtils.assertDifferentVariableExceptForName import kotlin.test.Test diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/SubstitutionTest.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/SubstitutionTest.kt index 8c47f9f27..7bf505700 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/SubstitutionTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/SubstitutionTest.kt @@ -5,7 +5,11 @@ import it.unibo.tuprolog.core.testutils.AssertionUtils.dropFirst import it.unibo.tuprolog.core.testutils.AssertionUtils.onCorrespondingItems import it.unibo.tuprolog.core.testutils.SubstitutionUtils import it.unibo.tuprolog.core.testutils.VarUtils.assertDifferentVariableExceptForName -import kotlin.test.* +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertSame +import kotlin.test.assertTrue import kotlin.collections.listOf as ktListOf /** 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 6781fd464..cf5e3f0c6 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/SubstitutionUnifierTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/SubstitutionUnifierTest.kt @@ -4,7 +4,11 @@ import it.unibo.tuprolog.core.testutils.AssertionUtils.assertEqualities import it.unibo.tuprolog.core.testutils.AssertionUtils.assertStructurallyEquals import it.unibo.tuprolog.core.testutils.AssertionUtils.onCorrespondingItems import it.unibo.tuprolog.core.testutils.SubstitutionUtils -import kotlin.test.* +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertNotEquals +import kotlin.test.assertTrue /** * Test class for [Substitution.Unifier] and [Substitution] diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/VarTest.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/VarTest.kt index bbdea6066..986163535 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/VarTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/VarTest.kt @@ -7,7 +7,12 @@ import it.unibo.tuprolog.core.testutils.AssertionUtils.assertStructurallyEquals import it.unibo.tuprolog.core.testutils.AssertionUtils.onCorrespondingItems import it.unibo.tuprolog.core.testutils.VarUtils import it.unibo.tuprolog.core.testutils.VarUtils.assertDifferentVariableExceptForName -import kotlin.test.* +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertNotEquals +import kotlin.test.assertNotSame +import kotlin.test.assertTrue /** * Test class for [Var] companion object 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 8a2ce9fcf..36c8d2e1c 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 @@ -7,7 +7,11 @@ import it.unibo.tuprolog.core.testutils.ConstantUtils import it.unibo.tuprolog.core.testutils.DirectiveUtils import it.unibo.tuprolog.core.testutils.StructUtils import it.unibo.tuprolog.core.testutils.TermTypeAssertionUtils -import kotlin.test.* +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertNull +import kotlin.test.assertTrue /** * 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 4dc094f0e..7a0503886 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 @@ -8,7 +8,11 @@ import it.unibo.tuprolog.core.testutils.ConstantUtils import it.unibo.tuprolog.core.testutils.FactUtils import it.unibo.tuprolog.core.testutils.StructUtils import it.unibo.tuprolog.core.testutils.TermTypeAssertionUtils -import kotlin.test.* +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertSame +import kotlin.test.assertTrue /** * Test class for [FactImpl] and [Fact] diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/IntegerImplTest.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/IntegerImplTest.kt index 972a2dd67..48c6720d8 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/IntegerImplTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/IntegerImplTest.kt @@ -1,6 +1,10 @@ package it.unibo.tuprolog.core.impl -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Constant +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Numeric +import it.unibo.tuprolog.core.Real import it.unibo.tuprolog.core.testutils.AssertionUtils.assertNotStructurallyEquals import it.unibo.tuprolog.core.testutils.AssertionUtils.assertStructurallyEquals import it.unibo.tuprolog.core.testutils.AssertionUtils.onCorrespondingItems @@ -9,7 +13,11 @@ import it.unibo.tuprolog.core.testutils.IntegerUtils import it.unibo.tuprolog.core.testutils.TermTypeAssertionUtils import org.gciatto.kt.math.BigDecimal import org.gciatto.kt.math.BigInteger -import kotlin.test.* +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertNotEquals +import kotlin.test.assertTrue /** * Test class for [IntegerImpl] and [Integer] diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/RealImplTest.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/RealImplTest.kt index 795d4f4b4..b948a0c84 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/RealImplTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/RealImplTest.kt @@ -10,7 +10,11 @@ import it.unibo.tuprolog.core.testutils.ConstantUtils import it.unibo.tuprolog.core.testutils.RealUtils import it.unibo.tuprolog.core.testutils.TermTypeAssertionUtils import org.gciatto.kt.math.BigDecimal -import kotlin.test.* +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertNotEquals +import kotlin.test.assertTrue /** * Test class for [RealImpl] and [Real] 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 5c706e38e..ccaa46383 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 @@ -1,13 +1,45 @@ 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.testutils.* +import it.unibo.tuprolog.core.Directive +import it.unibo.tuprolog.core.Fact +import it.unibo.tuprolog.core.Indicator +import it.unibo.tuprolog.core.Numeric +import it.unibo.tuprolog.core.Rule +import it.unibo.tuprolog.core.Scope +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Truth +import it.unibo.tuprolog.core.Tuple +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.core.testutils.AssertionUtils.assertEqualities import it.unibo.tuprolog.core.testutils.AssertionUtils.dropLast import it.unibo.tuprolog.core.testutils.AssertionUtils.onCorrespondingItems +import it.unibo.tuprolog.core.testutils.AtomUtils +import it.unibo.tuprolog.core.testutils.ConsUtils +import it.unibo.tuprolog.core.testutils.DirectiveUtils +import it.unibo.tuprolog.core.testutils.FactUtils +import it.unibo.tuprolog.core.testutils.IndicatorUtils +import it.unibo.tuprolog.core.testutils.IntegerUtils +import it.unibo.tuprolog.core.testutils.RealUtils +import it.unibo.tuprolog.core.testutils.RuleUtils +import it.unibo.tuprolog.core.testutils.ScopeUtils import it.unibo.tuprolog.core.testutils.ScopeUtils.assertScopeCorrectContents -import kotlin.test.* +import it.unibo.tuprolog.core.testutils.SetUtils +import it.unibo.tuprolog.core.testutils.StructUtils +import it.unibo.tuprolog.core.testutils.TermTypeAssertionUtils +import it.unibo.tuprolog.core.testutils.TupleUtils +import kotlin.test.BeforeTest +import kotlin.test.Ignore +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith +import kotlin.test.assertFalse +import kotlin.test.assertNotEquals +import kotlin.test.assertNotSame +import kotlin.test.assertSame +import kotlin.test.assertTrue import it.unibo.tuprolog.core.List as LogicList import it.unibo.tuprolog.core.Set as LogicSet diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/SetImplTest.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/SetImplTest.kt index 90aaf32a4..094f97dbb 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/SetImplTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/SetImplTest.kt @@ -10,7 +10,11 @@ import it.unibo.tuprolog.core.testutils.ConstantUtils import it.unibo.tuprolog.core.testutils.SetUtils import it.unibo.tuprolog.core.testutils.StructUtils import it.unibo.tuprolog.core.testutils.TermTypeAssertionUtils -import kotlin.test.* +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertSame +import kotlin.test.assertTrue /** * Test class for [SetImpl] and [Set] 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 0937545ba..ce8b55055 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 @@ -1,6 +1,15 @@ 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.Empty +import it.unibo.tuprolog.core.Indicator +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Substitution +import it.unibo.tuprolog.core.Truth +import it.unibo.tuprolog.core.Tuple +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.core.testutils.AssertionUtils.assertEqualities import it.unibo.tuprolog.core.testutils.AssertionUtils.assertStructurallyEquals import it.unibo.tuprolog.core.testutils.AssertionUtils.onCorrespondingItems diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/VarImplTest.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/VarImplTest.kt index 03c175276..692eb2c12 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/VarImplTest.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/impl/VarImplTest.kt @@ -11,7 +11,12 @@ import it.unibo.tuprolog.core.testutils.TermTypeAssertionUtils import it.unibo.tuprolog.core.testutils.VarUtils import it.unibo.tuprolog.core.testutils.VarUtils.assertDifferentVariableExceptForName import it.unibo.tuprolog.core.testutils.VarUtils.assertSameVariable -import kotlin.test.* +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertNotEquals +import kotlin.test.assertSame +import kotlin.test.assertTrue /** * Test class for [VarImpl] and [Var] 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 92dbc2390..2e2eb6e3c 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 @@ -6,7 +6,13 @@ import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.core.testutils.AssertionUtils.assertEqualities import it.unibo.tuprolog.core.testutils.AssertionUtils.assertStructurallyEquals import it.unibo.tuprolog.core.toTerm -import kotlin.test.* +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertNotEquals +import kotlin.test.assertNull +import kotlin.test.assertTrue +import kotlin.test.fail /** * Test class for [Operator] 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 439bac7cf..377d29546 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 @@ -4,10 +4,22 @@ import it.unibo.tuprolog.core.Atom import it.unibo.tuprolog.core.Struct import it.unibo.tuprolog.core.Truth import it.unibo.tuprolog.core.Var -import it.unibo.tuprolog.core.operators.Specifier.* +import it.unibo.tuprolog.core.operators.Specifier.FX +import it.unibo.tuprolog.core.operators.Specifier.FY +import it.unibo.tuprolog.core.operators.Specifier.XF +import it.unibo.tuprolog.core.operators.Specifier.XFX +import it.unibo.tuprolog.core.operators.Specifier.XFY +import it.unibo.tuprolog.core.operators.Specifier.YF +import it.unibo.tuprolog.core.operators.Specifier.YFX import it.unibo.tuprolog.core.testutils.AssertionUtils.assertEqualities import it.unibo.tuprolog.core.testutils.AssertionUtils.onCorrespondingItems -import kotlin.test.* +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith +import kotlin.test.assertFalse +import kotlin.test.assertNotEquals +import kotlin.test.assertSame +import kotlin.test.assertTrue /** * Test class for [Specifier] 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 c6d7d6f8d..b31b4293c 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 @@ -1,6 +1,12 @@ package it.unibo.tuprolog.core.testutils -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Cons +import it.unibo.tuprolog.core.Empty +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Real +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.core.testutils.AssertionUtils.dropLast /** 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 fd33f116f..692a71d7c 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 @@ -1,6 +1,11 @@ package it.unibo.tuprolog.core.testutils -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Directive +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Tuple +import it.unibo.tuprolog.core.Var /** * Utils singleton for testing [Directive] 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 2c7854777..fbb82e5e8 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 @@ -1,6 +1,12 @@ package it.unibo.tuprolog.core.testutils -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Fact +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Real +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Truth +import it.unibo.tuprolog.core.Var /** * Utils singleton for testing [Fact] 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 80ca230e6..92f602216 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 @@ -1,6 +1,12 @@ package it.unibo.tuprolog.core.testutils -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Indicator +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Real +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Truth +import it.unibo.tuprolog.core.Var /** * Utils singleton for testing [Indicator] 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 4225115b5..3d89bb0d7 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 @@ -1,6 +1,16 @@ package it.unibo.tuprolog.core.testutils -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Clause +import it.unibo.tuprolog.core.Empty +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.Struct +import it.unibo.tuprolog.core.Truth +import it.unibo.tuprolog.core.Tuple +import it.unibo.tuprolog.core.Var /** * Utils singleton for testing [Rule] diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/SetUtils.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/SetUtils.kt index e3325cef6..9742b65b2 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/SetUtils.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/SetUtils.kt @@ -1,6 +1,13 @@ package it.unibo.tuprolog.core.testutils -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Cons +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Real +import it.unibo.tuprolog.core.Set +import it.unibo.tuprolog.core.Truth +import it.unibo.tuprolog.core.Tuple +import it.unibo.tuprolog.core.Var /** * Utils singleton for testing [Set] diff --git a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/StructUtils.kt b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/StructUtils.kt index 8d47d7370..1df25dc17 100644 --- a/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/StructUtils.kt +++ b/core/src/commonTest/kotlin/it/unibo/tuprolog/core/testutils/StructUtils.kt @@ -1,6 +1,20 @@ package it.unibo.tuprolog.core.testutils -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.Empty +import it.unibo.tuprolog.core.EmptyList +import it.unibo.tuprolog.core.EmptySet +import it.unibo.tuprolog.core.Indicator +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Real +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 it.unibo.tuprolog.core.testutils.AssertionUtils.assertStructurallyEquals import kotlin.test.assertNotEquals import kotlin.test.assertNotSame 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 613934b09..f183f7bca 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 @@ -1,6 +1,12 @@ package it.unibo.tuprolog.core.testutils -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Empty +import it.unibo.tuprolog.core.Scope +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Substitution +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.Var import kotlin.collections.listOf as ktListOf /** 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 a6e4163d3..5cf590fa7 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 @@ -1,9 +1,22 @@ package it.unibo.tuprolog.core.testutils -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +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.List +import it.unibo.tuprolog.core.Real +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 import it.unibo.tuprolog.core.Var +import it.unibo.tuprolog.core.format import kotlin.test.assertEquals object TermFormatterUtils { @@ -95,16 +108,16 @@ object TermFormatterUtils { expected, formatted, message = - """ - |Formatting - | $actual - |with ${this::class} should result in - | $expected - |while - | $formatted - |is produced instead - | - """.trimMargin() + """ + |Formatting + | $actual + |with ${this::class} should result in + | $expected + |while + | $formatted + |is produced instead + | + """.trimMargin() ) } } 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 6a1f9546e..b2e59c40d 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 @@ -1,6 +1,24 @@ package it.unibo.tuprolog.core.testutils -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.Constant +import it.unibo.tuprolog.core.Directive +import it.unibo.tuprolog.core.Empty +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.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 it.unibo.tuprolog.core.testutils.AssertionUtils.assertFalse import it.unibo.tuprolog.core.testutils.AssertionUtils.assertTrue import kotlin.test.assertFalse 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 5c018d31f..a8928962d 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 @@ -1,6 +1,11 @@ package it.unibo.tuprolog.core.testutils -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Real +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.Tuple +import it.unibo.tuprolog.core.Var /** * Utils singleton for testing [Tuple] From e8c97fd37f95114f86d00a2caec1c3643cbfe78f Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 14 Sep 2020 12:36:54 +0200 Subject: [PATCH 07/34] format code in :unify --- unify/build.gradle.kts | 20 ---- .../tuprolog/unify/AbstractUnificator.kt | 8 +- .../unibo/tuprolog/unify/CachedUnificator.kt | 2 +- .../it/unibo/tuprolog/unify/Equation.kt | 26 +++-- .../unibo/tuprolog/unify/UnificationUtils.kt | 3 +- .../it/unibo/tuprolog/unify/Unificator.kt | 2 +- .../unify/exception/NoUnifyException.kt | 1 - .../unify/exception/OccurCheckException.kt | 7 +- .../tuprolog/unify/AbstractUnificatorTest.kt | 46 ++++---- .../it/unibo/tuprolog/unify/EquationTest.kt | 56 ++++++---- .../it/unibo/tuprolog/unify/UnificatorTest.kt | 6 +- .../tuprolog/unify/testutils/EquationUtils.kt | 38 ++++--- .../unify/testutils/UnificatorUtils.kt | 101 ++++++++++-------- .../unibo/tuprolog/unify/TestThreadSafety.kt | 15 +-- 14 files changed, 176 insertions(+), 155 deletions(-) diff --git a/unify/build.gradle.kts b/unify/build.gradle.kts index daf8cfd7c..9c10f82d3 100644 --- a/unify/build.gradle.kts +++ b/unify/build.gradle.kts @@ -1,29 +1,9 @@ -// Project specific kotlin multiplatform configuration kotlin { - sourceSets { val commonMain by getting { dependencies { -// api("com.github.gciatto:kt-math-metadata:0.+") api(project(":core")) } } - - // Default source set for JVM-specific sources and dependencies: - jvm { - compilations["main"].defaultSourceSet { - dependencies { -// api(project(":core")) - } - } - } - - js { - compilations["main"].defaultSourceSet { - dependencies { -// api(project(":core")) - } - } - } } } diff --git a/unify/src/commonMain/kotlin/it/unibo/tuprolog/unify/AbstractUnificator.kt b/unify/src/commonMain/kotlin/it/unibo/tuprolog/unify/AbstractUnificator.kt index 740242575..91da53757 100644 --- a/unify/src/commonMain/kotlin/it/unibo/tuprolog/unify/AbstractUnificator.kt +++ b/unify/src/commonMain/kotlin/it/unibo/tuprolog/unify/AbstractUnificator.kt @@ -6,7 +6,10 @@ import it.unibo.tuprolog.core.Substitution.Companion.empty import it.unibo.tuprolog.core.Substitution.Companion.failed import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.core.Var -import it.unibo.tuprolog.unify.Equation.* +import it.unibo.tuprolog.unify.Equation.Assignment +import it.unibo.tuprolog.unify.Equation.Comparison +import it.unibo.tuprolog.unify.Equation.Contradiction +import it.unibo.tuprolog.unify.Equation.Identity import it.unibo.tuprolog.utils.dequeOf import kotlin.jvm.JvmOverloads @@ -41,7 +44,6 @@ abstract class AbstractUnificator @JvmOverloads constructor(override val context equations: MutableList>, exceptIndex: Int ): Boolean { - var changed = false for (i in equations.indices) { @@ -120,4 +122,4 @@ abstract class AbstractUnificator @JvmOverloads constructor(override val context val equations = dequeOf(contextEquations + equationsFor(substitution1, substitution2)) return mgu(equations, occurCheckEnabled) } -} \ No newline at end of file +} diff --git a/unify/src/commonMain/kotlin/it/unibo/tuprolog/unify/CachedUnificator.kt b/unify/src/commonMain/kotlin/it/unibo/tuprolog/unify/CachedUnificator.kt index c9919e763..a47b6e913 100644 --- a/unify/src/commonMain/kotlin/it/unibo/tuprolog/unify/CachedUnificator.kt +++ b/unify/src/commonMain/kotlin/it/unibo/tuprolog/unify/CachedUnificator.kt @@ -46,4 +46,4 @@ class CachedUnificator( } } } -} \ No newline at end of file +} diff --git a/unify/src/commonMain/kotlin/it/unibo/tuprolog/unify/Equation.kt b/unify/src/commonMain/kotlin/it/unibo/tuprolog/unify/Equation.kt index 730e819de..ac6117031 100644 --- a/unify/src/commonMain/kotlin/it/unibo/tuprolog/unify/Equation.kt +++ b/unify/src/commonMain/kotlin/it/unibo/tuprolog/unify/Equation.kt @@ -1,6 +1,14 @@ package it.unibo.tuprolog.unify -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Cons +import it.unibo.tuprolog.core.Constant +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Substitution +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.ToTermConvertible +import it.unibo.tuprolog.core.Tuple +import it.unibo.tuprolog.core.Var import kotlin.js.JsName import kotlin.jvm.JvmOverloads import kotlin.jvm.JvmStatic @@ -18,7 +26,6 @@ sealed class Equation( @JsName("rhs") open val rhs: B ) : ToTermConvertible { - /** An equation of identical [Term]s */ data class Identity(override val lhs: T, override val rhs: T) : Equation(lhs, rhs) @@ -55,7 +62,6 @@ sealed class Equation( ): Equation = of(lhs[substitution], rhs[substitution], equalityChecker) - /** Equation companion object */ companion object { @@ -64,7 +70,8 @@ sealed class Equation( @JvmOverloads @JsName("of") fun of( - lhs: A, rhs: B, + lhs: A, + rhs: B, equalityChecker: (Term, Term) -> Boolean = Term::equals ): Equation = when { @@ -126,7 +133,8 @@ sealed class Equation( allOf(pair.first, pair.second, equalityChecker) private fun allOfLists( - lhs: LogicList, rhs: LogicList, + lhs: LogicList, + rhs: LogicList, equalityChecker: (Term, Term) -> Boolean = Term::equals ): Sequence> { return lhs.unfold().zip(rhs.unfold()).flatMap { (l, r) -> @@ -140,7 +148,8 @@ sealed class Equation( } private fun allOfTuples( - lhs: Tuple, rhs: Tuple, + lhs: Tuple, + rhs: Tuple, equalityChecker: (Term, Term) -> Boolean = Term::equals ): Sequence> { return lhs.unfold().zip(rhs.unfold()).flatMap { (l, r) -> @@ -156,7 +165,8 @@ sealed class Equation( @JvmOverloads @JsName("allOf") fun allOf( - lhs: A, rhs: B, + lhs: A, + rhs: B, equalityChecker: (Term, Term) -> Boolean = Term::equals ): Sequence> = when { @@ -178,5 +188,3 @@ sealed class Equation( } } } - - diff --git a/unify/src/commonMain/kotlin/it/unibo/tuprolog/unify/UnificationUtils.kt b/unify/src/commonMain/kotlin/it/unibo/tuprolog/unify/UnificationUtils.kt index 9f2ec224a..2273cfb39 100644 --- a/unify/src/commonMain/kotlin/it/unibo/tuprolog/unify/UnificationUtils.kt +++ b/unify/src/commonMain/kotlin/it/unibo/tuprolog/unify/UnificationUtils.kt @@ -5,7 +5,6 @@ package it.unibo.tuprolog.unify import it.unibo.tuprolog.core.Substitution import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.core.Var -import kotlin.js.JsName import kotlin.jvm.JvmName /** Transforms an [Equation] of a [Var] with a [Term] to the corresponding [Substitution] */ @@ -22,4 +21,4 @@ fun Substitution.toEquations(): List> = /** Creates an equation with [this] and [that] terms */ @Suppress("unused", "FunctionName") -infix fun Term.eq(that: Term): Equation = Equation.of(this, that) \ No newline at end of file +infix fun Term.eq(that: Term): Equation = Equation.of(this, that) diff --git a/unify/src/commonMain/kotlin/it/unibo/tuprolog/unify/Unificator.kt b/unify/src/commonMain/kotlin/it/unibo/tuprolog/unify/Unificator.kt index 5093f743c..95a19363f 100644 --- a/unify/src/commonMain/kotlin/it/unibo/tuprolog/unify/Unificator.kt +++ b/unify/src/commonMain/kotlin/it/unibo/tuprolog/unify/Unificator.kt @@ -137,4 +137,4 @@ interface Unificator { const val DEFAULT_CACHE_CAPACITY = 32 } -} \ No newline at end of file +} diff --git a/unify/src/commonMain/kotlin/it/unibo/tuprolog/unify/exception/NoUnifyException.kt b/unify/src/commonMain/kotlin/it/unibo/tuprolog/unify/exception/NoUnifyException.kt index 9e42e1d8e..0bb4fbaf1 100644 --- a/unify/src/commonMain/kotlin/it/unibo/tuprolog/unify/exception/NoUnifyException.kt +++ b/unify/src/commonMain/kotlin/it/unibo/tuprolog/unify/exception/NoUnifyException.kt @@ -11,4 +11,3 @@ open class NoUnifyException(private val term1: Term, private val term2: Term, ot override val message: String? get() = "Cannot match term `$term1` with term `$term2`" } - diff --git a/unify/src/commonMain/kotlin/it/unibo/tuprolog/unify/exception/OccurCheckException.kt b/unify/src/commonMain/kotlin/it/unibo/tuprolog/unify/exception/OccurCheckException.kt index 0c2d00b32..ab9cec409 100644 --- a/unify/src/commonMain/kotlin/it/unibo/tuprolog/unify/exception/OccurCheckException.kt +++ b/unify/src/commonMain/kotlin/it/unibo/tuprolog/unify/exception/OccurCheckException.kt @@ -11,10 +11,9 @@ class OccurCheckException( other: Throwable? ) : NoUnifyException(term1, term2, other) { - constructor(term1: Term, term2: Term, innerVar: Var, innerTerm: Term) - : this(term1, term2, innerVar, innerTerm, null) - + constructor(term1: Term, term2: Term, innerVar: Var, innerTerm: Term) : + this(term1, term2, innerVar, innerTerm, null) override val message: String? get() = "${super.message} because variable `$innerVar` occurs in term `$innerTerm`" -} \ No newline at end of file +} diff --git a/unify/src/commonTest/kotlin/it/unibo/tuprolog/unify/AbstractUnificatorTest.kt b/unify/src/commonTest/kotlin/it/unibo/tuprolog/unify/AbstractUnificatorTest.kt index e17619bfc..c13ab1a92 100644 --- a/unify/src/commonTest/kotlin/it/unibo/tuprolog/unify/AbstractUnificatorTest.kt +++ b/unify/src/commonTest/kotlin/it/unibo/tuprolog/unify/AbstractUnificatorTest.kt @@ -1,6 +1,11 @@ package it.unibo.tuprolog.unify -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Substitution +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.unify.testutils.UnificatorUtils import it.unibo.tuprolog.unify.testutils.UnificatorUtils.assertMatchCorrect import it.unibo.tuprolog.unify.testutils.UnificatorUtils.assertMguCorrect @@ -119,7 +124,7 @@ internal class AbstractUnificatorTest { val correctnessMap = mapOf( (xVar eq structWithX) to - Triple(Substitution.of(xVar, structWithX), true, structWithX) + Triple(Substitution.of(xVar, structWithX), true, structWithX) ) assertMguCorrect(correctnessMap) { term1, term2 -> myStrategy.mgu(term1, term2, false) } @@ -129,19 +134,13 @@ internal class AbstractUnificatorTest { @Test fun sequenceOfEquationsSuccessUnification() { - forEquationSequence(::assertMguCorrect, UnificatorUtils.successSequenceOfUnification, myStrategyConstructor) - { context, t1, t2 -> myStrategyConstructor(context).mgu(t1, t2) } + forEquationSequence(::assertMguCorrect, UnificatorUtils.successSequenceOfUnification, myStrategyConstructor) { context, t1, t2 -> myStrategyConstructor(context).mgu(t1, t2) } - forEquationSequence(::assertMguCorrect, UnificatorUtils.successSequenceOfUnification, myStrategyConstructor) - { context, t1, t2 -> myStrategyConstructor(context).mgu(t1, t2) } + forEquationSequence(::assertMguCorrect, UnificatorUtils.successSequenceOfUnification, myStrategyConstructor) { context, t1, t2 -> myStrategyConstructor(context).mgu(t1, t2) } + forEquationSequence(::assertMatchCorrect, UnificatorUtils.successSequenceOfUnification, myStrategyConstructor) { context, t1, t2 -> myStrategyConstructor(context).match(t1, t2) } - forEquationSequence(::assertMatchCorrect, UnificatorUtils.successSequenceOfUnification, myStrategyConstructor) - { context, t1, t2 -> myStrategyConstructor(context).match(t1, t2) } - - forEquationSequence(::assertMatchCorrect, UnificatorUtils.successSequenceOfUnification, myStrategyConstructor) - { context, t1, t2 -> myStrategyConstructor(context).match(t1, t2) } - + forEquationSequence(::assertMatchCorrect, UnificatorUtils.successSequenceOfUnification, myStrategyConstructor) { context, t1, t2 -> myStrategyConstructor(context).match(t1, t2) } forEquationSequence( ::assertUnifiedTermCorrect, @@ -180,19 +179,13 @@ internal class AbstractUnificatorTest { @Test fun sequenceOfEquationsFailedUnification() { - forEquationSequence(::assertMguCorrect, UnificatorUtils.failSequenceOfUnification, myStrategyConstructor) - { context, t1, t2 -> myStrategyConstructor(context).mgu(t1, t2) } - - forEquationSequence(::assertMguCorrect, UnificatorUtils.failSequenceOfUnification, myStrategyConstructor) - { context, t1, t2 -> myStrategyConstructor(context).mgu(t1, t2) } + forEquationSequence(::assertMguCorrect, UnificatorUtils.failSequenceOfUnification, myStrategyConstructor) { context, t1, t2 -> myStrategyConstructor(context).mgu(t1, t2) } + forEquationSequence(::assertMguCorrect, UnificatorUtils.failSequenceOfUnification, myStrategyConstructor) { context, t1, t2 -> myStrategyConstructor(context).mgu(t1, t2) } - forEquationSequence(::assertMatchCorrect, UnificatorUtils.failSequenceOfUnification, myStrategyConstructor) - { context, t1, t2 -> myStrategyConstructor(context).match(t1, t2) } - - forEquationSequence(::assertMatchCorrect, UnificatorUtils.failSequenceOfUnification, myStrategyConstructor) - { context, t1, t2 -> myStrategyConstructor(context).match(t1, t2) } + forEquationSequence(::assertMatchCorrect, UnificatorUtils.failSequenceOfUnification, myStrategyConstructor) { context, t1, t2 -> myStrategyConstructor(context).match(t1, t2) } + forEquationSequence(::assertMatchCorrect, UnificatorUtils.failSequenceOfUnification, myStrategyConstructor) { context, t1, t2 -> myStrategyConstructor(context).match(t1, t2) } forEquationSequence( ::assertUnifiedTermCorrect, @@ -210,10 +203,10 @@ internal class AbstractUnificatorTest { @Test fun unificationWorksForBigLists() { val n = 10_000 - val ints = LogicList.of((0 .. n).map { Integer.of(it) }) - val intsAndVars = LogicList.of((0 .. n).map { if (it % 100 == 0) Var.anonymous() else Integer.of(it) }) - val atoms = LogicList.of((0 .. n).map { Atom.of("a$it") }) - val atomsAndVars = LogicList.of((0 .. n).map { if (it % 100 == 0) Var.anonymous() else Atom.of("a$it") }) + val ints = LogicList.of((0..n).map { Integer.of(it) }) + val intsAndVars = LogicList.of((0..n).map { if (it % 100 == 0) Var.anonymous() else Integer.of(it) }) + val atoms = LogicList.of((0..n).map { Atom.of("a$it") }) + val atomsAndVars = LogicList.of((0..n).map { if (it % 100 == 0) Var.anonymous() else Atom.of("a$it") }) with(myStrategyConstructor(Substitution.empty())) { assertFalse { match(ints, atoms, true) } @@ -227,6 +220,5 @@ internal class AbstractUnificatorTest { assertTrue { match(atoms, atomsAndVars, true) } assertTrue { match(atoms, atomsAndVars, false) } } - } } diff --git a/unify/src/commonTest/kotlin/it/unibo/tuprolog/unify/EquationTest.kt b/unify/src/commonTest/kotlin/it/unibo/tuprolog/unify/EquationTest.kt index c0ab49b7c..2f5578bd0 100644 --- a/unify/src/commonTest/kotlin/it/unibo/tuprolog/unify/EquationTest.kt +++ b/unify/src/commonTest/kotlin/it/unibo/tuprolog/unify/EquationTest.kt @@ -1,6 +1,10 @@ package it.unibo.tuprolog.unify -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Substitution +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.unify.testutils.EquationUtils import it.unibo.tuprolog.unify.testutils.EquationUtils.assertAllIdentities import it.unibo.tuprolog.unify.testutils.EquationUtils.assertAnyAssignment @@ -23,9 +27,9 @@ internal class EquationTest { /** Correct instances of equations, whose type is recognizable without exploring in deep the components */ private val correctShallowEquationsInstances = EquationUtils.shallowIdentityEquations.map { (lhs, rhs) -> Equation.Identity(lhs, rhs) } + - EquationUtils.assignmentEquations.map { (lhs, rhs) -> Equation.Assignment(lhs, rhs) } + - EquationUtils.comparisonEquations.map { (lhs, rhs) -> Equation.Comparison(lhs, rhs) } + - EquationUtils.shallowContradictionEquations.map { (lhs, rhs) -> Equation.Contradiction(lhs, rhs) } + EquationUtils.assignmentEquations.map { (lhs, rhs) -> Equation.Assignment(lhs, rhs) } + + EquationUtils.comparisonEquations.map { (lhs, rhs) -> Equation.Comparison(lhs, rhs) } + + EquationUtils.shallowContradictionEquations.map { (lhs, rhs) -> Equation.Contradiction(lhs, rhs) } @Test fun identityLhsAndRhsCorrect() { @@ -80,10 +84,10 @@ internal class EquationTest { @Test fun equationOfAutomaticallySwapsAssignments() { val correct = EquationUtils.assignmentEquations.map { (lhs, rhs) -> Equation.of(lhs, rhs) } + - EquationUtils.assignmentEquations.map { Equation.of(it) } + EquationUtils.assignmentEquations.map { Equation.of(it) } val toBeTested = EquationUtils.assignmentEquationsShuffled.map { (lhs, rhs) -> Equation.of(lhs, rhs) } + - EquationUtils.assignmentEquationsShuffled.map { Equation.of(it) } + EquationUtils.assignmentEquationsShuffled.map { Equation.of(it) } assertEquals(correct, toBeTested) } @@ -133,11 +137,11 @@ internal class EquationTest { @Test fun equationAllOfAutomaticallySwapsAssignments() { val correct = EquationUtils.assignmentEquations.map { (lhs, rhs) -> Equation.allOf(lhs, rhs).toList() } + - EquationUtils.assignmentEquations.map { Equation.allOf(it).toList() } + EquationUtils.assignmentEquations.map { Equation.allOf(it).toList() } val toBeTested = EquationUtils.assignmentEquationsShuffled.map { (lhs, rhs) -> Equation.allOf(lhs, rhs).toList() } + - EquationUtils.assignmentEquationsShuffled.map { Equation.allOf(it).toList() } + EquationUtils.assignmentEquationsShuffled.map { Equation.allOf(it).toList() } assertEquals(correct, toBeTested) } @@ -166,8 +170,8 @@ internal class EquationTest { @Test fun swapCanInvertAllInvertibleEquations() { val testableItems = EquationUtils.allIdentityEquations + - EquationUtils.allContradictionEquations + - EquationUtils.comparisonEquations + EquationUtils.allContradictionEquations + + EquationUtils.comparisonEquations val correct = testableItems.map { (lhs, rhs) -> rhs to lhs }.map { Equation.of(it) } val toBeTested = testableItems.map { Equation.of(it) }.map(Equation<*, *>::swap) @@ -188,30 +192,38 @@ internal class EquationTest { @Test fun equationOfLhsAndRhsUsesProvidedEqualityCheckerToTestIdentity() { - assertNoIdentities(EquationUtils.mixedAllEquations.map { (lhs, rhs) -> - Equation.of(lhs, rhs, { _, _ -> false }) - }.asSequence()) + assertNoIdentities( + EquationUtils.mixedAllEquations.map { (lhs, rhs) -> + Equation.of(lhs, rhs, { _, _ -> false }) + }.asSequence() + ) } @Test fun equationOfPairUsesProvidedEqualityCheckerToTestIdentity() { - assertNoIdentities(EquationUtils.mixedAllEquations.map { - Equation.of(it) { _, _ -> false } - }.asSequence()) + assertNoIdentities( + EquationUtils.mixedAllEquations.map { + Equation.of(it) { _, _ -> false } + }.asSequence() + ) } @Test fun equationAllOfLhsAndRhsUsesProvidedEqualityCheckerToTestIdentity() { - assertNoIdentities(EquationUtils.mixedAllEquations.flatMap { (lhs, rhs) -> - Equation.allOf(lhs, rhs, { _, _ -> false }).asIterable() - }.asSequence()) + assertNoIdentities( + EquationUtils.mixedAllEquations.flatMap { (lhs, rhs) -> + Equation.allOf(lhs, rhs, { _, _ -> false }).asIterable() + }.asSequence() + ) } @Test fun equationAllOfPairUsesProvidedEqualityCheckerToTestIdentity() { - assertNoIdentities(EquationUtils.mixedAllEquations.flatMap { - Equation.allOf(it) { _, _ -> false }.asIterable() - }.asSequence()) + assertNoIdentities( + EquationUtils.mixedAllEquations.flatMap { + Equation.allOf(it) { _, _ -> false }.asIterable() + }.asSequence() + ) } @Test diff --git a/unify/src/commonTest/kotlin/it/unibo/tuprolog/unify/UnificatorTest.kt b/unify/src/commonTest/kotlin/it/unibo/tuprolog/unify/UnificatorTest.kt index eda14edbf..a8d0b2941 100644 --- a/unify/src/commonTest/kotlin/it/unibo/tuprolog/unify/UnificatorTest.kt +++ b/unify/src/commonTest/kotlin/it/unibo/tuprolog/unify/UnificatorTest.kt @@ -1,6 +1,10 @@ package it.unibo.tuprolog.unify -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Real +import it.unibo.tuprolog.core.Substitution +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.unify.Unificator.Companion.matches import it.unibo.tuprolog.unify.Unificator.Companion.mguWith import it.unibo.tuprolog.unify.Unificator.Companion.unifyWith diff --git a/unify/src/commonTest/kotlin/it/unibo/tuprolog/unify/testutils/EquationUtils.kt b/unify/src/commonTest/kotlin/it/unibo/tuprolog/unify/testutils/EquationUtils.kt index 194985fb3..0decb9acf 100644 --- a/unify/src/commonTest/kotlin/it/unibo/tuprolog/unify/testutils/EquationUtils.kt +++ b/unify/src/commonTest/kotlin/it/unibo/tuprolog/unify/testutils/EquationUtils.kt @@ -1,6 +1,19 @@ package it.unibo.tuprolog.unify.testutils -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Constant +import it.unibo.tuprolog.core.Directive +import it.unibo.tuprolog.core.Empty +import it.unibo.tuprolog.core.Fact +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.Var import it.unibo.tuprolog.unify.Equation import kotlin.test.assertTrue import kotlin.test.fail @@ -38,7 +51,7 @@ internal object EquationUtils { Scope.empty { listOf(atomOf("a"), varOf("V")) to listOf(atomOf("a"), varOf("V")) }, Scope.empty { listFrom(arrayListOf(atomOf("a")), last = varOf("V")) to - listFrom(arrayListOf(atomOf("a")), last = varOf("V")) + listFrom(arrayListOf(atomOf("a")), last = varOf("V")) }, Var.anonymous().let { anonymous -> LogicSet.of(Numeric.of(1.5), anonymous) to LogicSet.of(Numeric.of(1.5), anonymous) @@ -47,11 +60,11 @@ internal object EquationUtils { Scope.empty { factOf(structOf("aa", varOf("A"))) to factOf(structOf("aa", varOf("A"))) }, Scope.empty { directiveOf(atomOf("here"), structOf("f", Truth.TRUE)) to - directiveOf(atomOf("here"), structOf("f", Truth.TRUE)) + directiveOf(atomOf("here"), structOf("f", Truth.TRUE)) }, Scope.empty { ruleOf(Struct.fold("k", varOf("A"), varOf("A")), Truth.FALSE) to - ruleOf(Struct.fold("k", varOf("A"), varOf("A")), Truth.FALSE) + ruleOf(Struct.fold("k", varOf("A"), varOf("A")), Truth.FALSE) }, Scope.empty { indicatorOf(atomOf("ciao"), varOf("A")) to indicatorOf(atomOf("ciao"), varOf("A")) @@ -86,10 +99,12 @@ internal object EquationUtils { /** The same equations present in [assignmentEquations] but equations on even positions are swapped: Term to Var */ internal val assignmentEquationsShuffled by lazy { assignmentEquations.mapIndexed { i, (variable, term) -> - if (i % 2 == 0 || term.isVariable) // if rhs Term is variable, do not shuffle! Because will _not_ be automatically swapped back like others + // if rhs Term is variable, do not shuffle! Because will _not_ be automatically swapped back like others + if (i % 2 == 0 || term.isVariable) { variable to term - else + } else { term to variable + } } } @@ -99,9 +114,9 @@ internal object EquationUtils { Struct.of("f", Var.of("A")) to Struct.of("f", Var.of("B")), Fact.of(Struct.of("aa", Var.of("A"))) to Fact.of(Struct.of("aa", Var.of("B"))), Directive.of(Atom.of("here"), Struct.of("f", Var.of("A"))) to - Directive.of(Atom.of("here"), Struct.of("f", Var.of("B"))), + Directive.of(Atom.of("here"), Struct.of("f", Var.of("B"))), Rule.of(Struct.fold("k", Var.of("A"), Var.of("A")), Truth.FALSE) to - Rule.of(Struct.fold("k", Var.of("B"), Var.of("C")), Truth.FALSE) + Rule.of(Struct.fold("k", Var.of("B"), Var.of("C")), Truth.FALSE) ) } @@ -129,14 +144,14 @@ internal object EquationUtils { listOf( LogicList.of(Atom.of("b"), Var.of("V")) to LogicList.of(Atom.of("a"), Var.of("V")), LogicList.from(listOf(Atom.of("a")), last = Var.of("V")) to - LogicList.from(listOf(Atom.of("b")), last = Var.of("V")), + LogicList.from(listOf(Atom.of("b")), last = Var.of("V")), LogicSet.of(Real.of(1.5), Var.anonymous()) to LogicSet.of(Integer.of(1), Var.anonymous()), Struct.of("f", Atom.of("A")) to Struct.of("f", Atom.of("B")), Fact.of(Struct.of("aa", Atom.of("A"))) to Fact.of(Struct.of("aa", Var.of("A"), Var.of("A"))), Directive.of(Atom.of("here"), Struct.of("f", Truth.TRUE)) to - Directive.of(Atom.of("here"), Struct.of("f", Truth.TRUE, Atom.of("extra"))), + Directive.of(Atom.of("here"), Struct.of("f", Truth.TRUE, Atom.of("extra"))), Rule.of(Struct.fold("k", Var.of("A"), Var.of("A")), Truth.FAIL) to - Rule.of(Struct.fold("different", Var.of("A"), Var.of("A")), Truth.FAIL) + Rule.of(Struct.fold("different", Var.of("A"), Var.of("A")), Truth.FAIL) ) } @@ -195,5 +210,4 @@ internal object EquationUtils { is Struct -> term.argsSequence.sumBy { countDeepGeneratedEquations(it) } else -> fail("Should never be there") } - } diff --git a/unify/src/commonTest/kotlin/it/unibo/tuprolog/unify/testutils/UnificatorUtils.kt b/unify/src/commonTest/kotlin/it/unibo/tuprolog/unify/testutils/UnificatorUtils.kt index 4a72d4388..7aeafe8ef 100644 --- a/unify/src/commonTest/kotlin/it/unibo/tuprolog/unify/testutils/UnificatorUtils.kt +++ b/unify/src/commonTest/kotlin/it/unibo/tuprolog/unify/testutils/UnificatorUtils.kt @@ -1,6 +1,16 @@ package it.unibo.tuprolog.unify.testutils -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Fact +import it.unibo.tuprolog.core.Indicator +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.List +import it.unibo.tuprolog.core.Rule +import it.unibo.tuprolog.core.Scope +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Substitution +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.unify.Equation import it.unibo.tuprolog.unify.Unificator import it.unibo.tuprolog.unify.eq @@ -17,11 +27,9 @@ private typealias MatchStrategy = (T1, T2) -> Boolean /** Represents teh Unification Unify function */ private typealias UnifyStrategy = (T1, T2) -> Term? - /** A typealias to simplify method signature writing */ private typealias CorrectnessMap = Map, Triple> - /** * Utils singleton for testing [Unificator] * @@ -49,17 +57,17 @@ internal object UnificatorUtils { internal val positiveMemberPatterns = member(Atom.of("a"), List.of(Atom.of("a"))) + - member( - List.of(Struct.of("a", Var.of("X"))), - List.of(List.of(Struct.of("a", Integer.of(1)))) - ) + member( + List.of(Struct.of("a", Var.of("X"))), + List.of(List.of(Struct.of("a", Integer.of(1)))) + ) internal val negativeMemberPatterns = member(Atom.of("a"), List.of(Atom.of("b"))) + - member( - List.of(Struct.of("a", Var.of("X"))), - List.of(List.of(Struct.of("b", Integer.of(1)))) - ) + member( + List.of(Struct.of("a", Var.of("X"))), + List.of(List.of(Struct.of("b", Integer.of(1)))) + ) /** Contains a mapping between equations that should have success unifying and a `Triple(mgu, isMatching, unifiedTerm)` */ internal val successfulUnifications by lazy { @@ -75,41 +83,41 @@ internal object UnificatorUtils { Scope.empty { (xVar eq varOf("X")) to Triple(Substitution.of(xVar, varOf("X")), true, varOf("X")) }, Var.anonymous().let { (xVar eq it) to Triple(Substitution.of(xVar, it), true, it) }, (Struct.of("f", aAtom, xVar) eq Struct.of("f", aAtom, bAtom)) to - Triple(Substitution.of(xVar, bAtom), true, Struct.of("f", aAtom, bAtom)), + Triple(Substitution.of(xVar, bAtom), true, Struct.of("f", aAtom, bAtom)), (Struct.of("f", xVar) eq Struct.of("f", yVar)) to - Triple(Substitution.of(xVar, yVar), true, Struct.of("f", yVar)), + Triple(Substitution.of(xVar, yVar), true, Struct.of("f", yVar)), (Struct.of("f", Struct.of("g", xVar)) eq Struct.of("f", yVar)) to - Triple( - Substitution.of(yVar, Struct.of("g", xVar)), - true, - Struct.of("f", Struct.of("g", xVar)) - ), + Triple( + Substitution.of(yVar, Struct.of("g", xVar)), + true, + Struct.of("f", Struct.of("g", xVar)) + ), (Struct.of("f", Struct.of("g", xVar), xVar) eq Struct.of("f", yVar, aAtom)) to - Triple( - Substitution.of(yVar to Struct.of("g", aAtom), xVar to aAtom), - true, - Struct.of("f", Struct.of("g", aAtom), aAtom) - ), + Triple( + Substitution.of(yVar to Struct.of("g", aAtom), xVar to aAtom), + true, + Struct.of("f", Struct.of("g", aAtom), aAtom) + ), Scope.empty { Rule.of(Struct.of("f", aAtom, Struct.of("b", varOf("X"))), bAtom) eq - Rule.of(Struct.of("f", varOf("A"), varOf("B")), varOf("C")) to - Triple( - Substitution.of( - varOf("A") to aAtom, - varOf("B") to Struct.of("b", varOf("X")), - varOf("C") to bAtom - ), - true, - Rule.of(Struct.of("f", aAtom, Struct.of("b", varOf("X"))), bAtom) - ) + Rule.of(Struct.of("f", varOf("A"), varOf("B")), varOf("C")) to + Triple( + Substitution.of( + varOf("A") to aAtom, + varOf("B") to Struct.of("b", varOf("X")), + varOf("C") to bAtom + ), + true, + Rule.of(Struct.of("f", aAtom, Struct.of("b", varOf("X"))), bAtom) + ) }, Scope.empty { Indicator.of("ciao", 2) eq Indicator.of(varOf("A"), varOf("B")) to - Triple( - Substitution.of(varOf("A") to Atom.of("ciao"), varOf("B") to Integer.of(2)), - true, - Indicator.of("ciao", 2) - ) + Triple( + Substitution.of(varOf("A") to Atom.of("ciao"), varOf("B") to Integer.of(2)), + true, + Indicator.of("ciao", 2) + ) } ) @@ -141,11 +149,11 @@ internal object UnificatorUtils { internal val successSequenceOfUnification by lazy { mapOf( listOf(xVar eq yVar, yVar eq aAtom) to - Triple(Substitution.of(xVar to aAtom, yVar to aAtom), true, aAtom), + Triple(Substitution.of(xVar to aAtom, yVar to aAtom), true, aAtom), listOf(aAtom eq yVar, xVar eq yVar) to - Triple(Substitution.of(xVar to aAtom, yVar to aAtom), true, aAtom), + Triple(Substitution.of(xVar to aAtom, yVar to aAtom), true, aAtom), listOf(aAtom eq yVar, xVar eq yVar, xVar eq aAtom) to - Triple(Substitution.of(xVar to aAtom, yVar to aAtom), true, aAtom) + Triple(Substitution.of(xVar to aAtom, yVar to aAtom), true, aAtom) ) } @@ -160,11 +168,11 @@ internal object UnificatorUtils { ) } - /** Asserts that mgu computed with [mguStrategy] over [equation] is equals to [expectedMgu] */ internal inline fun assertMguCorrect( equation: Equation, - expectedMgu: Substitution, mguStrategy: MguStrategy + expectedMgu: Substitution, + mguStrategy: MguStrategy ) { val (equationLhs, equationRhs) = equation.toPair() @@ -190,7 +198,8 @@ internal object UnificatorUtils { /** Asserts that match computed with [matchStrategy] over [equation] is equals to [expectedMatch] */ internal inline fun assertMatchCorrect( equation: Equation, - expectedMatch: Boolean, matchStrategy: MatchStrategy + expectedMatch: Boolean, + matchStrategy: MatchStrategy ) { val (equationLhs, equationRhs) = equation.toPair() @@ -216,7 +225,8 @@ internal object UnificatorUtils { /** Asserts that unified term computed with [unifyStrategy] over [equation] is equals to [expectedUnifiedTerm] */ internal inline fun assertUnifiedTermCorrect( equation: Equation, - expectedUnifiedTerm: Term?, unifyStrategy: UnifyStrategy + expectedUnifiedTerm: Term?, + unifyStrategy: UnifyStrategy ) { val (equationLhs, equationRhs) = equation.toPair() @@ -239,7 +249,6 @@ internal object UnificatorUtils { ) } - /** Utility function to calculate the unifier for more than one equation, passing created context through different unification */ private inline fun multipleEquationMgu( equations: KtList>, diff --git a/unify/src/jvmTest/kotlin/it/unibo/tuprolog/unify/TestThreadSafety.kt b/unify/src/jvmTest/kotlin/it/unibo/tuprolog/unify/TestThreadSafety.kt index b933cf2b9..84f460bc0 100644 --- a/unify/src/jvmTest/kotlin/it/unibo/tuprolog/unify/TestThreadSafety.kt +++ b/unify/src/jvmTest/kotlin/it/unibo/tuprolog/unify/TestThreadSafety.kt @@ -2,7 +2,8 @@ package it.unibo.tuprolog.unify import it.unibo.tuprolog.core.Substitution import it.unibo.tuprolog.unify.testutils.UnificatorUtils.successfulUnifications -import java.util.* +import java.util.Collections +import java.util.LinkedList import java.util.concurrent.Executors import java.util.concurrent.Future import java.util.concurrent.TimeUnit @@ -15,11 +16,13 @@ class TestThreadSafety { val executors = Executors.newFixedThreadPool(8) val results: MutableList> = Collections.synchronizedList(LinkedList()) val unificator = Unificator.cached(Unificator.strict()) - for (i in 1 .. 100) { + for (i in 1..100) { for (equation in successfulUnifications.keys) { - results.add(executors.submit { - unificator.mgu(equation.lhs, equation.rhs) - }) + results.add( + executors.submit { + unificator.mgu(equation.lhs, equation.rhs) + } + ) } } executors.shutdown() @@ -28,4 +31,4 @@ class TestThreadSafety { assertTrue { res.get() is Substitution.Unifier } } } -} \ No newline at end of file +} From a873b669e1a42c2c1ae321d8da78d209f80eae48 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 14 Sep 2020 12:39:59 +0200 Subject: [PATCH 08/34] format code in :theory --- theory/build.gradle.kts | 20 --------------- .../collections/AbstractClauseCollection.kt | 5 +--- .../AbstractMutableReteClauseCollection.kt | 3 +-- .../AbstractReteClauseCollection.kt | 8 +++--- .../tuprolog/collections/ClauseCollection.kt | 19 +++++++------- .../tuprolog/collections/ClauseMultiSet.kt | 9 ++++--- .../unibo/tuprolog/collections/ClauseQueue.kt | 10 ++++---- .../collections/MutableClauseCollection.kt | 18 +++++++------ .../collections/MutableClauseMultiSet.kt | 12 ++++----- .../collections/MutableClauseQueue.kt | 12 ++++----- .../tuprolog/collections/RetrieveResult.kt | 2 +- .../impl/MutableReteClauseMultiSet.kt | 5 ++-- .../impl/MutableReteClauseQueue.kt | 6 ++--- .../collections/impl/ReteClauseMultiSet.kt | 7 +++--- .../collections/impl/ReteClauseQueue.kt | 4 +-- .../collections/rete/custom/Cacheable.kt | 3 +-- .../collections/rete/custom/IndexingLeaf.kt | 3 +-- .../collections/rete/custom/IndexingNode.kt | 2 +- .../collections/rete/custom/ReteNode.kt | 3 +-- .../collections/rete/custom/ReteTree.kt | 2 +- .../collections/rete/custom/Retractable.kt | 3 +-- .../rete/custom/TopLevelReteNode.kt | 3 +-- .../tuprolog/collections/rete/custom/Utils.kt | 3 +-- .../rete/custom/clause/IndexedClause.kt | 3 +-- .../custom/clause/SituatedIndexedClause.kt | 4 +-- .../rete/custom/leaf/AbstractIndexingLeaf.kt | 2 +- .../collections/rete/custom/leaf/AtomIndex.kt | 11 ++++---- .../rete/custom/leaf/CompoundIndex.kt | 10 +++----- .../rete/custom/leaf/DirectiveIndex.kt | 21 ++++++++-------- .../rete/custom/leaf/NumericIndex.kt | 11 ++++---- .../rete/custom/leaf/VariableIndex.kt | 4 +-- .../rete/custom/nodes/ArityIndexing.kt | 2 +- .../rete/custom/nodes/ArityNode.kt | 2 -- .../rete/custom/nodes/ArityRete.kt | 2 +- .../custom/nodes/FamilyArityIndexingNode.kt | 3 +-- .../rete/custom/nodes/FamilyArityReteNode.kt | 15 +++++------ .../rete/custom/nodes/FunctorIndexing.kt | 2 +- .../rete/custom/nodes/FunctorIndexingNode.kt | 7 +++--- .../rete/custom/nodes/FunctorNode.kt | 1 - .../rete/custom/nodes/FunctorRete.kt | 2 +- .../collections/rete/custom/nodes/RootNode.kt | 4 +-- .../collections/rete/custom/nodes/RuleNode.kt | 2 +- .../custom/nodes/TopLevelFunctorReteNode.kt | 2 +- .../rete/custom/nodes/ZeroArityReteNode.kt | 2 +- .../generic/AbstractIntermediateReteNode.kt | 10 +++++--- .../rete/generic/AbstractLeafReteNode.kt | 10 +++++--- .../rete/generic/AbstractReteNode.kt | 11 ++++---- .../collections/rete/generic/set/ArgNode.kt | 1 - .../collections/rete/generic/set/ArityNode.kt | 2 -- .../rete/generic/set/NoArgsNode.kt | 6 +++-- .../collections/rete/generic/set/RootNode.kt | 6 +++-- .../unibo/tuprolog/theory/AbstractTheory.kt | 8 ++++-- .../it/unibo/tuprolog/theory/RetractResult.kt | 2 +- .../kotlin/it/unibo/tuprolog/theory/Theory.kt | 25 +++++++++++++------ .../it/unibo/tuprolog/theory/TheoryUtils.kt | 9 +++---- .../tuprolog/theory/impl/IndexedTheory.kt | 2 +- .../tuprolog/theory/impl/ListedTheory.kt | 9 ++++--- .../PrototypeClauseCollectionTest.kt | 3 +-- .../PrototypeClauseMultiSetTest.kt | 4 +-- .../collections/PrototypeClauseQueueTest.kt | 2 +- .../impl/MutableReteClauseMultiSetTest.kt | 5 ++-- .../impl/MutableReteClauseQueueTest.kt | 2 +- .../impl/ReteClauseMultiSetTest.kt | 2 +- .../collections/impl/ReteClauseQueueTest.kt | 2 +- .../PrototypeClauseCollectionTestImpl.kt | 10 +++++--- .../PrototypeClauseMultiSetTestImpl.kt | 19 +++++++------- .../PrototypeClauseQueueTestImpl.kt | 11 +++++--- .../rete/custom/OrderedReteTreeTest.kt | 9 ++++--- .../rete/custom/ReteTreeAssertionUtils.kt | 15 +++++++++-- .../rete/custom/UnorderedReteTreeTest.kt | 10 +++++--- .../collections/rete/nodes/set/ArgNodeTest.kt | 10 ++++++-- .../rete/nodes/set/ArityNodeTest.kt | 15 ++++++++--- .../rete/nodes/set/DirectiveNodeTest.kt | 7 ++++-- .../rete/nodes/set/FunctorNodeTest.kt | 6 ++++- .../rete/nodes/set/NoArgsNodeTest.kt | 7 ++++-- .../rete/nodes/set/RootNodeTest.kt | 19 ++++++++++---- .../rete/nodes/set/RuleNodeTest.kt | 6 ++++- .../testutils/ClauseAssertionUtils.kt | 11 +++++--- .../unibo/tuprolog/testutils/ReteNodeUtils.kt | 23 ++++++++++++----- .../unibo/tuprolog/testutils/TheoryUtils.kt | 13 +++++++++- .../theory/PrototypeProperIndexingTest.kt | 17 +++++++------ .../theory/PrototypeTheoryCreationTest.kt | 1 - .../tuprolog/theory/PrototypeTheoryTest.kt | 16 +++++++++--- .../theory/impl/IndexedClauseIndexingTest.kt | 4 +-- .../tuprolog/theory/impl/IndexedTheoryTest.kt | 2 +- .../theory/impl/ListedClauseIndexingTest.kt | 3 +-- .../tuprolog/theory/impl/ListedTheoryTest.kt | 2 +- 87 files changed, 351 insertions(+), 280 deletions(-) diff --git a/theory/build.gradle.kts b/theory/build.gradle.kts index b799641eb..c6a382ffd 100644 --- a/theory/build.gradle.kts +++ b/theory/build.gradle.kts @@ -1,5 +1,4 @@ kotlin { - sourceSets { val commonMain by getting { dependencies { @@ -7,24 +6,5 @@ kotlin { api(project(":unify")) } } - - // Default source set for JVM-specific sources and dependencies: - jvm { - compilations["main"].defaultSourceSet { - dependencies { -// api(project(":core")) -// api(project(":unify")) - } - } - } - - js { - compilations["main"].defaultSourceSet { - dependencies { -// api(project(":core")) -// api(project(":unify")) - } - } - } } } diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/AbstractClauseCollection.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/AbstractClauseCollection.kt index 92e5c28a8..4aa33e862 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/AbstractClauseCollection.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/AbstractClauseCollection.kt @@ -2,7 +2,6 @@ package it.unibo.tuprolog.collections import it.unibo.tuprolog.collections.rete.custom.ReteTree import it.unibo.tuprolog.core.Clause -import it.unibo.tuprolog.theory.TheoryUtils internal abstract class AbstractClauseCollection> protected constructor(protected val rete: ReteTree) : ClauseCollection { @@ -33,6 +32,4 @@ protected constructor(protected val rete: ReteTree) : ClauseCollection { override fun toString(): String { return "${this::class.simpleName}(${this.joinToString(", ")})" } - - -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/AbstractMutableReteClauseCollection.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/AbstractMutableReteClauseCollection.kt index a9e6cc278..9e7357c90 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/AbstractMutableReteClauseCollection.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/AbstractMutableReteClauseCollection.kt @@ -2,7 +2,6 @@ package it.unibo.tuprolog.collections import it.unibo.tuprolog.collections.rete.custom.ReteTree import it.unibo.tuprolog.core.Clause -import it.unibo.tuprolog.theory.TheoryUtils internal abstract class AbstractMutableReteClauseCollection> protected constructor( @@ -50,4 +49,4 @@ protected constructor( ) } } -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/AbstractReteClauseCollection.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/AbstractReteClauseCollection.kt index fc6ac8859..b5ff3f653 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/AbstractReteClauseCollection.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/AbstractReteClauseCollection.kt @@ -37,7 +37,8 @@ protected constructor( RetrieveResult.Failure(this as Self) else -> RetrieveResult.Success( - newCollectionBuilder(newTheory), retracted.toList() + newCollectionBuilder(newTheory), + retracted.toList() ) } } @@ -52,8 +53,9 @@ protected constructor( RetrieveResult.Failure(this as Self) else -> RetrieveResult.Success( - newCollectionBuilder(newTheory), retracted.toList() + newCollectionBuilder(newTheory), + retracted.toList() ) } } -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/ClauseCollection.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/ClauseCollection.kt index 8f95e914f..e9e273cec 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/ClauseCollection.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/ClauseCollection.kt @@ -59,9 +59,11 @@ interface ClauseCollection : Iterable { @JvmStatic @JsName("multiSetOfScopes") fun multiSetOf(vararg clause: Scope.() -> Clause): ClauseMultiSet = - multiSetOf(clause.map { - Scope.empty(it) - }) + multiSetOf( + clause.map { + Scope.empty(it) + } + ) /** Creates a [ClauseQueue] from the given [Sequence] of [Clause] */ @JvmStatic @@ -88,9 +90,11 @@ interface ClauseCollection : Iterable { @JvmStatic @JsName("queueOfScopes") fun queueOf(vararg clause: Scope.() -> Clause): ClauseQueue = - queueOf(clause.map { - Scope.empty(it) - }) + queueOf( + clause.map { + Scope.empty(it) + } + ) /** Creates a [ClauseQueue] from the given [Sequence] of [Clause] */ @JvmStatic @@ -104,6 +108,3 @@ interface ClauseCollection : Iterable { ClauseQueue.of(clauses) } } - - - diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/ClauseMultiSet.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/ClauseMultiSet.kt index 534bc540e..2da86bc4c 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/ClauseMultiSet.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/ClauseMultiSet.kt @@ -48,9 +48,11 @@ interface ClauseMultiSet : ClauseCollection { @JvmStatic @JsName("ofScopes") fun of(vararg clause: Scope.() -> Clause): ClauseMultiSet = - of(clause.map { - Scope.empty(it) - }) + of( + clause.map { + Scope.empty(it) + } + ) /** Creates a [ClauseMultiSet] from the given [Sequence] of [Clause] */ @JvmStatic @@ -82,4 +84,3 @@ interface ClauseMultiSet : ClauseCollection { } } } - diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/ClauseQueue.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/ClauseQueue.kt index 0986b0296..4b1c36c52 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/ClauseQueue.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/ClauseQueue.kt @@ -69,9 +69,11 @@ interface ClauseQueue : ClauseCollection { @JvmStatic @JsName("ofScopes") fun of(vararg clause: Scope.() -> Clause): ClauseQueue = - of(clause.map { - Scope.empty(it) - }) + of( + clause.map { + Scope.empty(it) + } + ) /** Creates a [ClauseQueue] from the given [Sequence] of [Clause] */ @JvmStatic @@ -99,6 +101,4 @@ interface ClauseQueue : ClauseCollection { ) } } - } - diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/MutableClauseCollection.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/MutableClauseCollection.kt index 98537f0d0..cb11761f4 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/MutableClauseCollection.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/MutableClauseCollection.kt @@ -35,9 +35,11 @@ interface MutableClauseCollection : ClauseCollection { @JvmStatic @JsName("multiSetOfScopes") fun multiSetOf(vararg clause: Scope.() -> Clause): MutableClauseMultiSet = - multiSetOf(clause.map { - Scope.empty(it) - }) + multiSetOf( + clause.map { + Scope.empty(it) + } + ) /** Creates a [MutableClauseQueue] from the given [Sequence] of [Clause] */ @JvmStatic @@ -64,9 +66,11 @@ interface MutableClauseCollection : ClauseCollection { @JvmStatic @JsName("queueOfScopes") fun queueOf(vararg clause: Scope.() -> Clause): MutableClauseQueue = - queueOf(clause.map { - Scope.empty(it) - }) + queueOf( + clause.map { + Scope.empty(it) + } + ) /** Creates a [MutableClauseQueue] from the given [Sequence] of [Clause] */ @JvmStatic @@ -79,4 +83,4 @@ interface MutableClauseCollection : ClauseCollection { fun queueOf(clauses: Iterable): MutableClauseQueue = MutableClauseQueue.of(clauses) } -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/MutableClauseMultiSet.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/MutableClauseMultiSet.kt index e005a10f0..df9cac350 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/MutableClauseMultiSet.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/MutableClauseMultiSet.kt @@ -4,7 +4,6 @@ import it.unibo.tuprolog.collections.impl.MutableReteClauseMultiSet import it.unibo.tuprolog.core.Clause import it.unibo.tuprolog.core.Scope import it.unibo.tuprolog.core.TermComparator -import it.unibo.tuprolog.utils.itemWiseEquals import it.unibo.tuprolog.utils.itemWiseHashCode import kotlin.js.JsName import kotlin.jvm.JvmStatic @@ -39,9 +38,11 @@ interface MutableClauseMultiSet : ClauseMultiSet { @JvmStatic @JsName("ofScopes") fun of(vararg clause: Scope.() -> Clause): MutableClauseMultiSet = - of(clause.map { - Scope.empty(it) - }) + of( + clause.map { + Scope.empty(it) + } + ) /** Creates a [MutableClauseMultiSet] from the given [Sequence] of [Clause] */ @JvmStatic @@ -69,5 +70,4 @@ interface MutableClauseMultiSet : ClauseMultiSet { ) } } - -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/MutableClauseQueue.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/MutableClauseQueue.kt index d822d70c7..818af2be9 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/MutableClauseQueue.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/MutableClauseQueue.kt @@ -3,7 +3,6 @@ package it.unibo.tuprolog.collections import it.unibo.tuprolog.collections.impl.MutableReteClauseQueue import it.unibo.tuprolog.core.Clause import it.unibo.tuprolog.core.Scope -import it.unibo.tuprolog.utils.itemWiseEquals import it.unibo.tuprolog.utils.itemWiseHashCode import kotlin.js.JsName import kotlin.jvm.JvmStatic @@ -47,9 +46,11 @@ interface MutableClauseQueue : ClauseQueue { @JvmStatic @JsName("ofScopes") fun of(vararg clause: Scope.() -> Clause): MutableClauseQueue = - of(clause.map { - Scope.empty(it) - }) + of( + clause.map { + Scope.empty(it) + } + ) /** Creates a [MutableClauseQueue] from the given [Sequence] of [Clause] */ @JvmStatic @@ -77,5 +78,4 @@ interface MutableClauseQueue : ClauseQueue { ) } } - -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/RetrieveResult.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/RetrieveResult.kt index 8a8ca42f4..af8b96d64 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/RetrieveResult.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/RetrieveResult.kt @@ -19,4 +19,4 @@ sealed class RetrieveResult { } data class Failure(override val collection: C) : RetrieveResult() -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/impl/MutableReteClauseMultiSet.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/impl/MutableReteClauseMultiSet.kt index 0cf323609..8051cae60 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/impl/MutableReteClauseMultiSet.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/impl/MutableReteClauseMultiSet.kt @@ -1,7 +1,7 @@ package it.unibo.tuprolog.collections.impl -import it.unibo.tuprolog.collections.* import it.unibo.tuprolog.collections.AbstractMutableReteClauseCollection +import it.unibo.tuprolog.collections.MutableClauseMultiSet import it.unibo.tuprolog.collections.rete.custom.ReteTree import it.unibo.tuprolog.core.Clause import it.unibo.tuprolog.theory.TheoryUtils @@ -22,7 +22,6 @@ internal class MutableReteClauseMultiSet private constructor( override fun count(clause: Clause): Long = rete.get(clause).count().toLong() - override fun get(clause: Clause): Sequence = rete.get(clause) @@ -37,4 +36,4 @@ internal class MutableReteClauseMultiSet private constructor( override fun hashCode(): Int { return MutableClauseMultiSet.hashCode(this) } -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/impl/MutableReteClauseQueue.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/impl/MutableReteClauseQueue.kt index 7804f1c6d..581802e60 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/impl/MutableReteClauseQueue.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/impl/MutableReteClauseQueue.kt @@ -1,7 +1,6 @@ package it.unibo.tuprolog.collections.impl import it.unibo.tuprolog.collections.AbstractMutableReteClauseCollection -import it.unibo.tuprolog.collections.ClauseQueue import it.unibo.tuprolog.collections.MutableClauseQueue import it.unibo.tuprolog.collections.RetrieveResult import it.unibo.tuprolog.collections.rete.custom.ReteTree @@ -45,7 +44,8 @@ internal class MutableReteClauseQueue private constructor( RetrieveResult.Failure(this) else -> RetrieveResult.Success( - this, retracted.toList() + this, + retracted.toList() ) } } @@ -61,4 +61,4 @@ internal class MutableReteClauseQueue private constructor( override fun hashCode(): Int { return MutableClauseQueue.hashCode(this) } -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/impl/ReteClauseMultiSet.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/impl/ReteClauseMultiSet.kt index 69e527b4d..543933fd8 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/impl/ReteClauseMultiSet.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/impl/ReteClauseMultiSet.kt @@ -1,11 +1,11 @@ package it.unibo.tuprolog.collections.impl -import it.unibo.tuprolog.collections.* import it.unibo.tuprolog.collections.AbstractReteClauseCollection +import it.unibo.tuprolog.collections.ClauseMultiSet +import it.unibo.tuprolog.collections.MutableClauseMultiSet import it.unibo.tuprolog.collections.rete.custom.ReteTree import it.unibo.tuprolog.core.Clause import it.unibo.tuprolog.theory.TheoryUtils -import it.unibo.tuprolog.utils.itemWiseHashCode internal class ReteClauseMultiSet private constructor( rete: ReteTree @@ -43,5 +43,4 @@ internal class ReteClauseMultiSet private constructor( } override fun hashCode(): Int = hashCodeCache - -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/impl/ReteClauseQueue.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/impl/ReteClauseQueue.kt index 9b2cc141c..8e74d2224 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/impl/ReteClauseQueue.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/impl/ReteClauseQueue.kt @@ -7,7 +7,6 @@ import it.unibo.tuprolog.collections.RetrieveResult import it.unibo.tuprolog.collections.rete.custom.ReteTree import it.unibo.tuprolog.core.Clause import it.unibo.tuprolog.theory.TheoryUtils -import it.unibo.tuprolog.utils.itemWiseHashCode internal class ReteClauseQueue private constructor( rete: ReteTree @@ -69,5 +68,4 @@ internal class ReteClauseQueue private constructor( override fun hashCode(): Int { return hashCodeCache } - -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/Cacheable.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/Cacheable.kt index 7ece768bc..4be2e5ec3 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/Cacheable.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/Cacheable.kt @@ -10,5 +10,4 @@ internal interface Cacheable { /**Forcefully invalidate the node cache and all of its subtree cache*/ fun invalidateCache() - -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/IndexingLeaf.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/IndexingLeaf.kt index 3888e53b2..f2d9310ed 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/IndexingLeaf.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/IndexingLeaf.kt @@ -22,5 +22,4 @@ internal interface IndexingLeaf : ReteNode { /**Variant of [getIndexed] aimed at preventing a proper traversal of the children of this node, * retrieving all the clauses matching the given [Clause] without performing any branch selection*/ fun extractGlobalIndexedSequence(clause: Clause): Sequence - -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/IndexingNode.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/IndexingNode.kt index c37550334..444d28d32 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/IndexingNode.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/IndexingNode.kt @@ -2,4 +2,4 @@ package it.unibo.tuprolog.collections.rete.custom /**Marker interface to expand the capabilites of a [ReteNode] to behave as an [IndexingLeaf */ -internal interface IndexingNode : ReteNode, IndexingLeaf \ No newline at end of file +internal interface IndexingNode : ReteNode, IndexingLeaf diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/ReteNode.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/ReteNode.kt index 909c87b38..c3c363ef1 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/ReteNode.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/ReteNode.kt @@ -18,5 +18,4 @@ internal interface ReteNode : Cacheable { /**Removes all the clauses matching the given [Clause], returning all of them as a [Sequence] of [Clause]*/ fun retractAll(clause: Clause): Sequence - -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/ReteTree.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/ReteTree.kt index 3245c8c0b..db8f69633 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/ReteTree.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/ReteTree.kt @@ -67,4 +67,4 @@ interface ReteTree { fun ordered(vararg clauses: Clause): ReteTree = ordered(listOf(*clauses)) } -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/Retractable.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/Retractable.kt index 6705d60a6..de0c391b4 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/Retractable.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/Retractable.kt @@ -8,5 +8,4 @@ internal interface Retractable { /**Removes the given [SituatedIndexedClause] from the storage of this node*/ fun retractIndexed(indexed: SituatedIndexedClause) - -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/TopLevelReteNode.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/TopLevelReteNode.kt index 038cfca2e..720f5175c 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/TopLevelReteNode.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/TopLevelReteNode.kt @@ -9,5 +9,4 @@ internal interface TopLevelReteNode : ReteNode { /**Retracts the first matching occurrence of the given [Clause] from this [ReteTree]*/ fun retractFirst(clause: Clause): Sequence - -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/Utils.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/Utils.kt index 77455533d..600a61e0e 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/Utils.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/Utils.kt @@ -97,5 +97,4 @@ internal object Utils { a < b -> a else -> b } - -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/clause/IndexedClause.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/clause/IndexedClause.kt index 3c224daf1..5eec47b6a 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/clause/IndexedClause.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/clause/IndexedClause.kt @@ -51,5 +51,4 @@ internal interface IndexedClause : LongIndexed { ) } } - -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/clause/SituatedIndexedClause.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/clause/SituatedIndexedClause.kt index 002a83914..6ffd06cc7 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/clause/SituatedIndexedClause.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/clause/SituatedIndexedClause.kt @@ -43,6 +43,4 @@ internal interface SituatedIndexedClause : IndexedClause { } } } - - -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/leaf/AbstractIndexingLeaf.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/leaf/AbstractIndexingLeaf.kt index 3cb616131..dcf9bcd7a 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/leaf/AbstractIndexingLeaf.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/leaf/AbstractIndexingLeaf.kt @@ -6,4 +6,4 @@ internal abstract class AbstractIndexingLeaf : IndexingLeaf { override fun invalidateCache() { /* do nothing */ } -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/leaf/AtomIndex.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/leaf/AtomIndex.kt index a64396541..53fd75a20 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/leaf/AtomIndex.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/leaf/AtomIndex.kt @@ -21,13 +21,13 @@ internal class AtomIndex( private val index: MutableMap> = mutableMapOf() override fun get(clause: Clause): Sequence { - return if (clause.nestedFirstArgument().isAtom) + return if (clause.nestedFirstArgument().isAtom) { index[clause.asInnerAtom()] ?.asSequence() ?.filter { it.innerClause matches clause } ?.map { it.innerClause } ?: emptySequence() - else extractGlobalSequence(clause) + } else extractGlobalSequence(clause) } override fun assertA(clause: IndexedClause) { @@ -73,12 +73,12 @@ internal class AtomIndex( } override fun getIndexed(clause: Clause): Sequence { - return if (clause.nestedFirstArgument().isAtom) + return if (clause.nestedFirstArgument().isAtom) { index[clause.asInnerAtom()] ?.asSequence() ?.filter { it.innerClause matches clause } ?: emptySequence() - else extractGlobalIndexedSequence(clause) + } else extractGlobalIndexedSequence(clause) } override fun retractIndexed(indexed: SituatedIndexedClause) { @@ -126,5 +126,4 @@ internal class AtomIndex( private fun IndexedClause.asInnerAtom(): Atom = this.innerClause.nestedFirstArgument() as Atom - -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/leaf/CompoundIndex.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/leaf/CompoundIndex.kt index 2b8cd0845..62da4a5df 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/leaf/CompoundIndex.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/leaf/CompoundIndex.kt @@ -65,7 +65,6 @@ internal class CompoundIndex( retractAllUnordered(clause) } - override fun getCache(): Sequence = theoryCache.value.asSequence() @@ -113,7 +112,6 @@ internal class CompoundIndex( if (clause.isGlobal()) { Utils.merge( functors.values.map { -// it.getIndexed(clause) it.extractGlobalIndexedSequence(clause) } ) @@ -137,18 +135,19 @@ internal class CompoundIndex( } override fun extractGlobalIndexedSequence(clause: Clause): Sequence { - return if (ordered) + return if (ordered) { Utils.merge( functors.values.map { it.extractGlobalIndexedSequence(clause) } ) - else + } else { Utils.flattenIndexed( functors.values.map { it.extractGlobalIndexedSequence(clause) } ) + } } private fun Clause.nestedFunctor(): String = @@ -181,5 +180,4 @@ internal class CompoundIndex( ) } ) - -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/leaf/DirectiveIndex.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/leaf/DirectiveIndex.kt index 3907a3545..bfa5f59bf 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/leaf/DirectiveIndex.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/leaf/DirectiveIndex.kt @@ -43,23 +43,22 @@ internal class DirectiveIndex(private val ordered: Boolean) : TopLevelReteNode { override fun getCache(): Sequence = directives.asSequence().map { - SituatedIndexedClause.of(it, object : Retractable { - override fun retractIndexed(indexed: SituatedIndexedClause) { - TODO( - "Directives are adapted as a SituatedIndexedClause, but they are not actually not stored " + + SituatedIndexedClause.of( + it, + object : Retractable { + override fun retractIndexed(indexed: SituatedIndexedClause) { + TODO( + "Directives are adapted as a SituatedIndexedClause, but they are not actually not stored " + "with this type. Given their particular semantic, try retracting directly with a proper " + "query, or opening a pull request implementing this indexing class as a proper typed data " + "structure" - ) + ) + } } - - }) + ) } override fun invalidateCache() { /* do nothing */ } - - - -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/leaf/NumericIndex.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/leaf/NumericIndex.kt index 2dcad66e5..f5f639a10 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/leaf/NumericIndex.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/leaf/NumericIndex.kt @@ -21,13 +21,13 @@ internal class NumericIndex( private val index: MutableMap> = mutableMapOf() override fun get(clause: Clause): Sequence { - return if (clause.nestedFirstArgument().isNumber) + return if (clause.nestedFirstArgument().isNumber) { index[clause.asInnerNumeric()] ?.asSequence() ?.filter { it.innerClause matches clause } ?.map { it.innerClause } ?: emptySequence() - else extractGlobalSequence(clause) + } else extractGlobalSequence(clause) } override fun assertA(clause: IndexedClause) { @@ -73,12 +73,12 @@ internal class NumericIndex( } override fun getIndexed(clause: Clause): Sequence { - return if (clause.nestedFirstArgument().isNumber) + return if (clause.nestedFirstArgument().isNumber) { index[clause.asInnerNumeric()] ?.asSequence() ?.filter { it.innerClause matches clause } ?: emptySequence() - else extractGlobalIndexedSequence(clause) + } else extractGlobalIndexedSequence(clause) } override fun retractIndexed(indexed: SituatedIndexedClause) { @@ -126,5 +126,4 @@ internal class NumericIndex( private fun IndexedClause.asInnerNumeric(): Numeric = this.innerClause.nestedFirstArgument() as Numeric - -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/leaf/VariableIndex.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/leaf/VariableIndex.kt index 6aa0fcc10..e4881e20b 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/leaf/VariableIndex.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/leaf/VariableIndex.kt @@ -50,7 +50,6 @@ internal class VariableIndex( override fun retractAllIndexed(clause: Clause): Sequence = Utils.removeAllLazily(variables, clause).buffered() - private fun extractFirst(clause: Clause, index: MutableList): SituatedIndexedClause? { val actualIndex = index.indexOfFirst { it.innerClause matches clause } @@ -66,5 +65,4 @@ internal class VariableIndex( private fun extractGlobalSequence(clause: Clause): Sequence = extractGlobalIndexedSequence(clause).map { it.innerClause } - -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/ArityIndexing.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/ArityIndexing.kt index 9b74a1f22..f5640b838 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/ArityIndexing.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/ArityIndexing.kt @@ -3,4 +3,4 @@ package it.unibo.tuprolog.collections.rete.custom.nodes import it.unibo.tuprolog.collections.rete.custom.IndexingNode import it.unibo.tuprolog.collections.rete.custom.ReteNode -internal interface ArityIndexing : ReteNode, IndexingNode \ No newline at end of file +internal interface ArityIndexing : ReteNode, IndexingNode diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/ArityNode.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/ArityNode.kt index 8889376c6..58ffa234c 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/ArityNode.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/ArityNode.kt @@ -3,5 +3,3 @@ package it.unibo.tuprolog.collections.rete.custom.nodes import it.unibo.tuprolog.collections.rete.custom.ReteNode internal abstract class ArityNode : ReteNode - - diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/ArityRete.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/ArityRete.kt index 0242f1f09..0c4650200 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/ArityRete.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/ArityRete.kt @@ -3,4 +3,4 @@ package it.unibo.tuprolog.collections.rete.custom.nodes import it.unibo.tuprolog.collections.rete.custom.ReteNode import it.unibo.tuprolog.collections.rete.custom.TopLevelReteNode -internal interface ArityRete : ReteNode, TopLevelReteNode \ No newline at end of file +internal interface ArityRete : ReteNode, TopLevelReteNode diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/FamilyArityIndexingNode.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/FamilyArityIndexingNode.kt index f6a6e2db3..ebdae709d 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/FamilyArityIndexingNode.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/FamilyArityIndexingNode.kt @@ -41,5 +41,4 @@ internal class FamilyArityIndexingNode( ) } } - -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/FamilyArityReteNode.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/FamilyArityReteNode.kt index 1f67e0a3b..44811324a 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/FamilyArityReteNode.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/FamilyArityReteNode.kt @@ -9,7 +9,11 @@ import it.unibo.tuprolog.collections.rete.custom.leaf.AtomIndex import it.unibo.tuprolog.collections.rete.custom.leaf.CompoundIndex import it.unibo.tuprolog.collections.rete.custom.leaf.NumericIndex import it.unibo.tuprolog.collections.rete.custom.leaf.VariableIndex -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Clause +import it.unibo.tuprolog.core.Numeric +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.utils.Cached import it.unibo.tuprolog.utils.dequeOf @@ -46,7 +50,6 @@ internal open class FamilyArityReteNode( } } - override fun get(clause: Clause): Sequence { return if (clause.isGlobal()) { if (ordered) { @@ -70,7 +73,6 @@ internal open class FamilyArityReteNode( } } - override fun assertA(clause: IndexedClause) = assertByFirstParameter(clause).assertA(clause + this) @@ -151,7 +153,6 @@ internal open class FamilyArityReteNode( ) } - protected fun getOrderedIndexed(clause: Clause): Sequence = when (clause.nestedFirstArgument()) { is Numeric -> @@ -178,7 +179,6 @@ internal open class FamilyArityReteNode( ) } - protected fun getUnorderedIndexed(clause: Clause): Sequence = when (clause.nestedFirstArgument()) { is Numeric -> Utils.flattenIndexed( @@ -201,7 +201,6 @@ internal open class FamilyArityReteNode( ) } - protected fun anyLookahead(clause: Clause): SituatedIndexedClause? = when (clause.nestedFirstArgument()) { is Numeric -> { @@ -224,7 +223,6 @@ internal open class FamilyArityReteNode( } } - protected fun orderedLookahead(clause: Clause): SituatedIndexedClause? = when (clause.nestedFirstArgument()) { is Numeric -> { @@ -295,5 +293,4 @@ internal open class FamilyArityReteNode( private fun Clause.isGlobal(): Boolean = this.head!!.nestedFirstArgument(nestingLevel + 1) is Var - -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/FunctorIndexing.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/FunctorIndexing.kt index a1422ce3b..775a9ddc7 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/FunctorIndexing.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/FunctorIndexing.kt @@ -3,4 +3,4 @@ package it.unibo.tuprolog.collections.rete.custom.nodes import it.unibo.tuprolog.collections.rete.custom.IndexingNode import it.unibo.tuprolog.collections.rete.custom.ReteNode -internal interface FunctorIndexing : ReteNode, IndexingNode \ No newline at end of file +internal interface FunctorIndexing : ReteNode, IndexingNode diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/FunctorIndexingNode.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/FunctorIndexingNode.kt index 472ee9e3d..de63d640a 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/FunctorIndexingNode.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/FunctorIndexingNode.kt @@ -61,7 +61,6 @@ internal class FunctorIndexingNode( return if (clause.isGlobal()) { Utils.merge( arities.values.map { -// it.getIndexed(clause) it.extractGlobalIndexedSequence(clause) } ) @@ -75,7 +74,8 @@ internal class FunctorIndexingNode( val partialResult = Utils.merge( arities.values.map { it.extractGlobalIndexedSequence(clause) - }) + } + ) .filter { it.innerClause matches clause } .toList() if (partialResult.isNotEmpty()) { @@ -135,5 +135,4 @@ internal class FunctorIndexingNode( ) } ) - -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/FunctorNode.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/FunctorNode.kt index 4d29765a2..45f25758d 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/FunctorNode.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/FunctorNode.kt @@ -3,4 +3,3 @@ package it.unibo.tuprolog.collections.rete.custom.nodes import it.unibo.tuprolog.collections.rete.custom.ReteNode internal abstract class FunctorNode : ReteNode - diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/FunctorRete.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/FunctorRete.kt index 78e8871b5..dc8d51c03 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/FunctorRete.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/FunctorRete.kt @@ -3,4 +3,4 @@ package it.unibo.tuprolog.collections.rete.custom.nodes import it.unibo.tuprolog.collections.rete.custom.ReteNode import it.unibo.tuprolog.collections.rete.custom.TopLevelReteNode -internal interface FunctorRete : ReteNode, TopLevelReteNode \ No newline at end of file +internal interface FunctorRete : ReteNode, TopLevelReteNode diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/RootNode.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/RootNode.kt index abf7efe03..231df5c07 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/RootNode.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/RootNode.kt @@ -42,7 +42,7 @@ internal class RootNode( } override fun retractOnly(clause: Clause, limit: Int): Sequence = - (1 .. limit).asSequence().flatMap { retractFirst(clause) }.buffered() + (1..limit).asSequence().flatMap { retractFirst(clause) }.buffered() override fun retractAll(clause: Clause): Sequence = if (clause.isDirective) { @@ -111,4 +111,4 @@ internal class RootNode( override fun invalidateCache() { theoryCache.invalidate() } -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/RuleNode.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/RuleNode.kt index a60691acf..80b58f8af 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/RuleNode.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/RuleNode.kt @@ -77,4 +77,4 @@ internal class RuleNode( ) } ) -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/TopLevelFunctorReteNode.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/TopLevelFunctorReteNode.kt index 349f1b7c8..a82592363 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/TopLevelFunctorReteNode.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/TopLevelFunctorReteNode.kt @@ -80,4 +80,4 @@ internal class TopLevelFunctorReteNode( ) } ) -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/ZeroArityReteNode.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/ZeroArityReteNode.kt index cb7a845ec..7dd7b6494 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/ZeroArityReteNode.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/custom/nodes/ZeroArityReteNode.kt @@ -57,4 +57,4 @@ internal class ZeroArityReteNode(private val ordered: Boolean) : ArityNode(), Ar override fun retractIndexed(indexed: SituatedIndexedClause) { atoms.remove(indexed) } -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/generic/AbstractIntermediateReteNode.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/generic/AbstractIntermediateReteNode.kt index f8c40e764..0e6247c25 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/generic/AbstractIntermediateReteNode.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/generic/AbstractIntermediateReteNode.kt @@ -34,13 +34,15 @@ internal abstract class AbstractIntermediateReteNode(override val children limit: Int, operation: (acc: R, T) -> R ) = - if (limit < 0) + if (limit < 0) { fold(initial, operation) - else + } else { fold(initial) { accumulator, element -> - if (accumulator.count() < limit) + if (accumulator.count() < limit) { operation(accumulator, element) - else + } else { return@foldWithLimit accumulator + } } + } } diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/generic/AbstractLeafReteNode.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/generic/AbstractLeafReteNode.kt index 693f15ee5..1812c3eb7 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/generic/AbstractLeafReteNode.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/generic/AbstractLeafReteNode.kt @@ -13,10 +13,11 @@ internal abstract class AbstractLeafReteNode(override val children: MutableMa get() = leafElements.asSequence() override fun put(element: E, beforeOthers: Boolean) { - if (beforeOthers) + if (beforeOthers) { leafElements.add(0, element) - else + } else { leafElements.add(element) + } } override fun removeWithLimit(element: E, limit: Int): Sequence = @@ -33,8 +34,9 @@ internal abstract class AbstractLeafReteNode(override val children: MutableMa .also { leafElements.removeAll(it) } override fun toString(treefy: Boolean): String = - if (treefy) + if (treefy) { "$header {${leafElements.joinToString(".\n\t", "\n\t", ".\n")}}" - else + } else { toString() + } } diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/generic/AbstractReteNode.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/generic/AbstractReteNode.kt index 569ae6f4d..499a6e4e8 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/generic/AbstractReteNode.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/generic/AbstractReteNode.kt @@ -20,15 +20,16 @@ internal abstract class AbstractReteNode(override val children: MutableMap override fun removeAll(element: E): Sequence = remove(element, Int.MAX_VALUE) override fun toString(treefy: Boolean): String = - if (treefy) + if (treefy) { "$header {" + - children.values.joinToString(",\n\t", "\n\t", "\n") { - it.toString(treefy).replace("\n", "\n\t") - } + "}" - else + children.values.joinToString(",\n\t", "\n\t", "\n") { + it.toString(treefy).replace("\n", "\n\t") + } + "}" + } else { "$header {${children.values.joinToString(",") { it.toString() }}" + } override fun toString(): String { return toString(false) diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/generic/set/ArgNode.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/generic/set/ArgNode.kt index 78abc570f..49dd138f0 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/generic/set/ArgNode.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/generic/set/ArgNode.kt @@ -33,7 +33,6 @@ internal data class ArgNode( } else -> children.getOrPut(null) { RuleNode() } - }.put(element, beforeOthers) override fun selectChildren(element: Rule): Sequence?> = when { diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/generic/set/ArityNode.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/generic/set/ArityNode.kt index d91025cc2..4b68ab0a6 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/generic/set/ArityNode.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/generic/set/ArityNode.kt @@ -22,7 +22,6 @@ internal data class ArityNode( element.head.arity > 0 -> { val headFirstArg = element.head[0] val child = children.getOrElse(headFirstArg) { - children.retrieve { head -> head != null && head structurallyEquals headFirstArg } .singleOrNull() } @@ -32,7 +31,6 @@ internal data class ArityNode( } else -> children.getOrPut(null) { NoArgsNode() } - }.put(element, beforeOthers) override fun selectChildren(element: Rule) = when { diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/generic/set/NoArgsNode.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/generic/set/NoArgsNode.kt index a02ea3d23..8809e2d73 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/generic/set/NoArgsNode.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/collections/rete/generic/set/NoArgsNode.kt @@ -22,7 +22,9 @@ internal data class NoArgsNode(override val children: MutableMap): RetractResult = retract(clauses.asIterable()) -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/theory/RetractResult.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/theory/RetractResult.kt index 662919f37..c68457046 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/theory/RetractResult.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/theory/RetractResult.kt @@ -24,4 +24,4 @@ sealed class RetractResult { /** A failed "retract" operation result, carrying the unchanged [theory] */ data class Failure(override val theory: Theory) : RetractResult() -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/theory/Theory.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/theory/Theory.kt index 74789330c..20c13b582 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/theory/Theory.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/theory/Theory.kt @@ -1,6 +1,13 @@ package it.unibo.tuprolog.theory -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Clause +import it.unibo.tuprolog.core.Directive +import it.unibo.tuprolog.core.Fact +import it.unibo.tuprolog.core.Indicator +import it.unibo.tuprolog.core.Rule +import it.unibo.tuprolog.core.Scope +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.theory.impl.IndexedTheory import it.unibo.tuprolog.theory.impl.ListedTheory import kotlin.js.JsName @@ -174,9 +181,11 @@ interface Theory : Iterable { @JvmStatic @JsName("indexedOfScopes") fun indexedOf(vararg clauses: Scope.() -> Clause): Theory = - indexedOf(clauses.map { - Scope.empty(it) - }) + indexedOf( + clauses.map { + Scope.empty(it) + } + ) /** Creates a [Theory] backed by an indexed data structure, containing the given clauses */ @JvmStatic @@ -207,9 +216,11 @@ interface Theory : Iterable { @JvmStatic @JsName("listedOfScopes") fun listedOf(vararg clause: Scope.() -> Clause): Theory = - listedOf(clause.map { - Scope.empty(it) - }) + listedOf( + clause.map { + Scope.empty(it) + } + ) /** Creates a [Theory] backed by a list, containing the given clauses */ @JvmStatic diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/theory/TheoryUtils.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/theory/TheoryUtils.kt index 3e26465df..f28fcf607 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/theory/TheoryUtils.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/theory/TheoryUtils.kt @@ -9,7 +9,7 @@ internal object TheoryUtils { clause.also { require(clause.isWellFormed) { "ClauseDatabase can contain only well formed clauses: " + - "this isn't $clause" + "this isn't $clause" } } @@ -18,7 +18,7 @@ internal object TheoryUtils { clauses.also { require(clauses.all { it.isWellFormed }) { "ClauseDatabase can contain only well formed clauses: these aren't " + - "${clauses.filterNot { it.isWellFormed }.toList()}" + "${clauses.filterNot { it.isWellFormed }.toList()}" } } @@ -26,8 +26,7 @@ internal object TheoryUtils { clauses.also { require(clauses.all { it.isWellFormed }) { "ClauseDatabase can contain only well formed clauses: these aren't " + - "${clauses.filterNot { it.isWellFormed }.toList()}" + "${clauses.filterNot { it.isWellFormed }.toList()}" } } - -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/theory/impl/IndexedTheory.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/theory/impl/IndexedTheory.kt index 34695a813..b8af7f1ad 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/theory/impl/IndexedTheory.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/theory/impl/IndexedTheory.kt @@ -68,4 +68,4 @@ internal class IndexedTheory private constructor(private val queue: ClauseQueue) ) } } -} \ No newline at end of file +} diff --git a/theory/src/commonMain/kotlin/it/unibo/tuprolog/theory/impl/ListedTheory.kt b/theory/src/commonMain/kotlin/it/unibo/tuprolog/theory/impl/ListedTheory.kt index 24fb80080..4d6cd18b3 100644 --- a/theory/src/commonMain/kotlin/it/unibo/tuprolog/theory/impl/ListedTheory.kt +++ b/theory/src/commonMain/kotlin/it/unibo/tuprolog/theory/impl/ListedTheory.kt @@ -21,7 +21,6 @@ private constructor( checkClausesCorrect(clauses) } - override fun get(clause: Clause): Sequence = clauses.filter { it matches clause @@ -41,7 +40,8 @@ private constructor( RetractResult.Success( ListedTheory( newTheory - ), listOf(toBeActuallyRetracted) + ), + listOf(toBeActuallyRetracted) ) } } @@ -76,9 +76,10 @@ private constructor( RetractResult.Success( ListedTheory( newTheory - ), toBeActuallyRetracted + ), + toBeActuallyRetracted ) } } } -} \ No newline at end of file +} diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/PrototypeClauseCollectionTest.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/PrototypeClauseCollectionTest.kt index 2b7f76fe6..1115b5c1c 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/PrototypeClauseCollectionTest.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/PrototypeClauseCollectionTest.kt @@ -37,5 +37,4 @@ internal interface PrototypeClauseCollectionTest { fun retrievingPresentClauseWithRetrieveAllWorksCorrectly() fun retrievingAbsentClauseWithRetrieveAllDoesNotAlterCollection() - -} \ No newline at end of file +} diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/PrototypeClauseMultiSetTest.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/PrototypeClauseMultiSetTest.kt index a93894522..fb96766e2 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/PrototypeClauseMultiSetTest.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/PrototypeClauseMultiSetTest.kt @@ -26,7 +26,5 @@ internal interface PrototypeClauseMultiSetTest : PrototypeClauseCollectionTest { emptyGenerator, collectionGenerator ) - } - -} \ No newline at end of file +} diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/PrototypeClauseQueueTest.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/PrototypeClauseQueueTest.kt index cb68268c7..67692d2f6 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/PrototypeClauseQueueTest.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/PrototypeClauseQueueTest.kt @@ -39,4 +39,4 @@ internal interface PrototypeClauseQueueTest : PrototypeClauseCollectionTest { collectionGenerator ) } -} \ No newline at end of file +} diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/MutableReteClauseMultiSetTest.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/MutableReteClauseMultiSetTest.kt index ccff42d41..c9a5f2668 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/MutableReteClauseMultiSetTest.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/MutableReteClauseMultiSetTest.kt @@ -3,9 +3,8 @@ package it.unibo.tuprolog.collections.impl import it.unibo.tuprolog.collections.MutableClauseMultiSet import it.unibo.tuprolog.collections.PrototypeClauseMultiSetTest import kotlin.test.Test -import kotlin.test.todo -internal class MutableReteClauseMultiSetTest : PrototypeClauseMultiSetTest{ +internal class MutableReteClauseMultiSetTest : PrototypeClauseMultiSetTest { private val prototype = PrototypeClauseMultiSetTest.prototype( MutableClauseMultiSet.Companion::empty, @@ -131,4 +130,4 @@ internal class MutableReteClauseMultiSetTest : PrototypeClauseMultiSetTest{ override fun retractTakesUnificationIntoAccount() { prototype.retractTakesUnificationIntoAccount() } -} \ No newline at end of file +} diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/MutableReteClauseQueueTest.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/MutableReteClauseQueueTest.kt index e9795b339..2d8cc4470 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/MutableReteClauseQueueTest.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/MutableReteClauseQueueTest.kt @@ -160,4 +160,4 @@ internal class MutableReteClauseQueueTest : PrototypeClauseQueueTest { override fun retractTakesUnificationIntoAccount() { prototype.retractTakesUnificationIntoAccount() } -} \ No newline at end of file +} diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/ReteClauseMultiSetTest.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/ReteClauseMultiSetTest.kt index cae6df6f7..785be0d33 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/ReteClauseMultiSetTest.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/ReteClauseMultiSetTest.kt @@ -130,4 +130,4 @@ internal class ReteClauseMultiSetTest : PrototypeClauseMultiSetTest { override fun retractTakesUnificationIntoAccount() { prototype.retractTakesUnificationIntoAccount() } -} \ No newline at end of file +} diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/ReteClauseQueueTest.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/ReteClauseQueueTest.kt index 1c71a35ac..76c9a82af 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/ReteClauseQueueTest.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/impl/ReteClauseQueueTest.kt @@ -4,7 +4,7 @@ import it.unibo.tuprolog.collections.ClauseQueue import it.unibo.tuprolog.collections.PrototypeClauseQueueTest import kotlin.test.Test -internal class ReteClauseQueueTest : PrototypeClauseQueueTest{ +internal class ReteClauseQueueTest : PrototypeClauseQueueTest { private val prototype = PrototypeClauseQueueTest.prototype( ClauseQueue.Companion::empty, diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/prototypes/PrototypeClauseCollectionTestImpl.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/prototypes/PrototypeClauseCollectionTestImpl.kt index 9a46b9fa7..f388facda 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/prototypes/PrototypeClauseCollectionTestImpl.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/prototypes/PrototypeClauseCollectionTestImpl.kt @@ -3,7 +3,12 @@ package it.unibo.tuprolog.collections.prototypes import it.unibo.tuprolog.collections.ClauseCollection import it.unibo.tuprolog.collections.PrototypeClauseCollectionTest import it.unibo.tuprolog.collections.RetrieveResult -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Clause +import it.unibo.tuprolog.core.Fact +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.testutils.ClauseAssertionUtils.assertClausesHaveSameLengthAndContent import it.unibo.tuprolog.testutils.ClauseAssertionUtils.assertTermsAreEqual import it.unibo.tuprolog.testutils.TheoryUtils.deepClause @@ -230,5 +235,4 @@ internal abstract class PrototypeClauseCollectionTestImpl( assertClausesHaveSameLengthAndContent(clauses, retrieveResult.collection) } - -} \ No newline at end of file +} diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/prototypes/PrototypeClauseMultiSetTestImpl.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/prototypes/PrototypeClauseMultiSetTestImpl.kt index 8ab79655e..0c8c07bb4 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/prototypes/PrototypeClauseMultiSetTestImpl.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/prototypes/PrototypeClauseMultiSetTestImpl.kt @@ -1,15 +1,18 @@ package it.unibo.tuprolog.collections.prototypes -import it.unibo.tuprolog.collections.* +import it.unibo.tuprolog.collections.ClauseCollection +import it.unibo.tuprolog.collections.ClauseMultiSet import it.unibo.tuprolog.collections.PrototypeClauseMultiSetTest -import it.unibo.tuprolog.core.* -import it.unibo.tuprolog.testutils.ClauseAssertionUtils +import it.unibo.tuprolog.collections.RetrieveResult +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Clause +import it.unibo.tuprolog.core.Fact +import it.unibo.tuprolog.core.Struct import it.unibo.tuprolog.testutils.ClauseAssertionUtils.assertClausesHaveSameLengthAndContent import it.unibo.tuprolog.utils.permutations import kotlin.test.assertEquals -import kotlin.test.assertNotEquals -internal class PrototypeClauseMultiSetTestImpl ( +internal class PrototypeClauseMultiSetTestImpl( private val emptyGenerator: () -> ClauseMultiSet, private val collectionGenerator: (Iterable) -> ClauseMultiSet ) : PrototypeClauseMultiSetTest, @@ -35,7 +38,7 @@ internal class PrototypeClauseMultiSetTestImpl ( } override fun retractClauses(collection: ClauseCollection, query: Clause): Sequence { - return when(val res = (collection as ClauseMultiSet).retrieve(query)) { + return when (val res = (collection as ClauseMultiSet).retrieve(query)) { is RetrieveResult.Success -> res.clauses.asSequence() else -> emptySequence() } @@ -83,7 +86,6 @@ internal class PrototypeClauseMultiSetTestImpl ( } } - override fun hashCodeIsOrderIndependent() { val actualClauses = clauses + clauses[0] @@ -94,5 +96,4 @@ internal class PrototypeClauseMultiSetTestImpl ( permutations.map { collectionGenerator(it) }.toSet().size ) } - -} \ No newline at end of file +} diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/prototypes/PrototypeClauseQueueTestImpl.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/prototypes/PrototypeClauseQueueTestImpl.kt index 52878bc7b..243e75669 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/prototypes/PrototypeClauseQueueTestImpl.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/prototypes/PrototypeClauseQueueTestImpl.kt @@ -4,7 +4,12 @@ import it.unibo.tuprolog.collections.ClauseCollection import it.unibo.tuprolog.collections.ClauseQueue import it.unibo.tuprolog.collections.PrototypeClauseQueueTest import it.unibo.tuprolog.collections.RetrieveResult -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Clause +import it.unibo.tuprolog.core.Fact +import it.unibo.tuprolog.core.Numeric +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.testutils.ClauseAssertionUtils.assertClausesHaveSameLengthAndContent import it.unibo.tuprolog.testutils.ClauseAssertionUtils.assertTermsAreEqual import it.unibo.tuprolog.utils.permutations @@ -67,7 +72,7 @@ internal class PrototypeClauseQueueTestImpl( } override fun retractClauses(collection: ClauseCollection, query: Clause): Sequence { - return when(val res = (collection as ClauseQueue).retrieve(query)) { + return when (val res = (collection as ClauseQueue).retrieve(query)) { is RetrieveResult.Success -> res.clauses.asSequence() else -> emptySequence() } @@ -173,4 +178,4 @@ internal class PrototypeClauseQueueTestImpl( permutations.map { collectionGenerator(it) }.toSet().size ) } -} \ No newline at end of file +} diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/custom/OrderedReteTreeTest.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/custom/OrderedReteTreeTest.kt index 029453610..f5005c6ff 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/custom/OrderedReteTreeTest.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/custom/OrderedReteTreeTest.kt @@ -9,7 +9,11 @@ import it.unibo.tuprolog.collections.rete.custom.ReteTreeAssertionUtils.assertPa import it.unibo.tuprolog.collections.rete.custom.ReteTreeAssertionUtils.defaultClauses import it.unibo.tuprolog.collections.rete.custom.ReteTreeAssertionUtils.factsAndRules import it.unibo.tuprolog.collections.rete.custom.ReteTreeAssertionUtils.factsAndRulesFamilies -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Clause +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Rule +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Var import kotlin.test.Test import kotlin.test.assertEquals @@ -502,7 +506,6 @@ class OrderedReteTreeTest { .filter { (_, arity) -> arity > 0 } .toSet() - for ((functor, arity) in families) { for (args in groundTerms.allChunksOfSize(arity)) { for (i in 0 until arity) { @@ -564,4 +567,4 @@ class OrderedReteTreeTest { } } } -} \ No newline at end of file +} diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/custom/ReteTreeAssertionUtils.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/custom/ReteTreeAssertionUtils.kt index c779c4241..abbf33b68 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/custom/ReteTreeAssertionUtils.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/custom/ReteTreeAssertionUtils.kt @@ -1,6 +1,17 @@ package it.unibo.tuprolog.collections.rete.custom -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Directive +import it.unibo.tuprolog.core.Empty +import it.unibo.tuprolog.core.Fact +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Real +import it.unibo.tuprolog.core.Rule +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 it.unibo.tuprolog.unify.Unificator.Companion.matches import it.unibo.tuprolog.utils.interleave import it.unibo.tuprolog.utils.interleaveSequences @@ -509,4 +520,4 @@ internal object ReteTreeAssertionUtils { Rule.template("n", 2) to n2FactsAndRules, Rule.template("o", 2) to o2FactsAndRules ) -} \ No newline at end of file +} diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/custom/UnorderedReteTreeTest.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/custom/UnorderedReteTreeTest.kt index e5f987650..ae2320e97 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/custom/UnorderedReteTreeTest.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/custom/UnorderedReteTreeTest.kt @@ -11,7 +11,11 @@ import it.unibo.tuprolog.collections.rete.custom.ReteTreeAssertionUtils.assertSu import it.unibo.tuprolog.collections.rete.custom.ReteTreeAssertionUtils.defaultClauses import it.unibo.tuprolog.collections.rete.custom.ReteTreeAssertionUtils.factsAndRules import it.unibo.tuprolog.collections.rete.custom.ReteTreeAssertionUtils.factsAndRulesFamilies -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Clause +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Rule +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Var import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertTrue @@ -449,7 +453,6 @@ class UnorderedReteTreeTest { for ((functor, arity) in families) { for (args in groundTerms.allChunksOfSize(arity)) { - val head = Struct.of(functor, args) val template = Rule.of(head, Var.anonymous()) @@ -520,7 +523,6 @@ class UnorderedReteTreeTest { .filter { (_, arity) -> arity > 0 } .toSet() - for ((functor, arity) in families) { for (args in groundTerms.allChunksOfSize(arity)) { for (i in 0 until arity) { @@ -584,4 +586,4 @@ class UnorderedReteTreeTest { } } } -} \ No newline at end of file +} diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/nodes/set/ArgNodeTest.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/nodes/set/ArgNodeTest.kt index 166cc193e..d2f00e0eb 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/nodes/set/ArgNodeTest.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/nodes/set/ArgNodeTest.kt @@ -2,7 +2,11 @@ package it.unibo.tuprolog.collections.rete.nodes.set import it.unibo.tuprolog.collections.rete.generic.set.ArgNode import it.unibo.tuprolog.collections.rete.generic.set.RuleNode -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Empty +import it.unibo.tuprolog.core.Fact +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.testutils.ReteNodeUtils.assertNoChangesInReteNode import it.unibo.tuprolog.testutils.ReteNodeUtils.assertRemovedFromReteNodeRespectingPartialOrder import it.unibo.tuprolog.testutils.ReteNodeUtils.assertReteNodeClausesCorrect @@ -101,7 +105,9 @@ internal class ArgNodeTest { mutableListOf( noArgsHeadedRule ) - ), it.children[null]) + ), + it.children[null] + ) } } diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/nodes/set/ArityNodeTest.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/nodes/set/ArityNodeTest.kt index d71d6b64d..c553fb25e 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/nodes/set/ArityNodeTest.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/nodes/set/ArityNodeTest.kt @@ -1,7 +1,12 @@ package it.unibo.tuprolog.collections.rete.nodes.set import it.unibo.tuprolog.collections.rete.generic.set.ArityNode -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Empty +import it.unibo.tuprolog.core.Fact +import it.unibo.tuprolog.core.Rule +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.testutils.ReteNodeUtils import it.unibo.tuprolog.testutils.ReteNodeUtils.assertClauseHeadPartialOrderingRespected import it.unibo.tuprolog.testutils.ReteNodeUtils.assertCorrectAndPartialOrderRespected @@ -9,7 +14,12 @@ import it.unibo.tuprolog.testutils.ReteNodeUtils.assertNoChangesInReteNode import it.unibo.tuprolog.testutils.ReteNodeUtils.assertRemovedFromReteNodeRespectingPartialOrder import it.unibo.tuprolog.testutils.ReteNodeUtils.assertReteNodeClausesCorrect import it.unibo.tuprolog.testutils.ReteNodeUtils.assertReteNodeEmpty -import kotlin.test.* +import kotlin.test.BeforeTest +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith +import kotlin.test.assertSame +import kotlin.test.assertTrue /** * Test class for [ArityNode] @@ -202,5 +212,4 @@ internal class ArityNodeTest { assertSame(it.indexedElements.single(), independentCopy.indexedElements.single()) } } - } diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/nodes/set/DirectiveNodeTest.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/nodes/set/DirectiveNodeTest.kt index c518ec82e..b562ed2e1 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/nodes/set/DirectiveNodeTest.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/nodes/set/DirectiveNodeTest.kt @@ -9,7 +9,11 @@ import it.unibo.tuprolog.testutils.ReteNodeUtils.assertNoChangesInReteNode import it.unibo.tuprolog.testutils.ReteNodeUtils.assertRemovedFromReteNode import it.unibo.tuprolog.testutils.ReteNodeUtils.assertReteNodeClausesCorrect import it.unibo.tuprolog.testutils.ReteNodeUtils.assertReteNodeEmpty -import kotlin.test.* +import kotlin.test.BeforeTest +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertSame +import kotlin.test.assertTrue /** * Test class for [DirectiveNode] @@ -134,5 +138,4 @@ internal class DirectiveNodeTest { assertSame(emptyDirectiveNode.indexedElements.single(), independentCopy.indexedElements.single()) } - } diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/nodes/set/FunctorNodeTest.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/nodes/set/FunctorNodeTest.kt index 38f010cb5..a83a2736d 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/nodes/set/FunctorNodeTest.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/nodes/set/FunctorNodeTest.kt @@ -11,7 +11,11 @@ import it.unibo.tuprolog.testutils.ReteNodeUtils.assertNoChangesInReteNode import it.unibo.tuprolog.testutils.ReteNodeUtils.assertRemovedFromReteNodeRespectingPartialOrder import it.unibo.tuprolog.testutils.ReteNodeUtils.assertReteNodeClausesCorrect import it.unibo.tuprolog.testutils.ReteNodeUtils.assertReteNodeEmpty -import kotlin.test.* +import kotlin.test.BeforeTest +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertSame +import kotlin.test.assertTrue /** * Test class for [FunctorNode] diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/nodes/set/NoArgsNodeTest.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/nodes/set/NoArgsNodeTest.kt index 2dabf4601..cfd11692c 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/nodes/set/NoArgsNodeTest.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/nodes/set/NoArgsNodeTest.kt @@ -1,7 +1,11 @@ package it.unibo.tuprolog.collections.rete.nodes.set import it.unibo.tuprolog.collections.rete.generic.set.NoArgsNode -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Fact +import it.unibo.tuprolog.core.Rule +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.testutils.ReteNodeUtils import it.unibo.tuprolog.testutils.ReteNodeUtils.assertNoChangesInReteNode import it.unibo.tuprolog.testutils.ReteNodeUtils.assertRemovedFromReteNode @@ -140,5 +144,4 @@ internal class NoArgsNodeTest { assertSame(emptyNoArgsNode.indexedElements.single(), independentCopy.indexedElements.single()) } - } diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/nodes/set/RootNodeTest.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/nodes/set/RootNodeTest.kt index e0c108648..17733395d 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/nodes/set/RootNodeTest.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/nodes/set/RootNodeTest.kt @@ -2,14 +2,22 @@ package it.unibo.tuprolog.collections.rete.nodes.set import it.unibo.tuprolog.collections.rete.generic.ReteNode import it.unibo.tuprolog.collections.rete.generic.set.RootNode -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Directive +import it.unibo.tuprolog.core.Rule +import it.unibo.tuprolog.core.Truth +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.testutils.ReteNodeUtils import it.unibo.tuprolog.testutils.ReteNodeUtils.assertCorrectAndPartialOrderRespected import it.unibo.tuprolog.testutils.ReteNodeUtils.assertNoChangesInReteNode import it.unibo.tuprolog.testutils.ReteNodeUtils.assertRemovedFromReteNodeRespectingPartialOrder import it.unibo.tuprolog.testutils.ReteNodeUtils.assertReteNodeClausesCorrect import it.unibo.tuprolog.testutils.ReteNodeUtils.assertReteNodeEmpty -import kotlin.test.* +import kotlin.test.BeforeTest +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertSame +import kotlin.test.assertTrue /** * Test class for [RootNode] @@ -78,10 +86,12 @@ internal class RootNodeTest { filledRootNode.put(aDirective, true) filledRootNode.put(aRule, true) - assertCorrectAndPartialOrderRespected(filledRootNode, + assertCorrectAndPartialOrderRespected( + filledRootNode, ReteNodeUtils.mixedClauses.toMutableList().apply { addAll(0, listOf(aRule, aDirective)) - }) + } + ) } @Test @@ -174,5 +184,4 @@ internal class RootNodeTest { assertEquals(correctInstances, toBeTested) } - } diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/nodes/set/RuleNodeTest.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/nodes/set/RuleNodeTest.kt index 193e45272..bbf189668 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/nodes/set/RuleNodeTest.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/collections/rete/nodes/set/RuleNodeTest.kt @@ -9,7 +9,11 @@ import it.unibo.tuprolog.testutils.ReteNodeUtils.assertNoChangesInReteNode import it.unibo.tuprolog.testutils.ReteNodeUtils.assertRemovedFromReteNode import it.unibo.tuprolog.testutils.ReteNodeUtils.assertReteNodeClausesCorrect import it.unibo.tuprolog.testutils.ReteNodeUtils.assertReteNodeEmpty -import kotlin.test.* +import kotlin.test.BeforeTest +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertSame +import kotlin.test.assertTrue /** * Test class for [RuleNode] diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/testutils/ClauseAssertionUtils.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/testutils/ClauseAssertionUtils.kt index f0ab778a2..e94186e0f 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/testutils/ClauseAssertionUtils.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/testutils/ClauseAssertionUtils.kt @@ -1,6 +1,10 @@ package it.unibo.tuprolog.testutils -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Clause +import it.unibo.tuprolog.core.Constant +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.Var import kotlin.test.assertEquals internal object ClauseAssertionUtils { @@ -27,7 +31,7 @@ internal object ClauseAssertionUtils { expected, actual, message = - """Comparing: + """Comparing: | actual: $actual | type: ${actual::class} | expected: $expected @@ -56,5 +60,4 @@ internal object ClauseAssertionUtils { ) } } - -} \ No newline at end of file +} diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/testutils/ReteNodeUtils.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/testutils/ReteNodeUtils.kt index 89c96d5c3..95c9ce41b 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/testutils/ReteNodeUtils.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/testutils/ReteNodeUtils.kt @@ -1,7 +1,17 @@ package it.unibo.tuprolog.testutils -import it.unibo.tuprolog.core.* import it.unibo.tuprolog.collections.rete.generic.ReteNode +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Clause +import it.unibo.tuprolog.core.Directive +import it.unibo.tuprolog.core.Empty +import it.unibo.tuprolog.core.Fact +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Rule +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Truth +import it.unibo.tuprolog.core.Tuple +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.unify.Unificator.Companion.matches import kotlin.math.min import kotlin.test.assertEquals @@ -130,7 +140,7 @@ internal object ReteNodeUtils { ) { val beforeContents = reteNode.indexedElements.toList() - @Suppress("UNCHECKED_CAST") // nothing will be inserted, so it's safe + @Suppress("UNCHECKED_CAST") // nothing will be inserted, so it's safe val idempotentActionResult = (reteNode as ReteNode<*, Clause>).idempotentAction() assertTrue(idempotentActionResult.none()) @@ -147,7 +157,7 @@ internal object ReteNodeUtils { val allClauseCount = allClauses.count() val remainingClausesExpected = allClauses - removedExpected - @Suppress("UNCHECKED_CAST") // nothing will be inserted, so it's safe + @Suppress("UNCHECKED_CAST") // nothing will be inserted, so it's safe val removedActual = (reteNode as ReteNode<*, Clause>).removeAction() assertEquals(removedExpected, removedActual.toList()) @@ -198,7 +208,8 @@ internal object ReteNodeUtils { } assertTrue(actualClauses.toList().containsAll(expectedClauses.toList())) - actualClauses.forEachStructurallyEqualsHead(partialOrderingHeadClauseMap(expectedClauses).toMutableMap(), + actualClauses.forEachStructurallyEqualsHead( + partialOrderingHeadClauseMap(expectedClauses).toMutableMap(), onPresentEntry = { clause, entry -> when { entry.value.none() -> fail("Clause $clause not indexed under its head Struct") @@ -220,13 +231,13 @@ internal object ReteNodeUtils { * constructing the overall partial ordering */ private fun partialOrderingHeadClauseMap(clauses: Iterable): Map> = mutableMapOf>().also { resultMap -> - clauses.forEachStructurallyEqualsHead(resultMap, + clauses.forEachStructurallyEqualsHead( + resultMap, onPresentEntry = { clause, entry -> entry.setValue(entry.value + clause) }, onMissingEntry = { clause, map -> map[clause.head] = mutableListOf(clause) } ) }.toMap() - /** Utility function to iterate over clauses with partial ordering map, doing actions on found or missing entry */ private inline fun Iterable.forEachStructurallyEqualsHead( partialOrderingMap: MutableMap>, diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/testutils/TheoryUtils.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/testutils/TheoryUtils.kt index 01fed9977..ef2a7b3b2 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/testutils/TheoryUtils.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/testutils/TheoryUtils.kt @@ -1,6 +1,17 @@ package it.unibo.tuprolog.testutils -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Clause +import it.unibo.tuprolog.core.Directive +import it.unibo.tuprolog.core.Fact +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.Var import it.unibo.tuprolog.theory.Theory import it.unibo.tuprolog.core.List as LogicList diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/PrototypeProperIndexingTest.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/PrototypeProperIndexingTest.kt index 99c1f457e..082593e0b 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/PrototypeProperIndexingTest.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/PrototypeProperIndexingTest.kt @@ -1,11 +1,15 @@ package it.unibo.tuprolog.theory -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Clause +import it.unibo.tuprolog.core.Fact +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Numeric +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.testutils.ClauseAssertionUtils.assertClausesHaveSameLengthAndContent import it.unibo.tuprolog.testutils.ClauseAssertionUtils.assertTermsAreEqual import it.unibo.tuprolog.unify.Unificator.Companion.matches -import kotlin.test.assertEquals - class PrototypeProperIndexingTest( private val theoryGenerator: (Iterable) -> Theory @@ -96,7 +100,8 @@ class PrototypeProperIndexingTest( Struct.of( "f", Struct.of("f", Integer.of(1)), - Integer.of(2)), + Integer.of(2) + ), Integer.of(3) ) ) @@ -284,6 +289,4 @@ class PrototypeProperIndexingTest( assertTermsAreEqual(newF2MixedClause, generatedIndexingAfterAssertionA.asReversed().first()) assertClausesHaveSameLengthAndContent(expectedIndexingOverF2 + listOf(newF2MixedClause), generatedIndexingAfterAssertionA) } - - -} \ No newline at end of file +} diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/PrototypeTheoryCreationTest.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/PrototypeTheoryCreationTest.kt index 4abee6c94..8b9c9b8ec 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/PrototypeTheoryCreationTest.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/PrototypeTheoryCreationTest.kt @@ -54,5 +54,4 @@ internal class PrototypeTheoryCreationTest( assertEquals(correctInstance, toBeTested) } - } diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/PrototypeTheoryTest.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/PrototypeTheoryTest.kt index c3061cd5e..a5c3a63e9 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/PrototypeTheoryTest.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/PrototypeTheoryTest.kt @@ -1,6 +1,12 @@ package it.unibo.tuprolog.theory -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Clause +import it.unibo.tuprolog.core.Directive +import it.unibo.tuprolog.core.Fact +import it.unibo.tuprolog.core.Indicator +import it.unibo.tuprolog.core.Rule +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.testutils.ClauseAssertionUtils.assertClausesHaveSameLengthAndContent import it.unibo.tuprolog.testutils.ReteNodeUtils.assertClauseHeadPartialOrderingRespected import it.unibo.tuprolog.testutils.TheoryUtils @@ -9,7 +15,12 @@ import it.unibo.tuprolog.testutils.TheoryUtils.deepQueries import it.unibo.tuprolog.testutils.TheoryUtils.memberClause import it.unibo.tuprolog.testutils.TheoryUtils.negativeMemberQueries import it.unibo.tuprolog.testutils.TheoryUtils.positiveMemberQueries -import kotlin.test.* +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith +import kotlin.test.assertFalse +import kotlin.test.assertNotSame +import kotlin.test.assertSame +import kotlin.test.assertTrue /** * Test class for all [Theory] subtypes @@ -374,7 +385,6 @@ class PrototypeTheoryTest( } fun retractTakesUnificationIntoAccount() { - for (query in positiveMemberQueries) { var theory = theoryGenerator(memberClause) assertClausesHaveSameLengthAndContent( diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/impl/IndexedClauseIndexingTest.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/impl/IndexedClauseIndexingTest.kt index b9cd80acb..ceced6ff6 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/impl/IndexedClauseIndexingTest.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/impl/IndexedClauseIndexingTest.kt @@ -13,7 +13,6 @@ internal class IndexedClauseIndexingTest { @BeforeTest fun init() { - } @Test @@ -110,5 +109,4 @@ internal class IndexedClauseIndexingTest { fun correctIndexingAfterTwoArityMixedClauseAssertionZ() { prototype.correctIndexingAfterTwoArityMixedClauseAssertionZ() } - -} \ No newline at end of file +} diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/impl/IndexedTheoryTest.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/impl/IndexedTheoryTest.kt index f2d938abf..3b8c58a6a 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/impl/IndexedTheoryTest.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/impl/IndexedTheoryTest.kt @@ -246,4 +246,4 @@ internal class IndexedTheoryTest { fun nestedRetractWorksAtSeveralDepthLevels() { prototype.nestedRetractWorksAtSeveralDepthLevels() } -} \ No newline at end of file +} diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/impl/ListedClauseIndexingTest.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/impl/ListedClauseIndexingTest.kt index 80bd6a527..fd556473f 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/impl/ListedClauseIndexingTest.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/impl/ListedClauseIndexingTest.kt @@ -104,5 +104,4 @@ internal class ListedClauseIndexingTest { fun correctIndexingAfterTwoArityMixedClauseAssertionZ() { prototype.correctIndexingAfterTwoArityMixedClauseAssertionZ() } - -} \ No newline at end of file +} diff --git a/theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/impl/ListedTheoryTest.kt b/theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/impl/ListedTheoryTest.kt index eb8a34d75..6bcc35afa 100644 --- a/theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/impl/ListedTheoryTest.kt +++ b/theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/impl/ListedTheoryTest.kt @@ -246,4 +246,4 @@ internal class ListedTheoryTest { fun nestedRetractWorksAtSeveralDepthLevels() { prototype.nestedRetractWorksAtSeveralDepthLevels() } -} \ No newline at end of file +} From 7959b0439cf533208cae0ebef2d8e6baf154f475 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 14 Sep 2020 14:57:52 +0200 Subject: [PATCH 09/34] format code in :solve --- .../unibo/tuprolog/solve/ExecutionContext.kt | 2 +- .../tuprolog/solve/ExecutionContextAware.kt | 2 +- .../it/unibo/tuprolog/solve/Extensions.kt | 2 +- .../it/unibo/tuprolog/solve/InputStore.kt | 2 +- .../it/unibo/tuprolog/solve/OutputStore.kt | 2 +- .../it/unibo/tuprolog/solve/SideEffect.kt | 126 ++++++------------ .../unibo/tuprolog/solve/SideEffectFactory.kt | 2 +- .../unibo/tuprolog/solve/SideEffectManager.kt | 1 - .../tuprolog/solve/SideEffectsBuilder.kt | 2 +- .../it/unibo/tuprolog/solve/Signature.kt | 64 +++++---- .../it/unibo/tuprolog/solve/Solution.kt | 10 +- .../kotlin/it/unibo/tuprolog/solve/Solver.kt | 1 - .../it/unibo/tuprolog/solve/SolverFactory.kt | 11 +- .../kotlin/it/unibo/tuprolog/solve/Time.kt | 1 + .../kotlin/it/unibo/tuprolog/solve/Utils.kt | 3 +- .../unibo/tuprolog/solve/channel/Channel.kt | 3 +- .../unibo/tuprolog/solve/channel/Channels.kt | 2 +- .../tuprolog/solve/channel/InputChannel.kt | 2 +- .../unibo/tuprolog/solve/channel/Listener.kt | 2 +- .../tuprolog/solve/channel/OutputChannel.kt | 2 +- .../solve/channel/impl/AbstractChannel.kt | 3 +- .../channel/impl/AbstractInputChannel.kt | 2 +- .../channel/impl/AbstractOutputChannel.kt | 2 +- .../channel/impl/InputChannelFromFunction.kt | 2 +- .../channel/impl/OutputChannelFromFunction.kt | 2 +- .../tuprolog/solve/exception/HaltException.kt | 4 +- .../tuprolog/solve/exception/PrologError.kt | 24 +++- .../tuprolog/solve/exception/PrologWarning.kt | 2 +- .../solve/exception/TimeOutException.kt | 4 +- .../exception/TuPrologRuntimeException.kt | 4 +- .../solve/exception/error/DomainError.kt | 6 +- .../solve/exception/error/ErrorUtils.kt | 1 - .../solve/exception/error/EvaluationError.kt | 15 ++- .../solve/exception/error/ExistenceError.kt | 6 +- .../exception/error/InstantiationError.kt | 4 +- .../solve/exception/error/MessageError.kt | 3 +- .../solve/exception/error/PermissionError.kt | 4 +- .../exception/error/RepresentationError.kt | 2 +- .../solve/exception/error/SystemError.kt | 3 +- .../solve/exception/error/TypeError.kt | 11 +- .../exception/warning/MissingPredicate.kt | 2 +- .../tuprolog/solve/flags/DoubleQuotes.kt | 3 +- .../it/unibo/tuprolog/solve/flags/MaxArity.kt | 5 +- .../unibo/tuprolog/solve/flags/NotableFlag.kt | 12 +- .../it/unibo/tuprolog/solve/flags/Unknown.kt | 3 +- .../solve/function/AbstractEvaluator.kt | 7 +- .../solve/function/ArithmeticEvaluator.kt | 14 +- .../solve/function/ArithmeticUtils.kt | 4 +- .../solve/function/BinaryMathFunction.kt | 1 - .../unibo/tuprolog/solve/function/Compute.kt | 7 +- .../solve/function/ExpressionEvaluator.kt | 1 - .../solve/function/ExpressionReducer.kt | 3 - .../solve/function/FunctionWrapper.kt | 1 - .../tuprolog/solve/function/MathFunction.kt | 1 - .../solve/impl/SideEffectsBuilderImpl.kt | 2 +- .../unibo/tuprolog/solve/library/Libraries.kt | 5 +- .../unibo/tuprolog/solve/library/Library.kt | 2 +- .../tuprolog/solve/library/LibraryGroup.kt | 1 - .../AlreadyLoadedLibraryException.kt | 1 - .../exception/NoSuchALibraryException.kt | 2 +- .../solve/primitive/ArithmeticRelation.kt | 1 - .../solve/primitive/BinaryRelation.kt | 1 - .../solve/primitive/PrimitiveWrapper.kt | 25 +++- .../unibo/tuprolog/solve/primitive/Solve.kt | 16 ++- .../tuprolog/solve/primitive/TypeEnsurer.kt | 2 +- .../tuprolog/solve/primitive/TypeTester.kt | 2 +- .../solve/primitive/UnaryPredicate.kt | 2 - .../solve/primitive/ZeroaryPredicate.kt | 2 +- .../unibo/tuprolog/solve/rule/RuleWrapper.kt | 5 +- .../tuprolog/solve/stdlib/CommonBuiltins.kt | 101 ++------------ .../tuprolog/solve/stdlib/CommonFunctions.kt | 71 ++++++++++ .../tuprolog/solve/stdlib/CommonPrimitives.kt | 115 ++++++++++++++++ .../tuprolog/solve/stdlib/CommonRules.kt | 9 +- .../solve/stdlib/function/AbsoluteValue.kt | 1 - .../solve/stdlib/function/BitwiseAnd.kt | 2 +- .../solve/stdlib/function/BitwiseLeftShift.kt | 1 - .../solve/stdlib/function/Exponentiation.kt | 1 - .../stdlib/function/FloatingPointDivision.kt | 2 - .../solve/stdlib/function/IntegerDivision.kt | 1 - .../solve/stdlib/function/Multiplication.kt | 1 - .../tuprolog/solve/stdlib/magic/MagicCut.kt | 8 +- .../tuprolog/solve/stdlib/magic/MagicTerm.kt | 2 +- .../solve/stdlib/primitive/Abolish.kt | 10 +- .../solve/stdlib/primitive/AbstractAssert.kt | 12 +- .../tuprolog/solve/stdlib/primitive/Arg.kt | 10 +- .../tuprolog/solve/stdlib/primitive/Assert.kt | 2 +- .../solve/stdlib/primitive/AssertA.kt | 2 +- .../solve/stdlib/primitive/AssertZ.kt | 2 +- .../tuprolog/solve/stdlib/primitive/Atom.kt | 2 +- .../solve/stdlib/primitive/AtomChars.kt | 2 +- .../tuprolog/solve/stdlib/primitive/Atomic.kt | 2 +- .../solve/stdlib/primitive/Between.kt | 3 +- .../solve/stdlib/primitive/Callable.kt | 2 +- .../tuprolog/solve/stdlib/primitive/Clause.kt | 3 +- .../solve/stdlib/primitive/Compound.kt | 2 +- .../solve/stdlib/primitive/CopyTerm.kt | 3 +- .../solve/stdlib/primitive/CurrentOp.kt | 2 +- .../stdlib/primitive/CurrentPrologFlag.kt | 2 +- .../stdlib/primitive/EnsureExecutable.kt | 3 +- .../solve/stdlib/primitive/FindAll.kt | 2 +- .../tuprolog/solve/stdlib/primitive/Float.kt | 2 +- .../solve/stdlib/primitive/Functor.kt | 11 +- .../tuprolog/solve/stdlib/primitive/Ground.kt | 2 +- .../tuprolog/solve/stdlib/primitive/Halt.kt | 2 +- .../solve/stdlib/primitive/Integer.kt | 2 +- .../tuprolog/solve/stdlib/primitive/Is.kt | 4 +- .../solve/stdlib/primitive/Natural.kt | 3 +- .../solve/stdlib/primitive/NewLine.kt | 4 +- .../tuprolog/solve/stdlib/primitive/NonVar.kt | 2 +- .../stdlib/primitive/NotUnifiableWith.kt | 2 +- .../tuprolog/solve/stdlib/primitive/Number.kt | 2 +- .../tuprolog/solve/stdlib/primitive/Op.kt | 2 +- .../tuprolog/solve/stdlib/primitive/Repeat.kt | 2 +- .../solve/stdlib/primitive/Retract.kt | 12 +- .../solve/stdlib/primitive/RetractAll.kt | 9 +- .../tuprolog/solve/stdlib/primitive/Sleep.kt | 9 +- .../solve/stdlib/primitive/TermGreaterThan.kt | 2 +- .../primitive/TermGreaterThanOrEqualTo.kt | 2 +- .../solve/stdlib/primitive/TermIdentical.kt | 2 +- .../solve/stdlib/primitive/TermLowerThan.kt | 2 +- .../primitive/TermLowerThanOrEqualTo.kt | 2 +- .../stdlib/primitive/TermNotIdentical.kt | 2 +- .../solve/stdlib/primitive/TermNotSame.kt | 2 +- .../solve/stdlib/primitive/TermSame.kt | 2 +- .../solve/stdlib/primitive/UnifiesWith.kt | 2 +- .../tuprolog/solve/stdlib/primitive/Univ.kt | 6 +- .../tuprolog/solve/stdlib/primitive/Var.kt | 2 +- .../tuprolog/solve/stdlib/primitive/Write.kt | 2 +- .../tuprolog/solve/stdlib/rule/Append.kt | 2 +- .../unibo/tuprolog/solve/stdlib/rule/Arrow.kt | 3 +- .../tuprolog/solve/stdlib/rule/Member.kt | 2 +- .../unibo/tuprolog/solve/stdlib/rule/Not.kt | 2 +- .../unibo/tuprolog/solve/stdlib/rule/Once.kt | 2 +- .../tuprolog/solve/stdlib/rule/Semicolon.kt | 4 +- .../unibo/tuprolog/solve/channel/Channels.kt | 2 +- .../unibo/tuprolog/solve/channel/Channels.kt | 2 +- .../solve/channel/InputStreamChannel.kt | 4 +- 137 files changed, 537 insertions(+), 444 deletions(-) create mode 100644 solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/CommonFunctions.kt create mode 100644 solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/CommonPrimitives.kt diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/ExecutionContext.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/ExecutionContext.kt index 3e8a364ca..28ea15fdd 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/ExecutionContext.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/ExecutionContext.kt @@ -159,4 +159,4 @@ interface ExecutionContext : ExecutionContextAware { inputChannels: InputStore<*> = this.inputChannels, outputChannels: OutputStore<*> = this.outputChannels ): ExecutionContext -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/ExecutionContextAware.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/ExecutionContextAware.kt index 58102b81a..30eb6d782 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/ExecutionContextAware.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/ExecutionContextAware.kt @@ -104,4 +104,4 @@ interface ExecutionContextAware { get() { return outputChannels[WARNINGS].castOrNull() } -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Extensions.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Extensions.kt index 6808cf839..a9801c1ce 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Extensions.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Extensions.kt @@ -1,4 +1,5 @@ @file:JvmName("Extensions") + package it.unibo.tuprolog.solve import it.unibo.tuprolog.core.Scope @@ -16,4 +17,3 @@ fun Solver.solve( maxDuration: TimeDuration = TimeDuration.MAX_VALUE, scopedContext: Scope.() -> Struct ): Sequence = solve(scopedContext(Scope.empty()), maxDuration) - diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/InputStore.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/InputStore.kt index 1020fc857..60f2919bd 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/InputStore.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/InputStore.kt @@ -2,4 +2,4 @@ package it.unibo.tuprolog.solve import it.unibo.tuprolog.solve.channel.InputChannel -typealias InputStore = Map> \ No newline at end of file +typealias InputStore = Map> diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/OutputStore.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/OutputStore.kt index 93c03367f..8df6c7d31 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/OutputStore.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/OutputStore.kt @@ -2,4 +2,4 @@ package it.unibo.tuprolog.solve import it.unibo.tuprolog.solve.channel.OutputChannel -typealias OutputStore = Map> \ No newline at end of file +typealias OutputStore = Map> diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/SideEffect.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/SideEffect.kt index 8973e8d36..8b70e3602 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/SideEffect.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/SideEffect.kt @@ -14,11 +14,9 @@ import it.unibo.tuprolog.theory.Theory sealed class SideEffect { data class ResetStaticKb(val clauses: Iterable) : SideEffect() { - constructor(vararg clauses: Clause) - : this(listOf(*clauses)) + constructor(vararg clauses: Clause) : this(listOf(*clauses)) - constructor(clauses: Sequence) - : this(clauses.asIterable()) + constructor(clauses: Sequence) : this(clauses.asIterable()) val theory by lazy { if (clauses is Theory) { @@ -30,27 +28,21 @@ sealed class SideEffect { } data class AddStaticClauses(val clauses: Iterable, val onTop: Boolean = false) : SideEffect() { - constructor(vararg clauses: Clause, onTop: Boolean = false) - : this(listOf(*clauses), onTop) + constructor(vararg clauses: Clause, onTop: Boolean = false) : this(listOf(*clauses), onTop) - constructor(clauses: Sequence, onTop: Boolean = false) - : this(clauses.asIterable(), onTop) + constructor(clauses: Sequence, onTop: Boolean = false) : this(clauses.asIterable(), onTop) } data class RemoveStaticClauses(val clauses: Iterable) : SideEffect() { - constructor(vararg clauses: Clause) - : this(listOf(*clauses)) + constructor(vararg clauses: Clause) : this(listOf(*clauses)) - constructor(clauses: Sequence) - : this(clauses.asIterable()) + constructor(clauses: Sequence) : this(clauses.asIterable()) } data class ResetDynamicKb(val clauses: Iterable) : SideEffect() { - constructor(vararg clauses: Clause) - : this(listOf(*clauses)) + constructor(vararg clauses: Clause) : this(listOf(*clauses)) - constructor(clauses: Sequence) - : this(clauses.asIterable()) + constructor(clauses: Sequence) : this(clauses.asIterable()) val theory by lazy { if (clauses is Theory) { @@ -62,49 +54,37 @@ sealed class SideEffect { } data class AddDynamicClauses(val clauses: Iterable, val onTop: Boolean = false) : SideEffect() { - constructor(vararg clauses: Clause, onTop: Boolean = false) - : this(listOf(*clauses), onTop) + constructor(vararg clauses: Clause, onTop: Boolean = false) : this(listOf(*clauses), onTop) - constructor(clauses: Sequence, onTop: Boolean = false) - : this(clauses.asIterable(), onTop) + constructor(clauses: Sequence, onTop: Boolean = false) : this(clauses.asIterable(), onTop) } data class RemoveDynamicClauses(val clauses: Iterable) : SideEffect() { - constructor(vararg clauses: Clause) - : this(listOf(*clauses)) + constructor(vararg clauses: Clause) : this(listOf(*clauses)) - constructor(clauses: Sequence) - : this(clauses.asIterable()) + constructor(clauses: Sequence) : this(clauses.asIterable()) } data class SetFlags(val flags: Map) : SideEffect() { - constructor(vararg flags: Pair) - : this(listOf(*flags)) + constructor(vararg flags: Pair) : this(listOf(*flags)) - constructor(flags: Iterable>) - : this(flags.toMap()) + constructor(flags: Iterable>) : this(flags.toMap()) - constructor(flags: Sequence>) - : this(flags.toMap()) + constructor(flags: Sequence>) : this(flags.toMap()) } data class ResetFlags(val flags: Map) : SideEffect() { - constructor(vararg flags: Pair) - : this(listOf(*flags)) + constructor(vararg flags: Pair) : this(listOf(*flags)) - constructor(flags: Iterable>) - : this(flags.toMap()) + constructor(flags: Iterable>) : this(flags.toMap()) - constructor(flags: Sequence>) - : this(flags.toMap()) + constructor(flags: Sequence>) : this(flags.toMap()) } data class ClearFlags(val names: Iterable) : SideEffect() { - constructor(vararg names: String) - : this(listOf(*names)) + constructor(vararg names: String) : this(listOf(*names)) - constructor(names: Sequence) - : this(names.toList()) + constructor(names: Sequence) : this(names.toList()) } data class LoadLibrary(val alias: String, val library: Library) : SideEffect() { @@ -159,11 +139,9 @@ sealed class SideEffect { } data class SetOperators(val operators: Iterable) : SideEffect() { - constructor(vararg operators: Operator) : - this(listOf(*operators)) + constructor(vararg operators: Operator) : this(listOf(*operators)) - constructor(operators: Sequence) : - this(operators.toOperatorSet()) + constructor(operators: Sequence) : this(operators.toOperatorSet()) val operatorSet: OperatorSet by lazy { if (operators is OperatorSet) { @@ -175,11 +153,9 @@ sealed class SideEffect { } data class ResetOperators(val operators: Iterable) : SideEffect() { - constructor(vararg operators: Operator) : - this(listOf(*operators)) + constructor(vararg operators: Operator) : this(listOf(*operators)) - constructor(operators: Sequence) : - this(operators.toOperatorSet()) + constructor(operators: Sequence) : this(operators.toOperatorSet()) val operatorSet: OperatorSet by lazy { if (operators is OperatorSet) { @@ -191,11 +167,9 @@ sealed class SideEffect { } data class RemoveOperators(val operators: Iterable) : SideEffect() { - constructor(vararg operators: Operator) : - this(listOf(*operators)) + constructor(vararg operators: Operator) : this(listOf(*operators)) - constructor(operators: Sequence) : - this(operators.toOperatorSet()) + constructor(operators: Sequence) : this(operators.toOperatorSet()) val operatorSet: OperatorSet by lazy { if (operators is OperatorSet) { @@ -207,62 +181,46 @@ sealed class SideEffect { } data class OpenInputChannels(val inputChannels: Map>) : SideEffect() { - constructor(vararg inputChannels: Pair>) - : this(listOf(*inputChannels)) + constructor(vararg inputChannels: Pair>) : this(listOf(*inputChannels)) - constructor(inputChannels: Iterable>>) - : this(inputChannels.toMap()) + constructor(inputChannels: Iterable>>) : this(inputChannels.toMap()) - constructor(inputChannels: Sequence>>) - : this(inputChannels.toMap()) + constructor(inputChannels: Sequence>>) : this(inputChannels.toMap()) } data class ResetInputChannels(val inputChannels: Map>) : SideEffect() { - constructor(vararg inputChannels: Pair>) - : this(listOf(*inputChannels)) + constructor(vararg inputChannels: Pair>) : this(listOf(*inputChannels)) - constructor(inputChannels: Iterable>>) - : this(inputChannels.toMap()) + constructor(inputChannels: Iterable>>) : this(inputChannels.toMap()) - constructor(inputChannels: Sequence>>) - : this(inputChannels.toMap()) + constructor(inputChannels: Sequence>>) : this(inputChannels.toMap()) } data class CloseInputChannels(val names: Iterable) : SideEffect() { - constructor(vararg names: String) - : this(listOf(*names)) + constructor(vararg names: String) : this(listOf(*names)) - constructor(names: Sequence) - : this(names.toList()) + constructor(names: Sequence) : this(names.toList()) } data class OpenOutputChannels(val outputChannels: Map>) : SideEffect() { - constructor(vararg outputChannels: Pair>) - : this(listOf(*outputChannels)) + constructor(vararg outputChannels: Pair>) : this(listOf(*outputChannels)) - constructor(outputChannels: Iterable>>) - : this(outputChannels.toMap()) + constructor(outputChannels: Iterable>>) : this(outputChannels.toMap()) - constructor(outputChannels: Sequence>>) - : this(outputChannels.toMap()) + constructor(outputChannels: Sequence>>) : this(outputChannels.toMap()) } data class ResetOutputChannels(val outputChannels: Map>) : SideEffect() { - constructor(vararg outputChannels: Pair>) - : this(listOf(*outputChannels)) + constructor(vararg outputChannels: Pair>) : this(listOf(*outputChannels)) - constructor(outputChannels: Iterable>>) - : this(outputChannels.toMap()) + constructor(outputChannels: Iterable>>) : this(outputChannels.toMap()) - constructor(outputChannels: Sequence>>) - : this(outputChannels.toMap()) + constructor(outputChannels: Sequence>>) : this(outputChannels.toMap()) } data class CloseOutputChannels(val names: Iterable) : SideEffect() { - constructor(vararg names: String) - : this(listOf(*names)) + constructor(vararg names: String) : this(listOf(*names)) - constructor(names: Sequence) - : this(names.toList()) + constructor(names: Sequence) : this(names.toList()) } } diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/SideEffectFactory.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/SideEffectFactory.kt index 8af3b8c10..86e09584f 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/SideEffectFactory.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/SideEffectFactory.kt @@ -278,4 +278,4 @@ interface SideEffectFactory { @JsName("closeOutputChannels") fun closeOutputChannels(vararg names: String) = SideEffect.CloseOutputChannels(*names) -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/SideEffectManager.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/SideEffectManager.kt index 533a1e76d..32f14b5b7 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/SideEffectManager.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/SideEffectManager.kt @@ -12,5 +12,4 @@ interface SideEffectManager { /** A function to execute cut, and return a new [SideEffectManager] with executed cut */ @JsName("cut") fun cut(): SideEffectManager - } diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/SideEffectsBuilder.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/SideEffectsBuilder.kt index d93e74be3..ef451ae98 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/SideEffectsBuilder.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/SideEffectsBuilder.kt @@ -37,4 +37,4 @@ interface SideEffectsBuilder : SideEffectFactory { fun of(vararg sideEffects: SideEffect): SideEffectsBuilder = SideEffectsBuilderImpl(dequeOf(*sideEffects)) } -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Signature.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Signature.kt index 302fb13c2..02c60ff46 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Signature.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Signature.kt @@ -1,6 +1,11 @@ package it.unibo.tuprolog.solve -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Indicator +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.ToTermConvertible import kotlin.js.JsName /** The signature of a query Struct or a Primitive */ @@ -17,15 +22,23 @@ data class Signature( require(arity >= 0) { "Signature arity should be greater than or equals to 0: $arity" } } - /** Converts this signature to a Struct `'/'([name],[arity])` or `'/'([name],'+'([arity], vararg))` */ + /** Converts this signature to a Struct `'/'([name], [arity])` or `'/'([name],'+'([arity], vararg))` */ override fun toTerm(): Struct = when { - vararg -> Struct.of( - FUNCTOR, Atom.of(name), Struct.of( - varargStructFunctor, Integer.of(arity), - varargAtom - )) - else -> Struct.of(FUNCTOR, Atom.of(name), Integer.of(arity)) + vararg -> { + Struct.of( + FUNCTOR, + Atom.of(name), + Struct.of( + varargStructFunctor, + Integer.of(arity), + varargAtom + ) + ) + } + else -> { + Struct.of(FUNCTOR, Atom.of(name), Integer.of(arity)) + } } /** Converts this Signature to [Indicator], if possible without loosing information, otherwise throws an exception */ @@ -73,22 +86,23 @@ data class Signature( with(term) { when { functor == FUNCTOR && arity == 2 && args.first().isAtom -> when { - args.last().isInt -> + args.last().isInt -> { Signature( args.first().`as`().value, args.last().`as`().intValue.toInt() ) - - with(args.last()) { - this is Struct && functor == varargStructFunctor && arity == 2 && - args.first().isInt && - args.last() == varargAtom - } -> Signature( - args.first().`as`().value, - args.last().`as`()[0].`as`().intValue.toInt(), - true - ) - + } + args.last().let { + it is Struct && functor == varargStructFunctor && arity == 2 && + args.first().isInt && + args.last() == varargAtom + } -> { + Signature( + args.first().`as`().value, + args.last().`as`()[0].`as`().intValue.toInt(), + true + ) + } else -> null } else -> null @@ -108,10 +122,12 @@ data class Signature( /** Creates a Signature instance from a well-formed Indicator, or returns `null` if it wasn't */ @JsName("fromIndicator") fun fromIndicator(indicator: Indicator): Signature? = when { - indicator.isWellFormed -> Signature( - indicator.indicatedName!!, - indicator.indicatedArity!! - ) + indicator.isWellFormed -> { + Signature( + indicator.indicatedName!!, + indicator.indicatedArity!! + ) + } else -> null } } diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Solution.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Solution.kt index 7dda8138f..1edc9447d 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Solution.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Solution.kt @@ -58,10 +58,10 @@ sealed class Solution { @JsName("exception") val exception: TuPrologRuntimeException ) : Solution() { - constructor(signature: Signature, arguments: List, exception: TuPrologRuntimeException) - : this(signature withArgs arguments, exception) { - noVarargSignatureCheck(signature) - } + constructor(signature: Signature, arguments: List, exception: TuPrologRuntimeException) : + this(signature withArgs arguments, exception) { + noVarargSignatureCheck(signature) + } } val isYes: Boolean @@ -82,4 +82,4 @@ sealed class Solution { "The signature should be a well-formed indicator, not vararg `$signature`" } } -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Solver.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Solver.kt index 2f12239a3..6570242fa 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Solver.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Solver.kt @@ -2,7 +2,6 @@ package it.unibo.tuprolog.solve import it.unibo.tuprolog.core.Struct import kotlin.js.JsName -import kotlin.jvm.JvmOverloads /** * Represents a Prolog Goal solver diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/SolverFactory.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/SolverFactory.kt index c81842afe..31edf4670 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/SolverFactory.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/SolverFactory.kt @@ -154,7 +154,14 @@ interface SolverFactory { stdErr: OutputChannel = defaultErrorChannel, warnings: OutputChannel = defaultWarningsChannel ): Solver = solverOf( - otherLibraries + defaultBuiltins, flags, staticKb, dynamicKb, stdIn, stdOut, stdErr, warnings + otherLibraries + defaultBuiltins, + flags, + staticKb, + dynamicKb, + stdIn, + stdOut, + stdErr, + warnings ) @JsName("solverWithDefaultBuiltinsAndLibrariesAndKBs") @@ -410,4 +417,4 @@ interface SolverFactory { defaultErrorChannel, defaultWarningsChannel ) -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Time.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Time.kt index d4d650ab0..1677b4f69 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Time.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Time.kt @@ -1,4 +1,5 @@ @file:JvmName("Time") + package it.unibo.tuprolog.solve import kotlin.js.JsName diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Utils.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Utils.kt index b75b5c884..03e2d4b01 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Utils.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Utils.kt @@ -1,4 +1,5 @@ @file:JvmName("Utils") + package it.unibo.tuprolog.solve import it.unibo.tuprolog.core.Clause @@ -50,4 +51,4 @@ fun getAllOperators(libraries: Libraries, vararg theories: Theory): Sequence.toOperatorSet(): OperatorSet { return OperatorSet(this) -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/Channel.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/Channel.kt index efbd79bdf..cbff9938e 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/Channel.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/Channel.kt @@ -11,5 +11,4 @@ interface Channel { @JsName("clearListeners") fun clearListeners() - -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/Channels.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/Channels.kt index f2d847f96..34b507f1b 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/Channels.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/Channels.kt @@ -8,4 +8,4 @@ internal expect fun stdout(): OutputChannel internal expect fun stderr(): OutputChannel -internal expect fun warning(): OutputChannel \ No newline at end of file +internal expect fun warning(): OutputChannel diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/InputChannel.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/InputChannel.kt index f6446d47b..debadf7f2 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/InputChannel.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/InputChannel.kt @@ -27,4 +27,4 @@ interface InputChannel : Channel { @JsName("read") fun read(): T -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/Listener.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/Listener.kt index f21448c6e..7753a7e17 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/Listener.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/Listener.kt @@ -1,3 +1,3 @@ package it.unibo.tuprolog.solve.channel -typealias Listener = (T) -> Unit \ No newline at end of file +typealias Listener = (T) -> Unit diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/OutputChannel.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/OutputChannel.kt index 26cc0c4b2..6f2cc04bd 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/OutputChannel.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/OutputChannel.kt @@ -26,4 +26,4 @@ interface OutputChannel : Channel { @JsName("write") fun write(value: T) -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/impl/AbstractChannel.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/impl/AbstractChannel.kt index 347dd6983..368406d7b 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/impl/AbstractChannel.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/impl/AbstractChannel.kt @@ -21,5 +21,4 @@ abstract class AbstractChannel : Channel { protected fun notify(value: T) { _listeners.forEach { it(value) } } - -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/impl/AbstractInputChannel.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/impl/AbstractInputChannel.kt index 114807b9f..e7e8cea92 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/impl/AbstractInputChannel.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/impl/AbstractInputChannel.kt @@ -14,4 +14,4 @@ abstract class AbstractInputChannel : AbstractChannel(), InputChannel { notify(read) return read } -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/impl/AbstractOutputChannel.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/impl/AbstractOutputChannel.kt index 968e24e08..2a49efa14 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/impl/AbstractOutputChannel.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/impl/AbstractOutputChannel.kt @@ -9,4 +9,4 @@ abstract class AbstractOutputChannel : AbstractChannel(), OutputChannel } protected abstract fun writeActually(value: T) -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/impl/InputChannelFromFunction.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/impl/InputChannelFromFunction.kt index 456878bd0..bea0770ed 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/impl/InputChannelFromFunction.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/impl/InputChannelFromFunction.kt @@ -9,4 +9,4 @@ internal class InputChannelFromFunction( get() = availabilityChecker() override fun readActually(): T = generator() -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/impl/OutputChannelFromFunction.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/impl/OutputChannelFromFunction.kt index e5dbf6780..3fc79e765 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/impl/OutputChannelFromFunction.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/channel/impl/OutputChannelFromFunction.kt @@ -2,4 +2,4 @@ package it.unibo.tuprolog.solve.channel.impl internal class OutputChannelFromFunction(private val consumer: (T) -> Unit) : AbstractOutputChannel() { override fun writeActually(value: T) = consumer(value) -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/HaltException.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/HaltException.kt index 2984e07d6..052572bc4 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/HaltException.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/HaltException.kt @@ -27,8 +27,8 @@ class HaltException( exitStatus: Int = 1 ) : this(message, cause, arrayOf(context), exitStatus) - constructor(cause: Throwable?, context: ExecutionContext, exitStatus: Int = 1) - : this(cause?.toString(), cause, context, exitStatus) + constructor(cause: Throwable?, context: ExecutionContext, exitStatus: Int = 1) : + this(cause?.toString(), cause, context, exitStatus) override fun updateContext(newContext: ExecutionContext): HaltException = HaltException(message, cause, contexts.setFirst(newContext), exitStatus) diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/PrologError.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/PrologError.kt index 8762937c7..e90016b9e 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/PrologError.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/PrologError.kt @@ -1,10 +1,23 @@ package it.unibo.tuprolog.solve.exception -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.TermFormatter +import it.unibo.tuprolog.core.Var +import it.unibo.tuprolog.core.format import it.unibo.tuprolog.solve.ExecutionContext import it.unibo.tuprolog.solve.Signature -import it.unibo.tuprolog.solve.exception.error.* +import it.unibo.tuprolog.solve.exception.error.DomainError import it.unibo.tuprolog.solve.exception.error.ErrorUtils.errorStructOf +import it.unibo.tuprolog.solve.exception.error.EvaluationError +import it.unibo.tuprolog.solve.exception.error.ExistenceError +import it.unibo.tuprolog.solve.exception.error.InstantiationError +import it.unibo.tuprolog.solve.exception.error.MessageError +import it.unibo.tuprolog.solve.exception.error.PermissionError +import it.unibo.tuprolog.solve.exception.error.RepresentationError +import it.unibo.tuprolog.solve.exception.error.SystemError +import it.unibo.tuprolog.solve.exception.error.TypeError import kotlin.js.JsName import kotlin.jvm.JvmStatic @@ -36,8 +49,8 @@ abstract class PrologError( extraData: Term? = null ) : this(message, cause, arrayOf(context), type, extraData) - constructor(cause: Throwable?, context: ExecutionContext, type: Struct, extraData: Term? = null) - : this(cause?.toString(), cause, context, type, extraData) + constructor(cause: Throwable?, context: ExecutionContext, type: Struct, extraData: Term? = null) : + this(cause?.toString(), cause, context, type, extraData) /** The error Struct as described in Prolog standard: `error(error_type, error_extra)` */ val errorStruct: Struct by lazy { generateErrorStruct() } @@ -126,9 +139,8 @@ abstract class PrologError( override fun pushContext(newContext: ExecutionContext): PrologError = of(this.message, this.cause, this.contexts.addLast(newContext), this.type, this.extraData) - } } } } -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/PrologWarning.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/PrologWarning.kt index 761609a95..033d6b575 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/PrologWarning.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/PrologWarning.kt @@ -25,4 +25,4 @@ abstract class PrologWarning( abstract override fun updateContext(newContext: ExecutionContext): PrologWarning abstract override fun pushContext(newContext: ExecutionContext): PrologWarning -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/TimeOutException.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/TimeOutException.kt index edc8b94a7..7e559b82b 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/TimeOutException.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/TimeOutException.kt @@ -28,8 +28,8 @@ class TimeOutException( exceededDuration: TimeDuration ) : this(message, cause, arrayOf(context), exceededDuration) - constructor(cause: Throwable?, context: ExecutionContext, exceededDuration: TimeDuration) - : this(cause?.toString(), cause, context, exceededDuration) + constructor(cause: Throwable?, context: ExecutionContext, exceededDuration: TimeDuration) : + this(cause?.toString(), cause, context, exceededDuration) override fun updateContext(newContext: ExecutionContext): TimeOutException = TimeOutException(message, cause, contexts.setFirst(newContext), exceededDuration) diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/TuPrologRuntimeException.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/TuPrologRuntimeException.kt index 333ed8803..5b1981ec3 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/TuPrologRuntimeException.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/TuPrologRuntimeException.kt @@ -27,8 +27,8 @@ open class TuPrologRuntimeException( cause: Throwable? = null, context: ExecutionContext, vararg otherContexts: ExecutionContext - ) - : this(message, cause, arrayOf(context, *otherContexts)) + ) : + this(message, cause, arrayOf(context, *otherContexts)) constructor(cause: Throwable?, context: ExecutionContext) : this(cause?.toString(), cause, context) diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/DomainError.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/DomainError.kt index f66d4a5d1..57ca1c546 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/DomainError.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/DomainError.kt @@ -55,8 +55,8 @@ class DomainError( index: Int? = null ): DomainError = message( (index?.let { "The $it-th argument" } ?: "An argument") + - "of `${procedure.pretty()}` should be `$expectedDomain`, " + - "but `${actualValue.pretty()}` has been provided instead" + "of `${procedure.pretty()}` should be `$expectedDomain`, " + + "but `${actualValue.pretty()}` has been provided instead" ) { m, extra -> DomainError( message = m, @@ -152,4 +152,4 @@ class DomainError( } } } -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/ErrorUtils.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/ErrorUtils.kt index 65437a116..619d3f9f4 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/ErrorUtils.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/ErrorUtils.kt @@ -26,5 +26,4 @@ object ErrorUtils { */ fun errorStructOf(errorDescription: Struct, customErrorData: Term = Atom.of("")) = Struct.of(errorWrapperFunctor, errorDescription, customErrorData) - } diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/EvaluationError.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/EvaluationError.kt index b8a861f04..74e6f27e1 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/EvaluationError.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/EvaluationError.kt @@ -65,13 +65,14 @@ class EvaluationError( /** Gets [Type] instance from [term] representation, if possible */ fun fromTerm(term: Term): Type? = when (term) { - is Atom -> try { - valueOf(term.value.toUpperCase()) - } catch (e: IllegalArgumentException) { - null - } catch (e: IllegalStateException) { - null - } + is Atom -> + try { + valueOf(term.value.toUpperCase()) + } catch (e: IllegalArgumentException) { + null + } catch (e: IllegalStateException) { + null + } else -> null } } diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/ExistenceError.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/ExistenceError.kt index e91968c83..81abe872a 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/ExistenceError.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/ExistenceError.kt @@ -70,7 +70,7 @@ class ExistenceError( context: ExecutionContext, alias: String ) = message( - "There exists no stream whose alias is `${alias}`" + "There exists no stream whose alias is `$alias`" ) { m, extra -> ExistenceError( message = m, @@ -113,6 +113,4 @@ class ExistenceError( } } } - - -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/InstantiationError.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/InstantiationError.kt index 8994ec21e..cc1c61713 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/InstantiationError.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/InstantiationError.kt @@ -47,7 +47,7 @@ class InstantiationError( fun forArgument(context: ExecutionContext, procedure: Signature, variable: Var, index: Int? = null) = message( "${index?.let { "The $it-th argument" } ?: "The argument"} `${variable.pretty()}` " + - "of ${procedure.pretty()} is unexpectedly not instantiated" + "of ${procedure.pretty()} is unexpectedly not instantiated" ) { m, extra -> InstantiationError( message = m, @@ -68,7 +68,5 @@ class InstantiationError( extraData = extra ) } - } - } diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/MessageError.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/MessageError.kt index 5e2cba426..3ea89c8e8 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/MessageError.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/MessageError.kt @@ -46,6 +46,5 @@ class MessageError internal constructor( // TODO: 16/01/2020 test this class /** Factory method to create a [MessageError] */ fun of(content: Term, context: ExecutionContext, cause: Throwable? = null) = MessageError(content.toString(), cause, context, content) - } -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/PermissionError.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/PermissionError.kt index 8c1927086..d6631cc4c 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/PermissionError.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/PermissionError.kt @@ -64,7 +64,7 @@ class PermissionError( culprit: Term ): PermissionError = message( "Permission error while executing ${procedure.pretty()}: " + - "operation of type `$operation` is not possible on $permission: ${culprit.pretty()}" + "operation of type `$operation` is not possible on $permission: ${culprit.pretty()}" ) { m, extra -> PermissionError( message = m, @@ -147,4 +147,4 @@ class PermissionError( } } } -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/RepresentationError.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/RepresentationError.kt index b751d461a..dfd86b18a 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/RepresentationError.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/RepresentationError.kt @@ -98,4 +98,4 @@ class RepresentationError( } } } -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/SystemError.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/SystemError.kt index 75a26a246..ae10ceeee 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/SystemError.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/SystemError.kt @@ -50,10 +50,9 @@ class SystemError constructor( } fun forUncaughtException(context: ExecutionContext, exception: PrologError): SystemError = - when(exception) { + when (exception) { is MessageError -> forUncaughtException(context, exception.content) else -> forUncaughtException(context, exception.errorStruct) } - } } diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/TypeError.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/TypeError.kt index 996b6d096..6776c1335 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/TypeError.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/error/TypeError.kt @@ -59,8 +59,8 @@ class TypeError( index: Int? = null ) = message( (index?.let { "The $it-th argument" } ?: "An argument") + - " of `${procedure.pretty()}` should be a list of `$expectedType`, " + - "but `${actualValue.pretty()}` has been provided instead" + " of `${procedure.pretty()}` should be a list of `$expectedType`, " + + "but `${actualValue.pretty()}` has been provided instead" ) { m, extra -> TypeError( message = m, @@ -80,8 +80,8 @@ class TypeError( ) = message( (index?.let { "The $it-th argument" } ?: "An argument") + - " of `${procedure.pretty()}` should be a `$expectedType`, " + - "but `${actualValue.pretty()}` has been provided instead" + " of `${procedure.pretty()}` should be a `$expectedType`, " + + "but `${actualValue.pretty()}` has been provided instead" ) { m, extra -> TypeError( message = m, @@ -113,7 +113,6 @@ class TypeError( const val typeFunctor = "type_error" } - /** * A class describing the expected type whose absence caused the error * @@ -158,4 +157,4 @@ class TypeError( } } } -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/warning/MissingPredicate.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/warning/MissingPredicate.kt index a2089279c..bdb18460a 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/warning/MissingPredicate.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/exception/warning/MissingPredicate.kt @@ -26,4 +26,4 @@ class MissingPredicate( override fun pushContext(newContext: ExecutionContext): PrologWarning = MissingPredicate(cause, contexts.addLast(newContext), signature) -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/flags/DoubleQuotes.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/flags/DoubleQuotes.kt index ce515269c..6f95101d6 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/flags/DoubleQuotes.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/flags/DoubleQuotes.kt @@ -14,5 +14,4 @@ object DoubleQuotes : NotableFlag { get() = ATOM override val admissibleValues: Sequence = sequenceOf(ATOM) - -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/flags/MaxArity.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/flags/MaxArity.kt index 091f729d1..2880f7c4d 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/flags/MaxArity.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/flags/MaxArity.kt @@ -1,8 +1,6 @@ package it.unibo.tuprolog.solve.flags -import it.unibo.tuprolog.core.Atom import it.unibo.tuprolog.core.Integer -import it.unibo.tuprolog.core.Term @Suppress("MemberVisibilityCanBePrivate") object MaxArity : NotableFlag { @@ -12,5 +10,4 @@ object MaxArity : NotableFlag { override val defaultValue: Integer = Integer.of(Int.MAX_VALUE) override val admissibleValues: Sequence = sequenceOf(defaultValue) - -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/flags/NotableFlag.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/flags/NotableFlag.kt index 14f2ef259..8fff00a4b 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/flags/NotableFlag.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/flags/NotableFlag.kt @@ -15,9 +15,11 @@ interface NotableFlag { this to defaultValue infix fun to(value: Term): Pair = - name to (value.also { - require(isAdmissibleValue(it)) { - "$value is not an admissible value for flag $name" + name to ( + value.also { + require(isAdmissibleValue(it)) { + "$value is not an admissible value for flag $name" + } } - }) -} \ No newline at end of file + ) +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/flags/Unknown.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/flags/Unknown.kt index c93e3c999..84e8d345d 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/flags/Unknown.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/flags/Unknown.kt @@ -16,5 +16,4 @@ object Unknown : NotableFlag { get() = WARNING override val admissibleValues: Sequence = sequenceOf(ERROR, WARNING, FAIL) - -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/AbstractEvaluator.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/AbstractEvaluator.kt index eb26b1902..7bf6c9859 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/AbstractEvaluator.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/AbstractEvaluator.kt @@ -1,11 +1,14 @@ package it.unibo.tuprolog.solve.function -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Indicator +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.TermVisitor import it.unibo.tuprolog.solve.ExecutionContext import it.unibo.tuprolog.solve.extractSignature import it.unibo.tuprolog.solve.primitive.Solve - abstract class AbstractEvaluator( protected val request: Solve.Request, protected val index: Int? diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/ArithmeticEvaluator.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/ArithmeticEvaluator.kt index f9a52b469..83c2ce4c3 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/ArithmeticEvaluator.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/ArithmeticEvaluator.kt @@ -1,6 +1,12 @@ package it.unibo.tuprolog.solve.function -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Indicator +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Numeric +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.solve.ExecutionContext import it.unibo.tuprolog.solve.exception.error.InstantiationError import it.unibo.tuprolog.solve.exception.error.TypeError @@ -10,7 +16,11 @@ import it.unibo.tuprolog.solve.exception.error.TypeError.Expected.NUMBER import it.unibo.tuprolog.solve.extractSignature import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.stdlib.CommonBuiltins -import it.unibo.tuprolog.solve.stdlib.function.* +import it.unibo.tuprolog.solve.stdlib.function.BitwiseAnd +import it.unibo.tuprolog.solve.stdlib.function.BitwiseComplement +import it.unibo.tuprolog.solve.stdlib.function.BitwiseLeftShift +import it.unibo.tuprolog.solve.stdlib.function.BitwiseOr +import it.unibo.tuprolog.solve.stdlib.function.BitwiseRightShift /** * Evaluates an expression as a [Numeric] term. diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/ArithmeticUtils.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/ArithmeticUtils.kt index dff265a6a..801e39e65 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/ArithmeticUtils.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/ArithmeticUtils.kt @@ -3,8 +3,6 @@ package it.unibo.tuprolog.solve.function import it.unibo.tuprolog.core.Numeric import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.solve.ExecutionContext -import it.unibo.tuprolog.solve.exception.error.InstantiationError -import it.unibo.tuprolog.solve.exception.error.TypeError import it.unibo.tuprolog.solve.primitive.Solve private fun Term.eval( @@ -22,4 +20,4 @@ fun Term.evalAsExpression(request: Solve.Request<*>, index: Int? = null): Term = eval(request, index, ::ExpressionEvaluator) fun Term.evalAsArithmeticExpression(request: Solve.Request<*>, index: Int? = null): Numeric = - eval(request, index, ::ArithmeticEvaluator) \ No newline at end of file + eval(request, index, ::ArithmeticEvaluator) diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/BinaryMathFunction.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/BinaryMathFunction.kt index 5b77faa71..83a255df9 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/BinaryMathFunction.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/BinaryMathFunction.kt @@ -7,7 +7,6 @@ import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.solve.ExecutionContext import it.unibo.tuprolog.solve.exception.error.InstantiationError import it.unibo.tuprolog.solve.exception.error.TypeError -import kotlin.math.sign /** * Base class to implement unary math functions diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/Compute.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/Compute.kt index 7c28acbd8..bd4db1e60 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/Compute.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/Compute.kt @@ -2,7 +2,11 @@ package it.unibo.tuprolog.solve.function import it.unibo.tuprolog.core.Struct import it.unibo.tuprolog.core.Term -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.ExecutionContext +import it.unibo.tuprolog.solve.Signature +import it.unibo.tuprolog.solve.TimeDuration +import it.unibo.tuprolog.solve.TimeInstant +import it.unibo.tuprolog.solve.currentTimeInstant import kotlin.js.JsName /** A base class for Computation requests and responses */ @@ -48,7 +52,6 @@ sealed class Compute { fun replyWith(result: Term) = Response(result) } - /** Class representing a Response, from the Expression evaluator, to a [Solve.Request] */ data class Response( /** The result of evaluation process */ diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/ExpressionEvaluator.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/ExpressionEvaluator.kt index 9c17c91f0..37d385835 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/ExpressionEvaluator.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/ExpressionEvaluator.kt @@ -1,6 +1,5 @@ package it.unibo.tuprolog.solve.function -import it.unibo.tuprolog.core.Numeric import it.unibo.tuprolog.core.Struct import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.solve.ExecutionContext diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/ExpressionReducer.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/ExpressionReducer.kt index a400c2ec6..fa6378ebe 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/ExpressionReducer.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/ExpressionReducer.kt @@ -1,10 +1,7 @@ package it.unibo.tuprolog.solve.function -import it.unibo.tuprolog.core.Numeric -import it.unibo.tuprolog.core.Struct import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.solve.ExecutionContext -import it.unibo.tuprolog.solve.exception.error.TypeError import it.unibo.tuprolog.solve.primitive.Solve /** diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/FunctionWrapper.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/FunctionWrapper.kt index 7e1f9abe5..86b346133 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/FunctionWrapper.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/function/FunctionWrapper.kt @@ -22,5 +22,4 @@ abstract class FunctionWrapper : AbstractWrapper { expectedType = TypeError.Expected.INTEGER, actualValue = actualValue ) - } diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/impl/SideEffectsBuilderImpl.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/impl/SideEffectsBuilderImpl.kt index 135519c22..7104b2a14 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/impl/SideEffectsBuilderImpl.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/impl/SideEffectsBuilderImpl.kt @@ -275,4 +275,4 @@ internal data class SideEffectsBuilderImpl(override val sideEffects: MutableList override fun addLibraries(vararg libraries: AliasedLibrary): SideEffect.AddLibraries { return adding { super.addLibraries(*libraries) } } -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/library/Libraries.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/library/Libraries.kt index 0e5a1e603..41355a57c 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/library/Libraries.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/library/Libraries.kt @@ -10,7 +10,8 @@ import it.unibo.tuprolog.theory.Theory import kotlin.js.JsName /** A class representing an agglomerate of libraries with an alias */ -class Libraries(libraries: Sequence) : LibraryGroup, +class Libraries(libraries: Sequence) : + LibraryGroup, Map by (libraries.map { it.alias to it }.toMap()) { constructor(vararg library: AliasedLibrary) : this(library.asSequence()) @@ -121,4 +122,4 @@ class Libraries(libraries: Sequence) : LibraryGroup : Library { /** Updates an already contained library, with given library */ @JsName("update") fun update(library: L): LibraryGroup - } diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/library/exception/AlreadyLoadedLibraryException.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/library/exception/AlreadyLoadedLibraryException.kt index 916dd8682..8bf0f6805 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/library/exception/AlreadyLoadedLibraryException.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/library/exception/AlreadyLoadedLibraryException.kt @@ -6,4 +6,3 @@ class AlreadyLoadedLibraryException( ) : LibraryException(message, cause) { constructor(cause: Throwable?) : this(cause?.toString(), cause) } - diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/library/exception/NoSuchALibraryException.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/library/exception/NoSuchALibraryException.kt index 09a9945de..d92a58e49 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/library/exception/NoSuchALibraryException.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/library/exception/NoSuchALibraryException.kt @@ -5,4 +5,4 @@ class NoSuchALibraryException( cause: Throwable? = null ) : LibraryException(message, cause) { constructor(cause: Throwable?) : this(cause?.toString(), cause) -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/ArithmeticRelation.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/ArithmeticRelation.kt index c9d0ce6d5..af8741659 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/ArithmeticRelation.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/ArithmeticRelation.kt @@ -3,7 +3,6 @@ package it.unibo.tuprolog.solve.primitive import it.unibo.tuprolog.core.Numeric import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.solve.ExecutionContext -import it.unibo.tuprolog.solve.function.ArithmeticEvaluator import it.unibo.tuprolog.solve.function.evalAsArithmeticExpression /** Base class for implementing arithmetic relation between [Numeric] terms */ diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/BinaryRelation.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/BinaryRelation.kt index 1ac74467b..770b62b29 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/BinaryRelation.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/BinaryRelation.kt @@ -37,7 +37,6 @@ abstract class BinaryRelation(operator: String) : Primitiv final override fun Solve.Request.computeAll(first: Term, second: Term): Sequence { return sequenceOf(computeOne(first, second)) } - } abstract class Functional(operator: String) : NonBacktrackable(operator) { diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/PrimitiveWrapper.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/PrimitiveWrapper.kt index f04850160..d466e9dee 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/PrimitiveWrapper.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/PrimitiveWrapper.kt @@ -1,16 +1,30 @@ package it.unibo.tuprolog.solve.primitive -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Clause +import it.unibo.tuprolog.core.Indicator +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Numeric +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.TermVisitor +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.core.operators.Specifier import it.unibo.tuprolog.solve.AbstractWrapper import it.unibo.tuprolog.solve.ExecutionContext import it.unibo.tuprolog.solve.Signature -import it.unibo.tuprolog.solve.exception.error.* +import it.unibo.tuprolog.solve.exception.error.DomainError import it.unibo.tuprolog.solve.exception.error.DomainError.Expected.NOT_LESS_THAN_ZERO +import it.unibo.tuprolog.solve.exception.error.InstantiationError +import it.unibo.tuprolog.solve.exception.error.PermissionError import it.unibo.tuprolog.solve.exception.error.PermissionError.Permission.PRIVATE_PROCEDURE import it.unibo.tuprolog.solve.exception.error.PermissionError.Permission.STATIC_PROCEDURE +import it.unibo.tuprolog.solve.exception.error.RepresentationError import it.unibo.tuprolog.solve.exception.error.RepresentationError.Limit.MAX_ARITY -import it.unibo.tuprolog.solve.exception.error.TypeError.Expected.* +import it.unibo.tuprolog.solve.exception.error.TypeError +import it.unibo.tuprolog.solve.exception.error.TypeError.Expected.ATOM +import it.unibo.tuprolog.solve.exception.error.TypeError.Expected.INTEGER +import it.unibo.tuprolog.solve.exception.error.TypeError.Expected.PREDICATE_INDICATOR import it.unibo.tuprolog.solve.extractSignature import it.unibo.tuprolog.solve.flags.MaxArity import org.gciatto.kt.math.BigInteger @@ -68,8 +82,8 @@ abstract class PrimitiveWrapper : AbstractWrapper(signature) { - constructor(name: String, arity: Int, vararg: Boolean = false, uncheckedPrimitive: Primitive) - : this(Signature(name, arity, vararg), uncheckedPrimitive) + constructor(name: String, arity: Int, vararg: Boolean = false, uncheckedPrimitive: Primitive) : + this(Signature(name, arity, vararg), uncheckedPrimitive) override fun uncheckedImplementation(request: Solve.Request): Sequence = uncheckedPrimitive(request) @@ -261,7 +275,6 @@ abstract class PrimitiveWrapper : AbstractWrapper Solve.Request.ensuringArgumentIsNonNegativeInteger(index: Int): Solve.Request = ensuringArgumentIsInteger(index) .arguments[index].let { arg -> diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/Solve.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/Solve.kt index 886e20f38..3f10c090d 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/Solve.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/Solve.kt @@ -3,7 +3,16 @@ package it.unibo.tuprolog.solve.primitive import it.unibo.tuprolog.core.Struct import it.unibo.tuprolog.core.Substitution import it.unibo.tuprolog.core.Term -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.ExecutionContext +import it.unibo.tuprolog.solve.SideEffect +import it.unibo.tuprolog.solve.SideEffectManager +import it.unibo.tuprolog.solve.SideEffectsBuilder +import it.unibo.tuprolog.solve.Signature +import it.unibo.tuprolog.solve.Solution +import it.unibo.tuprolog.solve.Solver +import it.unibo.tuprolog.solve.TimeDuration +import it.unibo.tuprolog.solve.TimeInstant +import it.unibo.tuprolog.solve.currentTimeInstant import it.unibo.tuprolog.solve.exception.TuPrologRuntimeException import kotlin.js.JsName @@ -73,7 +82,7 @@ sealed class Solve { solution: Solution, sideEffectManager: SideEffectManager? = null, vararg sideEffects: SideEffect - ) = when(solution) { + ) = when (solution) { is Solution.Yes -> replySuccess(solution.substitution, sideEffectManager, *sideEffects) is Solution.No -> replyFail(sideEffectManager, *sideEffects) is Solution.Halt -> replyException(solution.exception, sideEffectManager, *sideEffects) @@ -85,7 +94,7 @@ sealed class Solve { solution: Solution, sideEffectManager: SideEffectManager? = null, buildSideEffects: SideEffectsBuilder.() -> Unit - ) = when(solution) { + ) = when (solution) { is Solution.Yes -> replySuccess(solution.substitution, sideEffectManager, buildSideEffects) is Solution.No -> replyFail(sideEffectManager, buildSideEffects) is Solution.Halt -> replyException(solution.exception, sideEffectManager, buildSideEffects) @@ -196,7 +205,6 @@ sealed class Solve { } } - /** Class representing a Response, from the Solver, to a [Solve.Request] */ data class Response( /** The solution attached to the response */ diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/TypeEnsurer.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/TypeEnsurer.kt index ad72f666c..39b75acbc 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/TypeEnsurer.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/TypeEnsurer.kt @@ -10,4 +10,4 @@ abstract class TypeEnsurer(typeName: String) : UnaryPredic } abstract fun Solve.Request.ensureType(context: E, term: Term) -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/TypeTester.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/TypeTester.kt index da399050f..3b789a1df 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/TypeTester.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/TypeTester.kt @@ -9,4 +9,4 @@ abstract class TypeTester(typeName: String) : UnaryPredica } abstract fun testType(term: Term): Boolean -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/UnaryPredicate.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/UnaryPredicate.kt index 2d4df87bc..d865b0986 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/UnaryPredicate.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/UnaryPredicate.kt @@ -16,7 +16,6 @@ abstract class UnaryPredicate(operator: String) : Primitiv return request.computeAll(request.arguments[0]) } - abstract class WithoutSideEffects(operator: String) : UnaryPredicate(operator) { protected abstract fun Solve.Request.computeAllSubstitutions( first: Term @@ -35,7 +34,6 @@ abstract class UnaryPredicate(operator: String) : Primitiv final override fun Solve.Request.computeAll(first: Term): Sequence { return sequenceOf(computeOne(first)) } - } abstract class Functional(operator: String) : NonBacktrackable(operator) { diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/ZeroaryPredicate.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/ZeroaryPredicate.kt index 5358d1bfd..e8d4e9852 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/ZeroaryPredicate.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/primitive/ZeroaryPredicate.kt @@ -1,3 +1,3 @@ package it.unibo.tuprolog.solve.primitive -typealias ZeroaryPredicate = PredicateWithoutArguments \ No newline at end of file +typealias ZeroaryPredicate = PredicateWithoutArguments diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/rule/RuleWrapper.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/rule/RuleWrapper.kt index 6224c1707..a1b31d93d 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/rule/RuleWrapper.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/rule/RuleWrapper.kt @@ -9,7 +9,6 @@ import it.unibo.tuprolog.solve.ExecutionContext import it.unibo.tuprolog.solve.Signature import kotlin.collections.List as KtList - // TODO: 16/01/2020 document and test this class abstract class RuleWrapper(signature: Signature) : AbstractWrapper(signature) { @@ -36,6 +35,4 @@ abstract class RuleWrapper(signature: Signature) : Abstrac override fun toString(): String { return "RuleWrapper(signature=${signature.toIndicator()}, rule=$wrappedImplementation)" } - - -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/CommonBuiltins.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/CommonBuiltins.kt index 98905e033..beb8e2dc4 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/CommonBuiltins.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/CommonBuiltins.kt @@ -3,97 +3,12 @@ package it.unibo.tuprolog.solve.stdlib import it.unibo.tuprolog.core.operators.OperatorSet import it.unibo.tuprolog.solve.library.AliasedLibrary import it.unibo.tuprolog.solve.library.Library -import it.unibo.tuprolog.solve.primitive.PrimitiveWrapper -import it.unibo.tuprolog.solve.stdlib.function.* -import it.unibo.tuprolog.solve.stdlib.primitive.* -import it.unibo.tuprolog.solve.stdlib.primitive.Float as FloatPrimitive -object CommonBuiltins : AliasedLibrary by Library.aliased( - alias = "prolog.lang", - operatorSet = OperatorSet.DEFAULT, - theory = CommonRules.theory, - primitives = sequenceOf>( - Abolish, - Arg, - ArithmeticEqual, - ArithmeticGreaterThan, - ArithmeticGreaterThanOrEqualTo, - ArithmeticLowerThan, - ArithmeticLowerThanOrEqualTo, - ArithmeticNotEqual, - Assert, - AssertA, - AssertZ, - Atom, - AtomChars, - Atomic, - Between, - Callable, - Clause, - Compound, - CopyTerm, - CurrentOp, - CurrentPrologFlag, - EnsureExecutable, - FindAll, - FloatPrimitive, - Functor, - Ground, - Halt, - Integer, - Is, - Natural, - NewLine, - NonVar, - NotUnifiableWith, - Number, - Op, - Repeat, - Retract, - RetractAll, - Sleep, - TermGreaterThan, - TermGreaterThanOrEqualTo, - TermIdentical, - TermLowerThan, - TermLowerThanOrEqualTo, - TermNotIdentical, - TermNotSame, - TermSame, - UnifiesWith, - Univ, - Var, - Write - ).map { it.descriptionPair }.toMap(), - functions = sequenceOf( - AbsoluteValue, - Addition, - ArcTangent, - BitwiseAnd, - BitwiseComplement, - BitwiseLeftShift, - BitwiseOr, - BitwiseRightShift, - Ceiling, - Cosine, - Exponential, - Exponentiation, - ToFloat, - FloatFractionalPart, - FloatIntegerPart, - FloatingPointDivision, - Floor, - IntegerDivision, - Modulo, - Multiplication, - NaturalLogarithm, - Remainder, - Round, - Sign, - SignReversal, - Sine, - SquareRoot, - Subtraction, - Truncate - ).map { it.descriptionPair }.toMap() -) +object CommonBuiltins : AliasedLibrary by + Library.aliased( + alias = "prolog.lang", + operatorSet = OperatorSet.DEFAULT, + theory = CommonRules.theory, + primitives = CommonPrimitives.primitives, + functions = CommonFunctions.functions + ) diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/CommonFunctions.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/CommonFunctions.kt new file mode 100644 index 000000000..44e9061b6 --- /dev/null +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/CommonFunctions.kt @@ -0,0 +1,71 @@ +package it.unibo.tuprolog.solve.stdlib + +import it.unibo.tuprolog.solve.Signature +import it.unibo.tuprolog.solve.function.FunctionWrapper +import it.unibo.tuprolog.solve.function.PrologFunction +import it.unibo.tuprolog.solve.stdlib.function.AbsoluteValue +import it.unibo.tuprolog.solve.stdlib.function.Addition +import it.unibo.tuprolog.solve.stdlib.function.ArcTangent +import it.unibo.tuprolog.solve.stdlib.function.BitwiseAnd +import it.unibo.tuprolog.solve.stdlib.function.BitwiseComplement +import it.unibo.tuprolog.solve.stdlib.function.BitwiseLeftShift +import it.unibo.tuprolog.solve.stdlib.function.BitwiseOr +import it.unibo.tuprolog.solve.stdlib.function.BitwiseRightShift +import it.unibo.tuprolog.solve.stdlib.function.Ceiling +import it.unibo.tuprolog.solve.stdlib.function.Cosine +import it.unibo.tuprolog.solve.stdlib.function.Exponential +import it.unibo.tuprolog.solve.stdlib.function.Exponentiation +import it.unibo.tuprolog.solve.stdlib.function.FloatFractionalPart +import it.unibo.tuprolog.solve.stdlib.function.FloatIntegerPart +import it.unibo.tuprolog.solve.stdlib.function.FloatingPointDivision +import it.unibo.tuprolog.solve.stdlib.function.Floor +import it.unibo.tuprolog.solve.stdlib.function.IntegerDivision +import it.unibo.tuprolog.solve.stdlib.function.Modulo +import it.unibo.tuprolog.solve.stdlib.function.Multiplication +import it.unibo.tuprolog.solve.stdlib.function.NaturalLogarithm +import it.unibo.tuprolog.solve.stdlib.function.Remainder +import it.unibo.tuprolog.solve.stdlib.function.Round +import it.unibo.tuprolog.solve.stdlib.function.Sign +import it.unibo.tuprolog.solve.stdlib.function.SignReversal +import it.unibo.tuprolog.solve.stdlib.function.Sine +import it.unibo.tuprolog.solve.stdlib.function.SquareRoot +import it.unibo.tuprolog.solve.stdlib.function.Subtraction +import it.unibo.tuprolog.solve.stdlib.function.ToFloat +import it.unibo.tuprolog.solve.stdlib.function.Truncate + +object CommonFunctions { + val wrappers: Sequence> = + sequenceOf( + AbsoluteValue, + Addition, + ArcTangent, + BitwiseAnd, + BitwiseComplement, + BitwiseLeftShift, + BitwiseOr, + BitwiseRightShift, + Ceiling, + Cosine, + Exponential, + Exponentiation, + ToFloat, + FloatFractionalPart, + FloatIntegerPart, + FloatingPointDivision, + Floor, + IntegerDivision, + Modulo, + Multiplication, + NaturalLogarithm, + Remainder, + Round, + Sign, + SignReversal, + Sine, + SquareRoot, + Subtraction, + Truncate + ) + + val functions: Map = wrappers.map { it.descriptionPair }.toMap() +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/CommonPrimitives.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/CommonPrimitives.kt new file mode 100644 index 000000000..efb07282e --- /dev/null +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/CommonPrimitives.kt @@ -0,0 +1,115 @@ +package it.unibo.tuprolog.solve.stdlib + +import it.unibo.tuprolog.solve.Signature +import it.unibo.tuprolog.solve.primitive.Primitive +import it.unibo.tuprolog.solve.primitive.PrimitiveWrapper +import it.unibo.tuprolog.solve.stdlib.primitive.Abolish +import it.unibo.tuprolog.solve.stdlib.primitive.Arg +import it.unibo.tuprolog.solve.stdlib.primitive.ArithmeticEqual +import it.unibo.tuprolog.solve.stdlib.primitive.ArithmeticGreaterThan +import it.unibo.tuprolog.solve.stdlib.primitive.ArithmeticGreaterThanOrEqualTo +import it.unibo.tuprolog.solve.stdlib.primitive.ArithmeticLowerThan +import it.unibo.tuprolog.solve.stdlib.primitive.ArithmeticLowerThanOrEqualTo +import it.unibo.tuprolog.solve.stdlib.primitive.ArithmeticNotEqual +import it.unibo.tuprolog.solve.stdlib.primitive.Assert +import it.unibo.tuprolog.solve.stdlib.primitive.AssertA +import it.unibo.tuprolog.solve.stdlib.primitive.AssertZ +import it.unibo.tuprolog.solve.stdlib.primitive.Atom +import it.unibo.tuprolog.solve.stdlib.primitive.AtomChars +import it.unibo.tuprolog.solve.stdlib.primitive.Atomic +import it.unibo.tuprolog.solve.stdlib.primitive.Between +import it.unibo.tuprolog.solve.stdlib.primitive.Callable +import it.unibo.tuprolog.solve.stdlib.primitive.Clause +import it.unibo.tuprolog.solve.stdlib.primitive.Compound +import it.unibo.tuprolog.solve.stdlib.primitive.CopyTerm +import it.unibo.tuprolog.solve.stdlib.primitive.CurrentOp +import it.unibo.tuprolog.solve.stdlib.primitive.CurrentPrologFlag +import it.unibo.tuprolog.solve.stdlib.primitive.EnsureExecutable +import it.unibo.tuprolog.solve.stdlib.primitive.FindAll +import it.unibo.tuprolog.solve.stdlib.primitive.Float +import it.unibo.tuprolog.solve.stdlib.primitive.Functor +import it.unibo.tuprolog.solve.stdlib.primitive.Ground +import it.unibo.tuprolog.solve.stdlib.primitive.Halt +import it.unibo.tuprolog.solve.stdlib.primitive.Integer +import it.unibo.tuprolog.solve.stdlib.primitive.Is +import it.unibo.tuprolog.solve.stdlib.primitive.Natural +import it.unibo.tuprolog.solve.stdlib.primitive.NewLine +import it.unibo.tuprolog.solve.stdlib.primitive.NonVar +import it.unibo.tuprolog.solve.stdlib.primitive.NotUnifiableWith +import it.unibo.tuprolog.solve.stdlib.primitive.Number +import it.unibo.tuprolog.solve.stdlib.primitive.Op +import it.unibo.tuprolog.solve.stdlib.primitive.Repeat +import it.unibo.tuprolog.solve.stdlib.primitive.Retract +import it.unibo.tuprolog.solve.stdlib.primitive.RetractAll +import it.unibo.tuprolog.solve.stdlib.primitive.Sleep +import it.unibo.tuprolog.solve.stdlib.primitive.TermGreaterThan +import it.unibo.tuprolog.solve.stdlib.primitive.TermGreaterThanOrEqualTo +import it.unibo.tuprolog.solve.stdlib.primitive.TermIdentical +import it.unibo.tuprolog.solve.stdlib.primitive.TermLowerThan +import it.unibo.tuprolog.solve.stdlib.primitive.TermLowerThanOrEqualTo +import it.unibo.tuprolog.solve.stdlib.primitive.TermNotIdentical +import it.unibo.tuprolog.solve.stdlib.primitive.TermNotSame +import it.unibo.tuprolog.solve.stdlib.primitive.TermSame +import it.unibo.tuprolog.solve.stdlib.primitive.UnifiesWith +import it.unibo.tuprolog.solve.stdlib.primitive.Univ +import it.unibo.tuprolog.solve.stdlib.primitive.Var +import it.unibo.tuprolog.solve.stdlib.primitive.Write + +object CommonPrimitives { + val wrappers: Sequence> = + sequenceOf( + Abolish, + Arg, + ArithmeticEqual, + ArithmeticGreaterThan, + ArithmeticGreaterThanOrEqualTo, + ArithmeticLowerThan, + ArithmeticLowerThanOrEqualTo, + ArithmeticNotEqual, + Assert, + AssertA, + AssertZ, + Atom, + AtomChars, + Atomic, + Between, + Callable, + Clause, + Compound, + CopyTerm, + CurrentOp, + CurrentPrologFlag, + EnsureExecutable, + FindAll, + Float, + Functor, + Ground, + Halt, + Integer, + Is, + Natural, + NewLine, + NonVar, + NotUnifiableWith, + Number, + Op, + Repeat, + Retract, + RetractAll, + Sleep, + TermGreaterThan, + TermGreaterThanOrEqualTo, + TermIdentical, + TermLowerThan, + TermLowerThanOrEqualTo, + TermNotIdentical, + TermNotSame, + TermSame, + UnifiesWith, + Univ, + Var, + Write + ) + + val primitives: Map = wrappers.map { it.descriptionPair }.toMap() +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/CommonRules.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/CommonRules.kt index a1fef7459..533334c49 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/CommonRules.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/CommonRules.kt @@ -2,7 +2,12 @@ package it.unibo.tuprolog.solve.stdlib import it.unibo.tuprolog.solve.ExecutionContext import it.unibo.tuprolog.solve.rule.RuleWrapper -import it.unibo.tuprolog.solve.stdlib.rule.* +import it.unibo.tuprolog.solve.stdlib.rule.Append +import it.unibo.tuprolog.solve.stdlib.rule.Arrow +import it.unibo.tuprolog.solve.stdlib.rule.Member +import it.unibo.tuprolog.solve.stdlib.rule.Not +import it.unibo.tuprolog.solve.stdlib.rule.Once +import it.unibo.tuprolog.solve.stdlib.rule.Semicolon import it.unibo.tuprolog.theory.Theory object CommonRules { @@ -22,4 +27,4 @@ object CommonRules { val theory: Theory get() = Theory.indexedOf(wrappers.map { it.wrappedImplementation }) -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/function/AbsoluteValue.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/function/AbsoluteValue.kt index eb606eed4..00c92d35c 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/function/AbsoluteValue.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/function/AbsoluteValue.kt @@ -18,5 +18,4 @@ object AbsoluteValue : UnaryMathFunction("abs") { override fun mathFunction(real: Real, context: ExecutionContext): Numeric = Numeric.of(real.value.absoluteValue) - } diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/function/BitwiseAnd.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/function/BitwiseAnd.kt index 98c2c335f..0fa5e2108 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/function/BitwiseAnd.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/function/BitwiseAnd.kt @@ -14,4 +14,4 @@ object BitwiseAnd : IntegersBinaryMathFunction("/\\") { override fun mathFunction(integer1: Integer, integer2: Integer, context: ExecutionContext): Numeric = Numeric.of(integer1.value.and(integer2.value)) -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/function/BitwiseLeftShift.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/function/BitwiseLeftShift.kt index 3a21252c3..83b230837 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/function/BitwiseLeftShift.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/function/BitwiseLeftShift.kt @@ -14,5 +14,4 @@ object BitwiseLeftShift : IntegersBinaryMathFunction("<<") { override fun mathFunction(integer1: Integer, integer2: Integer, context: ExecutionContext): Numeric = Numeric.of(integer1.value.shl(integer2.value.toInt())) - } diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/function/Exponentiation.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/function/Exponentiation.kt index 3540061ba..c5bb7c7c8 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/function/Exponentiation.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/function/Exponentiation.kt @@ -8,7 +8,6 @@ import it.unibo.tuprolog.solve.function.BinaryMathFunction import org.gciatto.kt.math.BigDecimal import kotlin.math.pow - /** * Implementation of `'**'/2` arithmetic functor * diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/function/FloatingPointDivision.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/function/FloatingPointDivision.kt index 66647c928..0c52af588 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/function/FloatingPointDivision.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/function/FloatingPointDivision.kt @@ -35,6 +35,4 @@ object FloatingPointDivision : BinaryMathFunction("/") { } else { Numeric.of(dividend.div(divisor, MathContext())!!) } - - } diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/function/IntegerDivision.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/function/IntegerDivision.kt index c34edccb3..ed5a57038 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/function/IntegerDivision.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/function/IntegerDivision.kt @@ -20,5 +20,4 @@ object IntegerDivision : IntegersBinaryMathFunction("//") { } else { Numeric.of(integer1.value / integer2.value) } - } diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/function/Multiplication.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/function/Multiplication.kt index 42b909152..fa6fcb0b1 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/function/Multiplication.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/function/Multiplication.kt @@ -31,5 +31,4 @@ object Multiplication : BinaryMathFunction("*") { private fun commonBehaviour(decimal1: BigDecimal, decimal2: BigDecimal): Real = // TODO: 25/10/2019 "float_overflow" and "underflow" checks missing (see the standard) Numeric.of(decimal1 * decimal2) - } diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/magic/MagicCut.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/magic/MagicCut.kt index ffe62e4b4..789074c65 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/magic/MagicCut.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/magic/MagicCut.kt @@ -1,6 +1,10 @@ package it.unibo.tuprolog.solve.stdlib.magic -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Scope +import it.unibo.tuprolog.core.Substitution +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.TermVisitor object MagicCut : Atom by Atom.of("!") { @@ -24,4 +28,4 @@ object MagicCut : Atom by Atom.of("!") { override fun apply(substitution: Substitution, vararg substitutions: Substitution): Term = this override fun accept(visitor: TermVisitor): T = visitor.visit(this) -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/magic/MagicTerm.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/magic/MagicTerm.kt index 49915383f..5c6f752b4 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/magic/MagicTerm.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/magic/MagicTerm.kt @@ -2,4 +2,4 @@ package it.unibo.tuprolog.solve.stdlib.magic import it.unibo.tuprolog.core.Term -interface MagicTerm : Term \ No newline at end of file +interface MagicTerm : Term diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Abolish.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Abolish.kt index b3363b99b..1c8b7ba16 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Abolish.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Abolish.kt @@ -1,14 +1,10 @@ package it.unibo.tuprolog.solve.stdlib.primitive -import it.unibo.tuprolog.core.* -import it.unibo.tuprolog.core.Clause +import it.unibo.tuprolog.core.Indicator +import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.solve.ExecutionContext import it.unibo.tuprolog.solve.Signature -import it.unibo.tuprolog.solve.exception.error.PermissionError import it.unibo.tuprolog.solve.exception.error.PermissionError.Operation.MODIFY -import it.unibo.tuprolog.solve.exception.error.PermissionError.Permission.PRIVATE_PROCEDURE -import it.unibo.tuprolog.solve.exception.error.PermissionError.Permission.STATIC_PROCEDURE -import it.unibo.tuprolog.solve.extractSignature import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.primitive.UnaryPredicate @@ -22,4 +18,4 @@ object Abolish : UnaryPredicate.NonBacktrackable("abolish") { removeDynamicClauses(clausesToBeRemoved) } } -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/AbstractAssert.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/AbstractAssert.kt index b0f4b0253..2b46dfd4e 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/AbstractAssert.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/AbstractAssert.kt @@ -1,14 +1,12 @@ package it.unibo.tuprolog.solve.stdlib.primitive -import it.unibo.tuprolog.core.* import it.unibo.tuprolog.core.Clause +import it.unibo.tuprolog.core.Fact +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.prepareForExecution import it.unibo.tuprolog.solve.ExecutionContext -import it.unibo.tuprolog.solve.Signature -import it.unibo.tuprolog.solve.exception.error.PermissionError import it.unibo.tuprolog.solve.exception.error.PermissionError.Operation.MODIFY -import it.unibo.tuprolog.solve.exception.error.PermissionError.Permission.PRIVATE_PROCEDURE -import it.unibo.tuprolog.solve.exception.error.PermissionError.Permission.STATIC_PROCEDURE -import it.unibo.tuprolog.solve.extractSignature import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.primitive.UnaryPredicate @@ -29,4 +27,4 @@ abstract class AbstractAssert( addDynamicClauses(clause.prepareForExecution(), onTop = before) } } -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Arg.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Arg.kt index f26a3ded8..716e80ccc 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Arg.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Arg.kt @@ -1,8 +1,10 @@ package it.unibo.tuprolog.solve.stdlib.primitive -import it.unibo.tuprolog.core.* -import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Substitution +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.solve.ExecutionContext import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.primitive.TernaryRelation @@ -43,6 +45,4 @@ object Arg : TernaryRelation.WithoutSideEffects("arg") { } } } - - -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Assert.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Assert.kt index 89a224074..280019d67 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Assert.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Assert.kt @@ -1,3 +1,3 @@ package it.unibo.tuprolog.solve.stdlib.primitive -object Assert : AbstractAssert("", false) \ No newline at end of file +object Assert : AbstractAssert("", false) diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/AssertA.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/AssertA.kt index e2a9b5504..7c7417b2a 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/AssertA.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/AssertA.kt @@ -1,3 +1,3 @@ package it.unibo.tuprolog.solve.stdlib.primitive -object AssertA : AbstractAssert("a", true) \ No newline at end of file +object AssertA : AbstractAssert("a", true) diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/AssertZ.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/AssertZ.kt index db3156321..7de1dfc31 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/AssertZ.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/AssertZ.kt @@ -1,3 +1,3 @@ package it.unibo.tuprolog.solve.stdlib.primitive -object AssertZ : AbstractAssert("z", false) \ No newline at end of file +object AssertZ : AbstractAssert("z", false) diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Atom.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Atom.kt index 1ca808412..35980e78a 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Atom.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Atom.kt @@ -6,4 +6,4 @@ import it.unibo.tuprolog.solve.primitive.TypeTester object Atom : TypeTester("atom") { override fun testType(term: Term): Boolean = term is it.unibo.tuprolog.core.Atom -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/AtomChars.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/AtomChars.kt index 25e2583bf..a53b3c2c9 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/AtomChars.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/AtomChars.kt @@ -47,4 +47,4 @@ object AtomChars : BinaryRelation.Functional("atom_chars") { chars mguWith second } } -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Atomic.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Atomic.kt index c476392ac..c195bfe6e 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Atomic.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Atomic.kt @@ -7,4 +7,4 @@ import it.unibo.tuprolog.solve.primitive.TypeTester object Atomic : TypeTester("atomic") { override fun testType(term: Term): Boolean = term is Constant -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Between.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Between.kt index 11c8a4c99..5f8501224 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Between.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Between.kt @@ -10,7 +10,6 @@ import it.unibo.tuprolog.solve.primitive.TernaryRelation import org.gciatto.kt.math.BigInteger import it.unibo.tuprolog.core.Integer as LogicInteger - object Between : TernaryRelation.WithoutSideEffects("between") { override fun Solve.Request.computeAllSubstitutions( @@ -51,4 +50,4 @@ object Between : TernaryRelation.WithoutSideEffects("between") } } } -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Callable.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Callable.kt index e356bf1b4..a0f32dc76 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Callable.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Callable.kt @@ -7,4 +7,4 @@ import it.unibo.tuprolog.solve.primitive.TypeTester object Callable : TypeTester("callable") { override fun testType(term: Term): Boolean = term is Struct -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Clause.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Clause.kt index 4cc10cab4..c94987942 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Clause.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Clause.kt @@ -35,5 +35,4 @@ object Clause : BinaryRelation.WithoutSideEffects("clause") { it.isSuccess } } - -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Compound.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Compound.kt index 65be57249..a651a8d11 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Compound.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Compound.kt @@ -8,4 +8,4 @@ import it.unibo.tuprolog.solve.primitive.TypeTester object Compound : TypeTester("compound") { override fun testType(term: Term): Boolean = term is Struct && term.arity > 0 -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/CopyTerm.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/CopyTerm.kt index 31b1383c1..c440c747c 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/CopyTerm.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/CopyTerm.kt @@ -10,5 +10,4 @@ import it.unibo.tuprolog.unify.Unificator.Companion.mguWith object CopyTerm : BinaryRelation.Functional("copy_term") { override fun Solve.Request.computeOneSubstitution(first: Term, second: Term): Substitution = first.freshCopy() mguWith second - -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/CurrentOp.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/CurrentOp.kt index 3045fe1f4..7815d4058 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/CurrentOp.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/CurrentOp.kt @@ -24,4 +24,4 @@ object CurrentOp : TernaryRelation.WithoutSideEffects("current }.filter { it.all { sub -> sub is Substitution.Unifier } }.map { it.reduce(Substitution::plus) } -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/CurrentPrologFlag.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/CurrentPrologFlag.kt index 427e6193e..d2135c14a 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/CurrentPrologFlag.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/CurrentPrologFlag.kt @@ -17,4 +17,4 @@ object CurrentPrologFlag : BinaryRelation.WithoutSideEffects(" .map { (k, v) -> Atom.of(k) to v } .map { (k, v) -> (k mguWith first) + (v mguWith second) } .filter { it.isSuccess } -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/EnsureExecutable.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/EnsureExecutable.kt index 94801f268..173644949 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/EnsureExecutable.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/EnsureExecutable.kt @@ -24,5 +24,4 @@ object EnsureExecutable : TypeEnsurer("ensure_executable") { } } } - -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/FindAll.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/FindAll.kt index 9ec7ed48e..919a349de 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/FindAll.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/FindAll.kt @@ -23,4 +23,4 @@ object FindAll : TernaryRelation.NonBacktrackable("findall") { .map { first[it.substitution].freshCopy() } return replyWith(third mguWith LogicList.from(mapped)) } -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Float.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Float.kt index 65067d1a3..f7f2c041d 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Float.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Float.kt @@ -7,4 +7,4 @@ import it.unibo.tuprolog.solve.primitive.TypeTester object Float : TypeTester("float") { override fun testType(term: Term): Boolean = term is Real -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Functor.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Functor.kt index 060bb100c..ff71ce001 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Functor.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Functor.kt @@ -1,15 +1,16 @@ package it.unibo.tuprolog.solve.stdlib.primitive -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.Substitution +import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.solve.ExecutionContext -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.exception.error.InstantiationError -import it.unibo.tuprolog.solve.exception.error.RepresentationError import it.unibo.tuprolog.solve.exception.error.TypeError -import it.unibo.tuprolog.solve.flags.MaxArity +import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.primitive.TernaryRelation import it.unibo.tuprolog.unify.Unificator.Companion.mguWith import org.gciatto.kt.math.BigInteger @@ -67,4 +68,4 @@ object Functor : TernaryRelation.Functional("functor") { throw TypeError.forArgument(context, signature, TypeError.Expected.CALLABLE, first, 0) } } -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Ground.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Ground.kt index ccda28eab..6e5a6470b 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Ground.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Ground.kt @@ -6,4 +6,4 @@ import it.unibo.tuprolog.solve.primitive.TypeTester object Ground : TypeTester("ground") { override fun testType(term: Term): Boolean = term.isGround -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Halt.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Halt.kt index eae8e69f6..0455e1ee2 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Halt.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Halt.kt @@ -1,9 +1,9 @@ package it.unibo.tuprolog.solve.stdlib.primitive import it.unibo.tuprolog.solve.ExecutionContext -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.exception.HaltException import it.unibo.tuprolog.solve.primitive.PredicateWithoutArguments +import it.unibo.tuprolog.solve.primitive.Solve /** * Implementation of primitive handling `halt/0` behaviour diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Integer.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Integer.kt index a51144a97..43c977fde 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Integer.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Integer.kt @@ -6,4 +6,4 @@ import it.unibo.tuprolog.solve.primitive.TypeTester object Integer : TypeTester("integer") { override fun testType(term: Term): Boolean = term is it.unibo.tuprolog.core.Integer -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Is.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Is.kt index 5da72cccf..aee005f2b 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Is.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Is.kt @@ -3,10 +3,9 @@ package it.unibo.tuprolog.solve.stdlib.primitive import it.unibo.tuprolog.core.Substitution import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.solve.ExecutionContext -import it.unibo.tuprolog.solve.primitive.Solve -import it.unibo.tuprolog.solve.function.ArithmeticEvaluator import it.unibo.tuprolog.solve.function.evalAsExpression import it.unibo.tuprolog.solve.primitive.BinaryRelation +import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.unify.Unificator.Companion.mguWith /** @@ -20,5 +19,4 @@ object Is : BinaryRelation.Functional("is") { ensuringArgumentIsInstantiated(1).run { first mguWith second.evalAsExpression(this, 1) } - } diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Natural.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Natural.kt index 501df5f42..b1544dbce 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Natural.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Natural.kt @@ -22,5 +22,4 @@ object Natural : UnaryPredicate("natural") { private fun checkValue(value: Integer): Boolean = value.intValue.signum >= 0 - -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/NewLine.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/NewLine.kt index 4be517dd7..3b94c9d66 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/NewLine.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/NewLine.kt @@ -1,8 +1,8 @@ package it.unibo.tuprolog.solve.stdlib.primitive import it.unibo.tuprolog.solve.ExecutionContext -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.primitive.PredicateWithoutArguments +import it.unibo.tuprolog.solve.primitive.Solve object NewLine : PredicateWithoutArguments.NonBacktrackable("nl") { override fun Solve.Request.computeOne(): Solve.Response { @@ -15,4 +15,4 @@ object NewLine : PredicateWithoutArguments.NonBacktrackable("n } } } -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/NonVar.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/NonVar.kt index 9932a19c5..8c9b7a7d7 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/NonVar.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/NonVar.kt @@ -6,4 +6,4 @@ import it.unibo.tuprolog.solve.primitive.TypeTester object NonVar : TypeTester("nonvar") { override fun testType(term: Term): Boolean = term !is it.unibo.tuprolog.core.Var -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/NotUnifiableWith.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/NotUnifiableWith.kt index a8e81d912..dd979de6f 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/NotUnifiableWith.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/NotUnifiableWith.kt @@ -2,8 +2,8 @@ package it.unibo.tuprolog.solve.stdlib.primitive import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.solve.ExecutionContext -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.primitive.BinaryRelation +import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.unify.Unificator.Companion.matches /** Implementation of '\='/2 predicate */ diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Number.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Number.kt index f5829ef45..a87bfa336 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Number.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Number.kt @@ -7,4 +7,4 @@ import it.unibo.tuprolog.solve.primitive.TypeTester object Number : TypeTester("number") { override fun testType(term: Term): Boolean = term is Numeric -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Op.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Op.kt index 52d6d405e..b30945fdc 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Op.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Op.kt @@ -24,4 +24,4 @@ object Op : TernaryRelation.NonBacktrackable("op") { SideEffect.SetOperators(operator) ) } -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Repeat.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Repeat.kt index dfb231d65..c00bb9cfd 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Repeat.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Repeat.kt @@ -8,4 +8,4 @@ import it.unibo.tuprolog.solve.primitive.Solve object Repeat : PredicateWithoutArguments.WithoutSideEffects("repeat") { override fun Solve.Request.computeAllSubstitutions(): Sequence = generateSequence(Substitution.empty()) { Substitution.empty() } -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Retract.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Retract.kt index a9577f986..81953e8c1 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Retract.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Retract.kt @@ -1,13 +1,13 @@ package it.unibo.tuprolog.solve.stdlib.primitive -import it.unibo.tuprolog.core.* -import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.core.Clause +import it.unibo.tuprolog.core.Rule +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Substitution +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.solve.ExecutionContext -import it.unibo.tuprolog.solve.Signature -import it.unibo.tuprolog.solve.exception.error.DomainError import it.unibo.tuprolog.solve.exception.error.PermissionError -import it.unibo.tuprolog.solve.extractSignature import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.primitive.UnaryPredicate import it.unibo.tuprolog.unify.Unificator.Companion.mguWith @@ -32,4 +32,4 @@ object Retract : UnaryPredicate("retract") { } } } -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/RetractAll.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/RetractAll.kt index ca01723a8..8c89872ab 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/RetractAll.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/RetractAll.kt @@ -1,8 +1,10 @@ package it.unibo.tuprolog.solve.stdlib.primitive -import it.unibo.tuprolog.core.* -import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.core.Clause +import it.unibo.tuprolog.core.Rule +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.solve.ExecutionContext import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.primitive.UnaryPredicate @@ -23,6 +25,5 @@ object RetractAll : UnaryPredicate.NonBacktrackable("retractal replySuccess() } } - } -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Sleep.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Sleep.kt index 294b610ec..e89f18f6b 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Sleep.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Sleep.kt @@ -3,9 +3,9 @@ package it.unibo.tuprolog.solve.stdlib.primitive import it.unibo.tuprolog.core.Integer import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.solve.ExecutionContext -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.currentTimeInstant import it.unibo.tuprolog.solve.exception.TimeOutException +import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.primitive.UnaryPredicate /** @@ -20,8 +20,9 @@ object Sleep : UnaryPredicate("sleep") { .ensuringArgumentIsInteger(0).let { val initialTime = currentTimeInstant() val threshold = arguments[0].castTo().intValue.toLongExact() - while (currentTimeInstant() - initialTime < threshold); - yield(replySuccess()) + while (currentTimeInstant() - initialTime < threshold) { + yield(replySuccess()) + } } } -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermGreaterThan.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermGreaterThan.kt index a199d1d02..804253ffd 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermGreaterThan.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermGreaterThan.kt @@ -2,8 +2,8 @@ package it.unibo.tuprolog.solve.stdlib.primitive import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.solve.ExecutionContext -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.primitive.BinaryRelation +import it.unibo.tuprolog.solve.primitive.Solve /** Implementation of '@>'/2 predicate */ object TermGreaterThan : BinaryRelation.Predicative("@>") { diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermGreaterThanOrEqualTo.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermGreaterThanOrEqualTo.kt index e149649dc..55399c968 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermGreaterThanOrEqualTo.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermGreaterThanOrEqualTo.kt @@ -2,8 +2,8 @@ package it.unibo.tuprolog.solve.stdlib.primitive import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.solve.ExecutionContext -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.primitive.BinaryRelation +import it.unibo.tuprolog.solve.primitive.Solve /** Implementation of '@>='/2 predicate */ object TermGreaterThanOrEqualTo : BinaryRelation.Predicative("@>=") { diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermIdentical.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermIdentical.kt index 459694e87..b3d4bf9b6 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermIdentical.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermIdentical.kt @@ -2,8 +2,8 @@ package it.unibo.tuprolog.solve.stdlib.primitive import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.solve.ExecutionContext -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.primitive.BinaryRelation +import it.unibo.tuprolog.solve.primitive.Solve /** Implementation of '=='/2 predicate */ object TermIdentical : BinaryRelation.Predicative("==") { diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermLowerThan.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermLowerThan.kt index 3b7ea89b3..a34e180a8 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermLowerThan.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermLowerThan.kt @@ -2,8 +2,8 @@ package it.unibo.tuprolog.solve.stdlib.primitive import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.solve.ExecutionContext -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.primitive.BinaryRelation +import it.unibo.tuprolog.solve.primitive.Solve /** Implementation of '@<'/2 predicate */ object TermLowerThan : BinaryRelation.Predicative("@<") { diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermLowerThanOrEqualTo.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermLowerThanOrEqualTo.kt index ce9091a5e..70fb14076 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermLowerThanOrEqualTo.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermLowerThanOrEqualTo.kt @@ -2,8 +2,8 @@ package it.unibo.tuprolog.solve.stdlib.primitive import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.solve.ExecutionContext -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.primitive.BinaryRelation +import it.unibo.tuprolog.solve.primitive.Solve /** Implementation of '@=<'/2 predicate */ object TermLowerThanOrEqualTo : BinaryRelation.Predicative("@=<") { diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermNotIdentical.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermNotIdentical.kt index 4e854f2d8..11ac3dde1 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermNotIdentical.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermNotIdentical.kt @@ -2,8 +2,8 @@ package it.unibo.tuprolog.solve.stdlib.primitive import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.solve.ExecutionContext -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.primitive.BinaryRelation +import it.unibo.tuprolog.solve.primitive.Solve /** Implementation of `'\=='/2` predicate */ object TermNotIdentical : BinaryRelation.Predicative("\\==") { diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermNotSame.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermNotSame.kt index e6f36f7ce..9902925e8 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermNotSame.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermNotSame.kt @@ -2,8 +2,8 @@ package it.unibo.tuprolog.solve.stdlib.primitive import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.solve.ExecutionContext -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.primitive.BinaryRelation +import it.unibo.tuprolog.solve.primitive.Solve /** Implementation of '=='/2 predicate */ object TermNotSame : BinaryRelation.Predicative("\\=@=") { diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermSame.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermSame.kt index 3d799c4eb..03d39d4b4 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermSame.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermSame.kt @@ -2,8 +2,8 @@ package it.unibo.tuprolog.solve.stdlib.primitive import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.solve.ExecutionContext -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.primitive.BinaryRelation +import it.unibo.tuprolog.solve.primitive.Solve /** Implementation of '=='/2 predicate */ object TermSame : BinaryRelation.Predicative("=@=") { diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/UnifiesWith.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/UnifiesWith.kt index 9cdfec4ea..30c7ca8a0 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/UnifiesWith.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/UnifiesWith.kt @@ -3,8 +3,8 @@ package it.unibo.tuprolog.solve.stdlib.primitive import it.unibo.tuprolog.core.Substitution import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.solve.ExecutionContext -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.primitive.BinaryRelation +import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.unify.Unificator.Companion.mguWith /** Implementation of '='/2 predicate */ diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Univ.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Univ.kt index bb66e59e0..d4eb3024f 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Univ.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Univ.kt @@ -1,13 +1,15 @@ package it.unibo.tuprolog.solve.stdlib.primitive -import it.unibo.tuprolog.core.* import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Substitution +import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.solve.ExecutionContext -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.exception.error.InstantiationError import it.unibo.tuprolog.solve.exception.error.TypeError import it.unibo.tuprolog.solve.primitive.BinaryRelation +import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.unify.Unificator.Companion.mguWith import it.unibo.tuprolog.core.List as LogicList import kotlin.collections.listOf as ktListOf diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Var.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Var.kt index 77dcb1fe4..35f58b34f 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Var.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Var.kt @@ -6,4 +6,4 @@ import it.unibo.tuprolog.solve.primitive.TypeTester object Var : TypeTester("var") { override fun testType(term: Term): Boolean = term is it.unibo.tuprolog.core.Var -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Write.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Write.kt index f27fd6b21..715a97a16 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Write.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Write.kt @@ -21,4 +21,4 @@ object Write : UnaryPredicate.NonBacktrackable("write") { } } } -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Append.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Append.kt index c3c901137..1a399aa5e 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Append.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Append.kt @@ -39,4 +39,4 @@ sealed class Append : RuleWrapper(FUNCTOR, ARITY) { val SIGNATURE: Signature get() = Signature(FUNCTOR, ARITY) } -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Arrow.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Arrow.kt index 7e0db071c..3506fee30 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Arrow.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Arrow.kt @@ -17,5 +17,4 @@ object Arrow : RuleWrapper("->", 2) { MagicCut, varOf("Then") ) - -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Member.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Member.kt index 95fd53e39..d42251991 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Member.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Member.kt @@ -37,4 +37,4 @@ sealed class Member : RuleWrapper(FUNCTOR, ARITY) { val SIGNATURE: Signature get() = Signature(FUNCTOR, ARITY) } -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Not.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Not.kt index dc414158d..b6c3d7a39 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Not.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Not.kt @@ -17,4 +17,4 @@ object Not : RuleWrapper("not", 1) { structOf(EnsureExecutable.functor, varOf("G")), structOf("\\+", varOf("G")) ) -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Once.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Once.kt index ef1d0b257..48394101e 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Once.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Once.kt @@ -19,4 +19,4 @@ object Once : RuleWrapper("once", 1) { structOf("call", varOf("G")), atomOf("!") ) -} \ No newline at end of file +} diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Semicolon.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Semicolon.kt index ec80d0ae2..28abbf5e3 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Semicolon.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Semicolon.kt @@ -6,7 +6,6 @@ import it.unibo.tuprolog.solve.ExecutionContext import it.unibo.tuprolog.solve.Signature import it.unibo.tuprolog.solve.rule.RuleWrapper import it.unibo.tuprolog.solve.stdlib.magic.MagicCut -import it.unibo.tuprolog.solve.stdlib.primitive.EnsureExecutable import kotlin.collections.List as KtList import kotlin.collections.listOf as ktListOf @@ -38,7 +37,6 @@ sealed class Semicolon : RuleWrapper(FUNCTOR, ARITY) { varOf("Else") ) } - } sealed class Or : Semicolon() { @@ -62,4 +60,4 @@ sealed class Semicolon : RuleWrapper(FUNCTOR, ARITY) { val SIGNATURE: Signature get() = Signature(FUNCTOR, ARITY) } -} \ No newline at end of file +} diff --git a/solve/src/jsMain/kotlin/it/unibo/tuprolog/solve/channel/Channels.kt b/solve/src/jsMain/kotlin/it/unibo/tuprolog/solve/channel/Channels.kt index 5268c80be..3067dfd91 100644 --- a/solve/src/jsMain/kotlin/it/unibo/tuprolog/solve/channel/Channels.kt +++ b/solve/src/jsMain/kotlin/it/unibo/tuprolog/solve/channel/Channels.kt @@ -12,4 +12,4 @@ internal actual fun stdout(): OutputChannel = OutputChannel.of { print(it) } internal actual fun warning(): OutputChannel = - OutputChannel.of { console.warn(it.message) } \ No newline at end of file + OutputChannel.of { console.warn(it.message) } diff --git a/solve/src/jvmMain/kotlin/it/unibo/tuprolog/solve/channel/Channels.kt b/solve/src/jvmMain/kotlin/it/unibo/tuprolog/solve/channel/Channels.kt index 7ad485e86..a2d4055ae 100644 --- a/solve/src/jvmMain/kotlin/it/unibo/tuprolog/solve/channel/Channels.kt +++ b/solve/src/jvmMain/kotlin/it/unibo/tuprolog/solve/channel/Channels.kt @@ -16,4 +16,4 @@ internal actual fun stdout(): OutputChannel { internal actual fun warning(): OutputChannel { return OutputChannel.of { System.err.println(it.message) } -} \ No newline at end of file +} diff --git a/solve/src/jvmMain/kotlin/it/unibo/tuprolog/solve/channel/InputStreamChannel.kt b/solve/src/jvmMain/kotlin/it/unibo/tuprolog/solve/channel/InputStreamChannel.kt index 7f0142b76..9a3f090f9 100644 --- a/solve/src/jvmMain/kotlin/it/unibo/tuprolog/solve/channel/InputStreamChannel.kt +++ b/solve/src/jvmMain/kotlin/it/unibo/tuprolog/solve/channel/InputStreamChannel.kt @@ -6,7 +6,7 @@ import java.io.InputStream import java.io.InputStreamReader import java.io.Reader -class InputStreamChannel(inputStream: InputStream) : AbstractInputChannel() { +class InputStreamChannel(inputStream: InputStream) : AbstractInputChannel() { private val reader: Reader by lazy { BufferedReader(InputStreamReader(inputStream)) @@ -18,4 +18,4 @@ class InputStreamChannel(inputStream: InputStream) : AbstractInputChannel Date: Mon, 14 Sep 2020 15:05:33 +0200 Subject: [PATCH 10/34] format code in :solve-classic --- .../tuprolog/solve/ChoicePointContext.kt | 20 +++++----- .../tuprolog/solve/ClassicExecutionContext.kt | 39 +++++++++++-------- .../it/unibo/tuprolog/solve/ClassicSolver.kt | 1 - .../tuprolog/solve/ClassicSolverFactory.kt | 2 +- .../tuprolog/solve/MutableClassicSolver.kt | 3 +- .../unibo/tuprolog/solve/SolutionIterator.kt | 2 +- .../unibo/tuprolog/solve/SolverExtensions.kt | 3 +- .../tuprolog/solve/fsm/AbstractEndState.kt | 2 +- .../unibo/tuprolog/solve/fsm/AbstractState.kt | 1 - .../it/unibo/tuprolog/solve/fsm/EndState.kt | 2 +- .../tuprolog/solve/fsm/ExceptionalState.kt | 2 +- .../it/unibo/tuprolog/solve/fsm/State.kt | 2 - .../tuprolog/solve/fsm/StateBacktracking.kt | 2 +- .../it/unibo/tuprolog/solve/fsm/StateEnd.kt | 2 +- .../tuprolog/solve/fsm/StateException.kt | 3 +- .../tuprolog/solve/fsm/StateGoalSelection.kt | 3 +- .../it/unibo/tuprolog/solve/fsm/StateHalt.kt | 5 ++- .../it/unibo/tuprolog/solve/fsm/StateInit.kt | 2 +- .../solve/fsm/StatePrimitiveExecution.kt | 4 +- .../solve/fsm/StatePrimitiveSelection.kt | 4 +- .../tuprolog/solve/fsm/StateRuleExecution.kt | 2 +- .../tuprolog/solve/fsm/StateRuleSelection.kt | 31 ++++++++------- .../it/unibo/tuprolog/solve/fsm/Utils.kt | 15 +++++-- .../tuprolog/solve/stdlib/DefaultBuiltins.kt | 2 +- .../tuprolog/solve/stdlib/primitive/Throw.kt | 4 +- .../unibo/tuprolog/solve/stdlib/rule/Call.kt | 2 +- .../unibo/tuprolog/solve/stdlib/rule/Catch.kt | 2 +- .../unibo/tuprolog/solve/stdlib/rule/Comma.kt | 2 +- .../unibo/tuprolog/solve/stdlib/rule/Cut.kt | 2 +- .../solve/stdlib/rule/NegationAsFailure.kt | 2 +- .../solve/stdlib/rule/SpecificRules.kt | 2 +- .../solve/systemtest/TestClassicAbolish.kt | 3 +- .../solve/systemtest/TestClassicAnd.kt | 13 ++----- .../solve/systemtest/TestClassicArg.kt | 39 ++++++++----------- .../solve/systemtest/TestClassicArith.kt | 12 ++---- .../solve/systemtest/TestClassicAssertA.kt | 4 +- .../solve/systemtest/TestClassicAssertZ.kt | 4 +- .../solve/systemtest/TestClassicAtom.kt | 23 +++++------ .../solve/systemtest/TestClassicAtomic.kt | 21 ++++------ .../solve/systemtest/TestClassicCall.kt | 7 ++-- .../systemtest/TestClassicCatchAndThrow.kt | 4 +- .../solve/systemtest/TestClassicClause.kt | 5 +-- .../solve/systemtest/TestClassicCompound.kt | 4 +- .../solve/systemtest/TestClassicCopyTerm.kt | 5 +-- .../solve/systemtest/TestClassicCut.kt | 4 +- .../solve/systemtest/TestClassicFail.kt | 5 +-- .../solve/systemtest/TestClassicFindAll.kt | 27 ++++++------- .../solve/systemtest/TestClassicFloat.kt | 4 +- .../solve/systemtest/TestClassicFunctor.kt | 7 ++-- .../solve/systemtest/TestClassicIfThen.kt | 4 +- .../solve/systemtest/TestClassicIfThenElse.kt | 4 +- .../solve/systemtest/TestClassicInteger.kt | 13 ++----- .../solve/systemtest/TestClassicIs.kt | 6 +-- .../solve/systemtest/TestClassicNonVar.kt | 13 ++----- .../systemtest/TestClassicNotProvable.kt | 5 +-- .../solve/systemtest/TestClassicNotUnify.kt | 14 ++----- .../solve/systemtest/TestClassicNumber.kt | 3 +- .../solve/systemtest/TestClassicOnce.kt | 5 +-- .../solve/systemtest/TestClassicOr.kt | 15 ++----- .../solve/systemtest/TestClassicRepeat.kt | 4 +- .../solve/systemtest/TestClassicRetract.kt | 5 +-- .../solve/systemtest/TestClassicSolver.kt | 5 ++- .../solve/systemtest/TestClassicTerm.kt | 3 +- .../solve/systemtest/TestClassicTrue.kt | 4 +- .../solve/systemtest/TestClassicUnify.kt | 14 ++----- 65 files changed, 207 insertions(+), 271 deletions(-) diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/ChoicePointContext.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/ChoicePointContext.kt index 80d163da5..47dad63d2 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/ChoicePointContext.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/ChoicePointContext.kt @@ -45,15 +45,15 @@ sealed class ChoicePointContext( get() = executionContext?.procedure override fun toString(): String = "$typeName(" + - "alternatives=$alternatives, " + - if (executionContext === null) { - "executionContext=${executionContext}, " - } else { - "executionContextDepth=${executionContextDepth}, " - "executionContextProcedure=${executionContextProcedure}, " - } + - "depth=$depth" + - ")" + "alternatives=$alternatives, " + + if (executionContext === null) { + "executionContext=$executionContext, " + } else { + "executionContextDepth=$executionContextDepth, " + "executionContextProcedure=$executionContextProcedure, " + } + + "depth=$depth" + + ")" protected abstract val typeName: String @@ -144,4 +144,4 @@ fun ChoicePointContext?.appendPrimitives( fun ChoicePointContext?.appendRules( alternatives: Cursor, executionContext: ClassicExecutionContext? = null -): ChoicePointContext? = ChoicePointContext.Rules(alternatives, executionContext, this, nextDepth()) \ No newline at end of file +): ChoicePointContext? = ChoicePointContext.Rules(alternatives, executionContext, this, nextDepth()) diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/ClassicExecutionContext.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/ClassicExecutionContext.kt index ee98d3958..0c81faced 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/ClassicExecutionContext.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/ClassicExecutionContext.kt @@ -1,6 +1,11 @@ package it.unibo.tuprolog.solve -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Rule +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Substitution +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.Truth +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.core.operators.OperatorSet import it.unibo.tuprolog.solve.channel.InputChannel import it.unibo.tuprolog.solve.channel.OutputChannel @@ -125,20 +130,20 @@ data class ClassicExecutionContext( override fun toString(): String { return "ClassicExecutionContext(" + - "query=$query, " + - "procedure=$procedure, " + - "substitution=$substitution, " + - "goals=$goals, " + - "rules=$rules, " + - "primitives=$primitives, " + - "startTime=$startTime, " + - "operators=${operators.joinToString(",", "{", "}") { "'${it.functor}':${it.specifier}" }}, " + - "inputChannels=${inputChannels.keys}, " + - "outputChannels=${outputChannels.keys}, " + - "maxDuration=$maxDuration, " + - "choicePoints=$choicePoints, " + - "depth=$depth, " + - "step=$step" + - ")" + "query=$query, " + + "procedure=$procedure, " + + "substitution=$substitution, " + + "goals=$goals, " + + "rules=$rules, " + + "primitives=$primitives, " + + "startTime=$startTime, " + + "operators=${operators.joinToString(",", "{", "}") { "'${it.functor}':${it.specifier}" }}, " + + "inputChannels=${inputChannels.keys}, " + + "outputChannels=${outputChannels.keys}, " + + "maxDuration=$maxDuration, " + + "choicePoints=$choicePoints, " + + "depth=$depth, " + + "step=$step" + + ")" } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/ClassicSolver.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/ClassicSolver.kt index 5c547f580..f3f7bd63e 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/ClassicSolver.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/ClassicSolver.kt @@ -57,7 +57,6 @@ internal open class ClassicSolver( require(newState.context.step == newStep) state = newState }.asSequence() - } override val libraries: Libraries diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/ClassicSolverFactory.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/ClassicSolverFactory.kt index 567705c7e..c55aa2d11 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/ClassicSolverFactory.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/ClassicSolverFactory.kt @@ -54,4 +54,4 @@ object ClassicSolverFactory : SolverFactory { mapOf(STDIN to stdIn), mapOf(STDOUT to stdOut, STDERR to stdErr, WARNINGS to warnings) ) -} \ No newline at end of file +} diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/MutableClassicSolver.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/MutableClassicSolver.kt index e7943ce2d..bb2f42115 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/MutableClassicSolver.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/MutableClassicSolver.kt @@ -125,5 +125,4 @@ internal class MutableClassicSolver( } return result } - -} \ No newline at end of file +} diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/SolutionIterator.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/SolutionIterator.kt index 7a8726ca4..0365e71fe 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/SolutionIterator.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/SolutionIterator.kt @@ -42,4 +42,4 @@ internal class SolutionIterator( private fun Substitution.Unifier.cleanUp(toRetain: Set): Substitution.Unifier { return filter { _, term -> (term !is Var) || (term in toRetain) } } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/SolverExtensions.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/SolverExtensions.kt index 7ad672561..d2e483d0a 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/SolverExtensions.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/SolverExtensions.kt @@ -1,4 +1,5 @@ @file:JvmName("SolverExtensions") + package it.unibo.tuprolog.solve import it.unibo.tuprolog.solve.channel.InputChannel @@ -59,4 +60,4 @@ fun MutableSolver.Companion.classicWithDefaultBuiltins( stdErr: OutputChannel = ClassicSolverFactory.defaultErrorChannel, warnings: OutputChannel = ClassicSolverFactory.defaultWarningsChannel ): MutableSolver = - ClassicSolverFactory.mutableSolverWithDefaultBuiltins(libraries, flags, staticKb, dynamicKb, stdIn, stdOut, stdErr, warnings) \ No newline at end of file + ClassicSolverFactory.mutableSolverWithDefaultBuiltins(libraries, flags, staticKb, dynamicKb, stdIn, stdOut, stdErr, warnings) diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/AbstractEndState.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/AbstractEndState.kt index be40bab8e..de4df544b 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/AbstractEndState.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/AbstractEndState.kt @@ -9,4 +9,4 @@ internal abstract class AbstractEndState( ) : EndState, AbstractState(context) { override fun computeNext(): State = throw NoSuchElementException() -} \ No newline at end of file +} diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/AbstractState.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/AbstractState.kt index 35993cb9e..939049f68 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/AbstractState.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/AbstractState.kt @@ -39,4 +39,3 @@ internal abstract class AbstractState(override val context: ClassicExecutionCont protected fun previousDepth(): Int = context.depth - 1 } - diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/EndState.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/EndState.kt index 315383f96..73f01da4e 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/EndState.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/EndState.kt @@ -8,4 +8,4 @@ interface EndState : State { val hasOpenAlternatives: Boolean get() = solution is Solution.Yes && context.hasOpenAlternatives -} \ No newline at end of file +} diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/ExceptionalState.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/ExceptionalState.kt index 8c8a73887..74afd73e6 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/ExceptionalState.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/ExceptionalState.kt @@ -4,4 +4,4 @@ import it.unibo.tuprolog.solve.exception.TuPrologRuntimeException interface ExceptionalState : State { val exception: TuPrologRuntimeException -} \ No newline at end of file +} diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/State.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/State.kt index 9e1f8a3ab..949d4a60e 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/State.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/State.kt @@ -22,5 +22,3 @@ fun State.clone(context: ClassicExecutionContext = this.context): State = is StateRuleSelection -> copy(context) else -> throw IllegalStateException() } - - diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateBacktracking.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateBacktracking.kt index 5b9732016..e238d79f4 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateBacktracking.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateBacktracking.kt @@ -21,4 +21,4 @@ internal data class StateBacktracking(override val context: ClassicExecutionCont } } } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateEnd.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateEnd.kt index 12dcb2513..4ad2595c6 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateEnd.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateEnd.kt @@ -18,4 +18,4 @@ internal data class StateEnd( super.computeNext() } } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateException.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateException.kt index 86fb0f8a5..4a25c44a9 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateException.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateException.kt @@ -83,5 +83,4 @@ internal data class StateException( else -> finalState } } - -} \ No newline at end of file +} diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateGoalSelection.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateGoalSelection.kt index b491e3fcc..b449a6878 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateGoalSelection.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateGoalSelection.kt @@ -5,7 +5,6 @@ import it.unibo.tuprolog.solve.Solution internal data class StateGoalSelection(override val context: ClassicExecutionContext) : AbstractState(context) { override fun computeNext(): State { - return if (context.goals.isOver) { if (context.isRoot) { StateEnd( @@ -44,4 +43,4 @@ internal data class StateGoalSelection(override val context: ClassicExecutionCon ) } } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateHalt.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateHalt.kt index 511e94860..249711acf 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateHalt.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateHalt.kt @@ -8,5 +8,6 @@ internal data class StateHalt( override val exception: TuPrologRuntimeException, override val context: ClassicExecutionContext ) : ExceptionalState, AbstractEndState( - Solution.Halt(context.query, exception), context -) \ No newline at end of file + Solution.Halt(context.query, exception), + context +) diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateInit.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateInit.kt index 8e96aebca..02c88b6e9 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateInit.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateInit.kt @@ -20,4 +20,4 @@ internal data class StateInit(override val context: ClassicExecutionContext) : A ).appendRulesAndChoicePoints(Cursor.empty()) ) } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StatePrimitiveExecution.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StatePrimitiveExecution.kt index 1e6b44b8a..2d2a4f273 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StatePrimitiveExecution.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StatePrimitiveExecution.kt @@ -24,7 +24,6 @@ internal data class StatePrimitiveExecution(override val context: ClassicExecuti ) } - override fun computeNext(): State = try { when (val sol = context.primitives.current?.solution) { is Solution.Yes -> { @@ -55,5 +54,4 @@ internal data class StatePrimitiveExecution(override val context: ClassicExecuti context.copy(step = nextStep()) ) } - -} \ No newline at end of file +} diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StatePrimitiveSelection.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StatePrimitiveSelection.kt index 485a098e6..82980403f 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StatePrimitiveSelection.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StatePrimitiveSelection.kt @@ -35,7 +35,6 @@ internal data class StatePrimitiveSelection(override val context: ClassicExecuti val signature = goal.extractSignature() if (libraries.hasPrimitive(signature)) { - val req = toRequest(goal, signature) val primitive = libraries.primitives[signature] ?: error("Inconsistent behaviour of Library.contains and Library.get") @@ -69,5 +68,4 @@ internal data class StatePrimitiveSelection(override val context: ClassicExecuti } } } - -} \ No newline at end of file +} diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateRuleExecution.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateRuleExecution.kt index 6670a1424..941b9be52 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateRuleExecution.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateRuleExecution.kt @@ -30,4 +30,4 @@ internal data class StateRuleExecution(override val context: ClassicExecutionCon else -> failureState } } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateRuleSelection.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateRuleSelection.kt index 3763fa958..95aed388e 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateRuleSelection.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/StateRuleSelection.kt @@ -1,6 +1,10 @@ package it.unibo.tuprolog.solve.fsm -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.Truth +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.solve.ChoicePointContext import it.unibo.tuprolog.solve.ClassicExecutionContext import it.unibo.tuprolog.solve.Signature @@ -84,16 +88,16 @@ internal data class StateRuleSelection(override val context: ClassicExecutionCon private fun ClassicExecutionContext.computeCutLimit(magicCut: Boolean = false): CutLimit { val cutLimit = if (magicCut) { - this.pathToRoot.firstOrNull() - } else { - this.pathToRoot.firstOrNull { it.procedure?.extractSignature() !in transparentToCut } - } - return if (cutLimit == null) { - CutLimit.None - } else { - CutLimit.Actual(cutLimit.depth, cutLimit.procedure) - } + this.pathToRoot.firstOrNull() + } else { + this.pathToRoot.firstOrNull { it.procedure?.extractSignature() !in transparentToCut } + } + return if (cutLimit == null) { + CutLimit.None + } else { + CutLimit.Actual(cutLimit.depth, cutLimit.procedure) } + } private fun ChoicePointContext?.performCut(cutLimit: CutLimit): ChoicePointContext? { return when { @@ -101,8 +105,8 @@ internal data class StateRuleSelection(override val context: ClassicExecutionCon null } cutLimit is CutLimit.None || - cutLimit.depthToCut > executionContext!!.depth || - cutLimit.depthToCut == executionContext!!.depth && cutLimit.procedure != executionContext!!.procedure -> { + cutLimit.depthToCut > executionContext!!.depth || + cutLimit.depthToCut == executionContext!!.depth && cutLimit.procedure != executionContext!!.procedure -> { this } else -> { @@ -122,7 +126,6 @@ internal data class StateRuleSelection(override val context: ClassicExecutionCon } override fun computeNext(): State { - return when (val currentGoal = context.currentGoal!!) { is Var -> { exceptionalState( @@ -183,4 +186,4 @@ internal data class StateRuleSelection(override val context: ClassicExecutionCon } } } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/Utils.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/Utils.kt index 87a333f81..3686b66e2 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/Utils.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/fsm/Utils.kt @@ -1,12 +1,19 @@ package it.unibo.tuprolog.solve.fsm -import it.unibo.tuprolog.core.* -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.core.Clause +import it.unibo.tuprolog.core.Rule +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.Tuple +import it.unibo.tuprolog.core.Var +import it.unibo.tuprolog.solve.ClassicExecutionContext +import it.unibo.tuprolog.solve.Signature +import it.unibo.tuprolog.solve.appendPrimitives +import it.unibo.tuprolog.solve.appendRules import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.utils.Cursor import it.unibo.tuprolog.utils.cursor - fun Sequence.ensureRules(): Cursor = @Suppress("USELESS_CAST") map { require(it is Rule); it as Rule }.cursor() @@ -99,4 +106,4 @@ fun ClassicExecutionContext.toRequest( substitution = substitution ), executionMaxDuration = maxDuration - ) \ No newline at end of file + ) diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/DefaultBuiltins.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/DefaultBuiltins.kt index cd1ffb9fc..f16d571d3 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/DefaultBuiltins.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/DefaultBuiltins.kt @@ -18,4 +18,4 @@ object DefaultBuiltins : AliasedLibrary by CommonBuiltins { Throw ).map { it.descriptionPair }.toMap() } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Throw.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Throw.kt index aafc65e92..d1147731f 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Throw.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Throw.kt @@ -3,10 +3,10 @@ package it.unibo.tuprolog.solve.stdlib.primitive import it.unibo.tuprolog.core.Struct import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.solve.ExecutionContext -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.exception.PrologError import it.unibo.tuprolog.solve.exception.TuPrologRuntimeException import it.unibo.tuprolog.solve.exception.error.MessageError +import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.primitive.UnaryPredicate object Throw : UnaryPredicate("throw") { @@ -30,4 +30,4 @@ object Throw : UnaryPredicate("throw") { ) ) } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Call.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Call.kt index 9e22b2270..65f202d47 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Call.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Call.kt @@ -17,4 +17,4 @@ object Call : RuleWrapper("call", 1) { structOf(EnsureExecutable.functor, varOf("G")), varOf("G") ) -} \ No newline at end of file +} diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Catch.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Catch.kt index 501c758a5..badeec0b9 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Catch.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Catch.kt @@ -13,4 +13,4 @@ object Catch : RuleWrapper("catch", 3) { override val Scope.body: Term get() = varOf("G") -} \ No newline at end of file +} diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Comma.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Comma.kt index d14c6c39d..71703c26b 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Comma.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Comma.kt @@ -13,4 +13,4 @@ object Comma : RuleWrapper(",", 2) { override val Scope.body: Term get() = tupleOf(varOf("A"), varOf("B")) -} \ No newline at end of file +} diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Cut.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Cut.kt index 81922a61e..425906960 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Cut.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/Cut.kt @@ -3,4 +3,4 @@ package it.unibo.tuprolog.solve.stdlib.rule import it.unibo.tuprolog.solve.ExecutionContext import it.unibo.tuprolog.solve.rule.RuleWrapper -object Cut : RuleWrapper("!", 0) \ No newline at end of file +object Cut : RuleWrapper("!", 0) diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/NegationAsFailure.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/NegationAsFailure.kt index 90a159fa7..34db896c4 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/NegationAsFailure.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/NegationAsFailure.kt @@ -38,4 +38,4 @@ sealed class NegationAsFailure : RuleWrapper(FUNCTOR, ARITY) { const val ARITY: Int = 1 } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/SpecificRules.kt b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/SpecificRules.kt index f88d34a1f..d28d5dca6 100644 --- a/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/SpecificRules.kt +++ b/solve-classic/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/rule/SpecificRules.kt @@ -15,4 +15,4 @@ object SpecificRules { val theory: Theory = Theory.indexedOf( wrappers.map { it.wrappedImplementation } ) -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicAbolish.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicAbolish.kt index 89088e54f..62c33685e 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicAbolish.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicAbolish.kt @@ -3,7 +3,6 @@ package it.unibo.tuprolog.solve.systemtest import it.unibo.tuprolog.solve.ClassicSolverFactory import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.TestAbolish -import kotlin.test.Ignore import kotlin.test.Test class TestClassicAbolish : TestAbolish, SolverFactory by ClassicSolverFactory { @@ -33,4 +32,4 @@ class TestClassicAbolish : TestAbolish, SolverFactory by ClassicSolverFactory { override fun testAbolish() { prototype.testAbolish() } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicAnd.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicAnd.kt index 62610da5b..78f1f68b8 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicAnd.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicAnd.kt @@ -1,13 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory +import it.unibo.tuprolog.solve.ClassicSolverFactory +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.TestAnd import kotlin.test.Test class TestClassicAnd : TestAnd, SolverFactory by ClassicSolverFactory { @@ -38,4 +33,4 @@ class TestClassicAnd : TestAnd, SolverFactory by ClassicSolverFactory { override fun testTrueVarCallable() { prototype.testTrueVarCallable() } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicArg.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicArg.kt index 4e12e7da5..e79af6964 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicArg.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicArg.kt @@ -1,13 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory +import it.unibo.tuprolog.solve.ClassicSolverFactory +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.TestArg import kotlin.test.Test class TestClassicArg : TestArg, SolverFactory by ClassicSolverFactory { @@ -20,67 +15,67 @@ class TestClassicArg : TestArg, SolverFactory by ClassicSolverFactory { } @Test - override fun testArgFromFooX(){ + override fun testArgFromFooX() { prototype.testArgFromFooX() } @Test - override fun testArgFromFoo2(){ + override fun testArgFromFoo2() { prototype.testArgFromFoo2() } @Test - override fun testArgFromFooInF(){ + override fun testArgFromFooInF() { prototype.testArgFromFooInF() } @Test - override fun testArgFromFooY(){ + override fun testArgFromFooY() { prototype.testArgFromFooY() } @Test - override fun testArgFromFooInSecondTerm(){ + override fun testArgFromFooInSecondTerm() { prototype.testArgFromFooInSecondTerm() } @Test - override fun testArgFromFooInFoo(){ + override fun testArgFromFooInFoo() { prototype.testArgFromFooInFoo() } @Test - override fun testArgNumberFromFoo(){ + override fun testArgNumberFromFoo() { prototype.testArgNumberFromFoo() } @Test - override fun testArgXFromFoo(){ + override fun testArgXFromFoo() { prototype.testArgXFromFoo() } @Test - override fun testArgNumberFromX(){ + override fun testArgNumberFromX() { prototype.testArgNumberFromX() } @Test - override fun testArgFromAtom(){ + override fun testArgFromAtom() { prototype.testArgFromAtom() } @Test - override fun testArgFromNumber(){ + override fun testArgFromNumber() { prototype.testArgFromNumber() } @Test - override fun testNegativeArgFromFoo(){ + override fun testNegativeArgFromFoo() { prototype.testNegativeArgFromFoo() } @Test - override fun testArgAFromFoo(){ + override fun testArgAFromFoo() { prototype.testArgAFromFoo() } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicArith.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicArith.kt index 9dd55c9ac..468b2a5bb 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicArith.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicArith.kt @@ -1,13 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory +import it.unibo.tuprolog.solve.ClassicSolverFactory +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.TestArith import kotlin.test.Test class TestClassicArith : TestArith, SolverFactory by ClassicSolverFactory { @@ -43,4 +38,3 @@ class TestClassicArith : TestArith, SolverFactory by ClassicSolverFactory { prototype.testArithLessThanEq() } } - diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicAssertA.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicAssertA.kt index 228ea4f00..925b85ca3 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicAssertA.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicAssertA.kt @@ -5,7 +5,7 @@ import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.TestAssertA import kotlin.test.Test -class TestClassicAssertA : TestAssertA, SolverFactory by ClassicSolverFactory{ +class TestClassicAssertA : TestAssertA, SolverFactory by ClassicSolverFactory { private val prototype = TestAssertA.prototype(this) @Test @@ -32,4 +32,4 @@ class TestClassicAssertA : TestAssertA, SolverFactory by ClassicSolverFactory{ override fun testAssertAAtomTrue() { prototype.testAssertAAtomTrue() } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicAssertZ.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicAssertZ.kt index 9ce7397be..2e5a7b8ec 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicAssertZ.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicAssertZ.kt @@ -5,7 +5,7 @@ import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.TestAssertZ import kotlin.test.Test -class TestClassicAssertZ : TestAssertZ, SolverFactory by ClassicSolverFactory{ +class TestClassicAssertZ : TestAssertZ, SolverFactory by ClassicSolverFactory { private val prototype = TestAssertZ.prototype(this) @Test @@ -32,4 +32,4 @@ class TestClassicAssertZ : TestAssertZ, SolverFactory by ClassicSolverFactory{ override fun testAssertZAtomTrue() { prototype.testAssertZAtomTrue() } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicAtom.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicAtom.kt index a99fb9943..8c84687f1 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicAtom.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicAtom.kt @@ -1,13 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory +import it.unibo.tuprolog.solve.ClassicSolverFactory +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.TestAtom import kotlin.test.Test class TestClassicAtom : TestAtom, SolverFactory by ClassicSolverFactory { @@ -25,27 +20,27 @@ class TestClassicAtom : TestAtom, SolverFactory by ClassicSolverFactory { } @Test - override fun testAtomAofB(){ + override fun testAtomAofB() { prototype.testAtomAofB() } @Test - override fun testAtomVar(){ + override fun testAtomVar() { prototype.testAtomVar() } @Test - override fun testAtomEmptyList(){ + override fun testAtomEmptyList() { prototype.testAtomEmptyList() } @Test - override fun testAtomNum(){ + override fun testAtomNum() { prototype.testAtomNum() } @Test - override fun testAtomNumDec(){ + override fun testAtomNumDec() { prototype.testAtomNumDec() } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicAtomic.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicAtomic.kt index e13b63f8a..c1f2db30f 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicAtomic.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicAtomic.kt @@ -1,13 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory +import it.unibo.tuprolog.solve.ClassicSolverFactory +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.TestAtomic import kotlin.test.Test class TestClassicAtomic : TestAtomic, SolverFactory by ClassicSolverFactory { @@ -25,22 +20,22 @@ class TestClassicAtomic : TestAtomic, SolverFactory by ClassicSolverFactory { } @Test - override fun testAtomicVar(){ + override fun testAtomicVar() { prototype.testAtomicVar() } @Test - override fun testAtomicEmptyList(){ + override fun testAtomicEmptyList() { prototype.testAtomicEmptyList() } @Test - override fun testAtomicNum(){ + override fun testAtomicNum() { prototype.testAtomicNum() } @Test - override fun testAtomicNumDec(){ + override fun testAtomicNumDec() { prototype.testAtomicNumDec() } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicCall.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicCall.kt index 20cb40371..589845b99 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicCall.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicCall.kt @@ -3,14 +3,13 @@ package it.unibo.tuprolog.solve.systemtest import it.unibo.tuprolog.solve.ClassicSolverFactory import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.TestCall -import kotlin.test.Ignore import kotlin.test.Test -class TestClassicCall : TestCall, SolverFactory by ClassicSolverFactory { +class TestClassicCall : TestCall, SolverFactory by ClassicSolverFactory { private val prototype = TestCall.prototype(this) @Test - override fun testCallCut(){ + override fun testCallCut() { prototype.testCallCut() } @@ -63,4 +62,4 @@ class TestClassicCall : TestCall, SolverFactory by ClassicSolverFactory { override fun testCallTrue() { prototype.testCallTrue() } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicCatchAndThrow.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicCatchAndThrow.kt index 92222cc58..66ef2d6fa 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicCatchAndThrow.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicCatchAndThrow.kt @@ -5,7 +5,7 @@ import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.TestCatchAndThrow import kotlin.test.Test -class TestClassicCatchAndThrow : TestCatchAndThrow, SolverFactory by ClassicSolverFactory { +class TestClassicCatchAndThrow : TestCatchAndThrow, SolverFactory by ClassicSolverFactory { private val prototype = TestCatchAndThrow.prototype(this) @Test @@ -17,4 +17,4 @@ class TestClassicCatchAndThrow : TestCatchAndThrow, SolverFactory by ClassicSolv override fun testCatchFail() { prototype.testCatchFail() } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicClause.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicClause.kt index ce414f268..7cd89d6f9 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicClause.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicClause.kt @@ -3,10 +3,9 @@ package it.unibo.tuprolog.solve.systemtest import it.unibo.tuprolog.solve.ClassicSolverFactory import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.TestClause -import kotlin.test.Ignore import kotlin.test.Test -class TestClassicClause : TestClause, SolverFactory by ClassicSolverFactory { +class TestClassicClause : TestClause, SolverFactory by ClassicSolverFactory { private val prototype = TestClause.prototype(this) @Test @@ -33,4 +32,4 @@ class TestClassicClause : TestClause, SolverFactory by ClassicSolverFactory { override fun testClauseAtomBody() { prototype.testClauseAtomBody() } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicCompound.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicCompound.kt index b9f26b376..a8a87a26d 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicCompound.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicCompound.kt @@ -5,7 +5,7 @@ import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.TestCompound import kotlin.test.Test -class TestClassicCompound : TestCompound, SolverFactory by ClassicSolverFactory { +class TestClassicCompound : TestCompound, SolverFactory by ClassicSolverFactory { private val prototype = TestCompound.prototype(this) @Test @@ -42,4 +42,4 @@ class TestClassicCompound : TestCompound, SolverFactory by ClassicSolverFactory override fun testCompoundListA() { prototype.testCompoundListA() } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicCopyTerm.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicCopyTerm.kt index a1107af43..e29bfaadd 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicCopyTerm.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicCopyTerm.kt @@ -3,10 +3,9 @@ package it.unibo.tuprolog.solve.systemtest import it.unibo.tuprolog.solve.ClassicSolverFactory import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.TestCopyTerm -import kotlin.test.Ignore import kotlin.test.Test -class TestClassicCopyTerm : TestCopyTerm, SolverFactory by ClassicSolverFactory { +class TestClassicCopyTerm : TestCopyTerm, SolverFactory by ClassicSolverFactory { private val prototype = TestCopyTerm.prototype(this) @Test @@ -53,4 +52,4 @@ class TestClassicCopyTerm : TestCopyTerm, SolverFactory by ClassicSolverFactory override fun testDoubleCopy() { prototype.testDoubleCopy() } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicCut.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicCut.kt index 0792ab157..8c9997fb8 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicCut.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicCut.kt @@ -5,7 +5,7 @@ import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.TestCut import kotlin.test.Test -class TestClassicCut: TestCut, SolverFactory by ClassicSolverFactory { +class TestClassicCut : TestCut, SolverFactory by ClassicSolverFactory { private val prototype = TestCut.prototype(this) @@ -23,4 +23,4 @@ class TestClassicCut: TestCut, SolverFactory by ClassicSolverFactory { override fun testCallCutFailTrue() { prototype.testCallCutFailTrue() } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicFail.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicFail.kt index 3cd57965d..127ca2364 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicFail.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicFail.kt @@ -3,10 +3,9 @@ package it.unibo.tuprolog.solve.systemtest import it.unibo.tuprolog.solve.ClassicSolverFactory import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.TestFail -import kotlin.test.Ignore import kotlin.test.Test -class TestClassicFail : TestFail, SolverFactory by ClassicSolverFactory { +class TestClassicFail : TestFail, SolverFactory by ClassicSolverFactory { private val prototype = TestFail.prototype(this) @Test @@ -28,4 +27,4 @@ class TestClassicFail : TestFail, SolverFactory by ClassicSolverFactory { override fun testSetFlagWarning() { prototype.testSetFlagWarning() } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicFindAll.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicFindAll.kt index a6669dc8a..af91a7352 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicFindAll.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicFindAll.kt @@ -1,13 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory +import it.unibo.tuprolog.solve.ClassicSolverFactory +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.TestFindAll import kotlin.test.Test class TestClassicFindAll : TestFindAll, SolverFactory by ClassicSolverFactory { @@ -25,37 +20,37 @@ class TestClassicFindAll : TestFindAll, SolverFactory by ClassicSolverFactory { } @Test - override fun testFindXinFail(){ + override fun testFindXinFail() { prototype.testFindXinFail() } @Test - override fun testFindXinSameXValues(){ + override fun testFindXinSameXValues() { prototype.testFindXinSameXValues() } @Test - override fun testResultListIsCorrect(){ + override fun testResultListIsCorrect() { prototype.testResultListIsCorrect() } @Test - override fun testFindXtoDoubleAssigment(){ + override fun testFindXtoDoubleAssigment() { prototype.testFindXtoDoubleAssigment() } @Test - override fun testFindXinGoal(){ + override fun testFindXinGoal() { prototype.testFindXinGoal() } @Test - override fun testFindXinNumber(){ + override fun testFindXinNumber() { prototype.testFindXinNumber() } @Test - override fun testFindXinCall(){ + override fun testFindXinCall() { prototype.testFindXinCall() } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicFloat.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicFloat.kt index 4a59e6d67..9304b1194 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicFloat.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicFloat.kt @@ -5,7 +5,7 @@ import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.TestFloat import kotlin.test.Test -class TestClassicFloat : TestFloat, SolverFactory by ClassicSolverFactory { +class TestClassicFloat : TestFloat, SolverFactory by ClassicSolverFactory { private val prototype = TestFloat.prototype(this) @Test @@ -32,4 +32,4 @@ class TestClassicFloat : TestFloat, SolverFactory by ClassicSolverFactory { override fun testFloatX() { prototype.testFloatX() } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicFunctor.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicFunctor.kt index 767ea995b..273ce0468 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicFunctor.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicFunctor.kt @@ -3,14 +3,13 @@ package it.unibo.tuprolog.solve.systemtest import it.unibo.tuprolog.solve.ClassicSolverFactory import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.TestFunctor -import kotlin.test.Ignore import kotlin.test.Test -class TestClassicFunctor : TestFunctor, SolverFactory by ClassicSolverFactory { +class TestClassicFunctor : TestFunctor, SolverFactory by ClassicSolverFactory { private val prototype = TestFunctor.prototype(this) @Test - override fun testFunArity(){ + override fun testFunArity() { prototype.testFunArity() } @@ -93,4 +92,4 @@ class TestClassicFunctor : TestFunctor, SolverFactory by ClassicSolverFactory { override fun testFunNegativeArity() { prototype.testFunNegativeArity() } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicIfThen.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicIfThen.kt index 114995e03..cfb0ba5db 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicIfThen.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicIfThen.kt @@ -5,7 +5,7 @@ import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.TestIfThen import kotlin.test.Test -class TestClassicIfThen : TestIfThen, SolverFactory by ClassicSolverFactory { +class TestClassicIfThen : TestIfThen, SolverFactory by ClassicSolverFactory { private val prototype = TestIfThen.prototype(this) @Test @@ -37,4 +37,4 @@ class TestClassicIfThen : TestIfThen, SolverFactory by ClassicSolverFactory { override fun testIfThenXtoOne() { prototype.testIfThenXtoOne() } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicIfThenElse.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicIfThenElse.kt index c4ef3e875..05a20e3c3 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicIfThenElse.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicIfThenElse.kt @@ -5,7 +5,7 @@ import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.TestIfThenElse import kotlin.test.Test -class TestClassicIfThenElse : TestIfThenElse, SolverFactory by ClassicSolverFactory { +class TestClassicIfThenElse : TestIfThenElse, SolverFactory by ClassicSolverFactory { private val prototype = TestIfThenElse.prototype(this) @Test @@ -47,4 +47,4 @@ class TestClassicIfThenElse : TestIfThenElse, SolverFactory by ClassicSolverFact override fun testIfOrElseTrue() { prototype.testIfOrElseTrue() } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicInteger.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicInteger.kt index 7e3fbb375..c9c59d36e 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicInteger.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicInteger.kt @@ -1,13 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory +import it.unibo.tuprolog.solve.ClassicSolverFactory +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.TestInteger import kotlin.test.Test class TestClassicInteger : TestInteger, SolverFactory by ClassicSolverFactory { @@ -38,4 +33,4 @@ class TestClassicInteger : TestInteger, SolverFactory by ClassicSolverFactory { override fun testIntAtom() { prototype.testIntAtom() } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicIs.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicIs.kt index 43772d62d..b28206b3a 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicIs.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicIs.kt @@ -5,7 +5,7 @@ import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.TestIs import kotlin.test.Test -class TestClassicIs : TestIs, SolverFactory by ClassicSolverFactory { +class TestClassicIs : TestIs, SolverFactory by ClassicSolverFactory { private val prototype = TestIs.prototype(this) @Test @@ -14,7 +14,7 @@ class TestClassicIs : TestIs, SolverFactory by ClassicSolverFactory { } @Test - override fun testIsXY(){ + override fun testIsXY() { prototype.testIsXY() } @@ -37,4 +37,4 @@ class TestClassicIs : TestIs, SolverFactory by ClassicSolverFactory { override fun testIsXFloat() { prototype.testIsXFloat() } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicNonVar.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicNonVar.kt index 0a77ecb55..682171be1 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicNonVar.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicNonVar.kt @@ -1,13 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory +import it.unibo.tuprolog.solve.ClassicSolverFactory +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.TestNonVar import kotlin.test.Test class TestClassicNonVar : TestNonVar, SolverFactory by ClassicSolverFactory { @@ -43,4 +38,4 @@ class TestClassicNonVar : TestNonVar, SolverFactory by ClassicSolverFactory { override fun testNonVar() { prototype.testNonVar() } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicNotProvable.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicNotProvable.kt index 29bef91e8..5bdc9ae5e 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicNotProvable.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicNotProvable.kt @@ -3,10 +3,9 @@ package it.unibo.tuprolog.solve.systemtest import it.unibo.tuprolog.solve.ClassicSolverFactory import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.TestNotProvable -import kotlin.test.Ignore import kotlin.test.Test -class TestClassicNotProvable : TestNotProvable, SolverFactory by ClassicSolverFactory { +class TestClassicNotProvable : TestNotProvable, SolverFactory by ClassicSolverFactory { private val prototype = TestNotProvable.prototype(this) @Test @@ -43,4 +42,4 @@ class TestClassicNotProvable : TestNotProvable, SolverFactory by ClassicSolverFa override fun testOrNotCutFail() { prototype.testOrNotCutFail() } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicNotUnify.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicNotUnify.kt index 714ede7d5..f5e49bdc2 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicNotUnify.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicNotUnify.kt @@ -1,13 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory +import it.unibo.tuprolog.solve.ClassicSolverFactory +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.TestNotUnify import kotlin.test.Test class TestClassicNotUnify : TestNotUnify, SolverFactory by ClassicSolverFactory { @@ -63,5 +58,4 @@ class TestClassicNotUnify : TestNotUnify, SolverFactory by ClassicSolverFactory override fun testFMultipleTermNotUnify() { prototype.testFMultipleTermNotUnify() } - -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicNumber.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicNumber.kt index 97fedfc12..8bc76e808 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicNumber.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicNumber.kt @@ -33,5 +33,4 @@ class TestClassicNumber : TestNumber, SolverFactory by ClassicSolverFactory { override fun testXNum() { prototype.testXNum() } - -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicOnce.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicOnce.kt index a16655450..2ec2fc07c 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicOnce.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicOnce.kt @@ -3,10 +3,9 @@ package it.unibo.tuprolog.solve.systemtest import it.unibo.tuprolog.solve.ClassicSolverFactory import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.TestOnce -import kotlin.test.Ignore import kotlin.test.Test -class TestClassicOnce : TestOnce, SolverFactory by ClassicSolverFactory { +class TestClassicOnce : TestOnce, SolverFactory by ClassicSolverFactory { private val prototype = TestOnce.prototype(this) @Test @@ -38,4 +37,4 @@ class TestClassicOnce : TestOnce, SolverFactory by ClassicSolverFactory { override fun testOnceX() { prototype.testOnceX() } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicOr.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicOr.kt index 5fd4a0127..fa3bd4bc1 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicOr.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicOr.kt @@ -1,13 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory +import it.unibo.tuprolog.solve.ClassicSolverFactory +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.TestOr import kotlin.test.Test class TestClassicOr : TestOr, SolverFactory by ClassicSolverFactory { @@ -38,6 +33,4 @@ class TestClassicOr : TestOr, SolverFactory by ClassicSolverFactory { override fun testOrDoubleAssignment() { prototype.testOrDoubleAssignment() } - - -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicRepeat.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicRepeat.kt index f564f2777..097b6a7c8 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicRepeat.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicRepeat.kt @@ -5,11 +5,11 @@ import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.TestRepeat import kotlin.test.Test -class TestClassicRepeat : TestRepeat, SolverFactory by ClassicSolverFactory { +class TestClassicRepeat : TestRepeat, SolverFactory by ClassicSolverFactory { private val prototype = TestRepeat.prototype(this) @Test override fun testRepeat() { prototype.testRepeat() } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicRetract.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicRetract.kt index b0fee4d6c..c2e0f4147 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicRetract.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicRetract.kt @@ -3,10 +3,9 @@ package it.unibo.tuprolog.solve.systemtest import it.unibo.tuprolog.solve.ClassicSolverFactory import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.TestRetract -import kotlin.test.Ignore import kotlin.test.Test -class TestClassicRetract : TestRetract, SolverFactory by ClassicSolverFactory { +class TestClassicRetract : TestRetract, SolverFactory by ClassicSolverFactory { private val prototype = TestRetract.prototype(this) @Test @@ -18,4 +17,4 @@ class TestClassicRetract : TestRetract, SolverFactory by ClassicSolverFactory { override fun testRetractAtomEmptyList() { prototype.testRetractAtomEmptyList() } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicSolver.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicSolver.kt index 1f2de5f6a..3b4db666f 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicSolver.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicSolver.kt @@ -1,6 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.ClassicSolverFactory +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.TestSolver import kotlin.test.Ignore import kotlin.test.Test @@ -78,7 +80,6 @@ class TestClassicSolver : TestSolver, SolverFactory by ClassicSolverFactory { prototype.testIfThenElse2() } - @Test override fun testTimeout1() { prototype.testTimeout1() diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicTerm.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicTerm.kt index a250fa4ab..4d97d08f6 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicTerm.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicTerm.kt @@ -2,7 +2,6 @@ package it.unibo.tuprolog.solve.systemtest import it.unibo.tuprolog.solve.ClassicSolverFactory import it.unibo.tuprolog.solve.SolverFactory -import it.unibo.tuprolog.solve.TestInteger import it.unibo.tuprolog.solve.TestTerm import kotlin.test.Test @@ -39,4 +38,4 @@ class TestClassicTerm : TestTerm, SolverFactory by ClassicSolverFactory { override fun testTermLessThanEq() { prototype.testTermLessThanEq() } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicTrue.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicTrue.kt index bb0d8e086..18a5a4b3f 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicTrue.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicTrue.kt @@ -5,11 +5,11 @@ import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.TestTrue import kotlin.test.Test -class TestClassicTrue : TestTrue, SolverFactory by ClassicSolverFactory { +class TestClassicTrue : TestTrue, SolverFactory by ClassicSolverFactory { private val prototype = TestTrue.prototype(this) @Test override fun testTrue() { prototype.testTrue() } -} \ No newline at end of file +} diff --git a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicUnify.kt b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicUnify.kt index f36cc3171..06b76f7b9 100644 --- a/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicUnify.kt +++ b/solve-classic/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestClassicUnify.kt @@ -1,13 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory +import it.unibo.tuprolog.solve.ClassicSolverFactory +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.TestUnify import kotlin.test.Test class TestClassicUnify : TestUnify, SolverFactory by ClassicSolverFactory { @@ -68,5 +63,4 @@ class TestClassicUnify : TestUnify, SolverFactory by ClassicSolverFactory { override fun testMultipleTermUnify() { prototype.testMultipleTermUnify() } - -} \ No newline at end of file +} From b8b465e093c299b392820465d108df04ea19f776 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 14 Sep 2020 15:10:58 +0200 Subject: [PATCH 11/34] format code in :solve-streams --- solve-streams/build.gradle.kts | 3 +- .../unibo/tuprolog/solve/SolverExtensions.kt | 3 +- .../tuprolog/solve/StreamsSolverFactory.kt | 2 +- .../solve/solver/SideEffectManagerImpl.kt | 5 +- .../tuprolog/solve/solver/SolverUtils.kt | 12 +- .../solve/solver/StreamsExecutionContext.kt | 13 ++- .../tuprolog/solve/solver/fsm/FinalState.kt | 1 - .../solve/solver/fsm/IntermediateState.kt | 1 - .../solver/fsm/impl/StateGoalEvaluation.kt | 5 - .../solve/solver/fsm/impl/StateInit.kt | 14 ++- .../solver/fsm/impl/StateRuleSelection.kt | 109 ++++++++++-------- .../tuprolog/solve/stdlib/DefaultBuiltins.kt | 9 +- .../tuprolog/solve/stdlib/primitive/Call.kt | 9 +- .../tuprolog/solve/stdlib/primitive/Catch.kt | 9 +- .../solve/stdlib/primitive/Conjunction.kt | 34 ++++-- .../tuprolog/solve/stdlib/primitive/Cut.kt | 2 +- .../tuprolog/solve/stdlib/primitive/Not.kt | 2 +- .../tuprolog/solve/stdlib/primitive/Throw.kt | 23 ++-- .../tuprolog/solve/SolverStrategiesTest.kt | 1 - .../unibo/tuprolog/solve/StreamsSolverTest.kt | 1 - .../tuprolog/solve/solver/SolverUtilsTest.kt | 39 +++++-- .../solver/fsm/AlreadyExecutedStateTest.kt | 1 - .../solver/fsm/StateMachineExecutorTest.kt | 7 +- .../solver/fsm/impl/AbstractTimedStateTest.kt | 5 +- .../fsm/impl/StateGoalEvaluationTest.kt | 1 - .../solve/solver/fsm/impl/StateInitTest.kt | 2 +- .../solver/fsm/impl/StateRuleSelectionTest.kt | 20 ++-- .../StateIntegrationTesting.kt | 5 +- .../testutils/StateGoalEvaluationUtils.kt | 14 +-- .../fsm/impl/testutils/StateInitUtils.kt | 2 +- .../solver/fsm/impl/testutils/StateUtils.kt | 6 +- .../solve/stdlib/primitive/CallTest.kt | 1 - .../solve/stdlib/primitive/ConjunctionTest.kt | 10 +- .../solve/stdlib/primitive/NotTest.kt | 13 ++- .../CutAndConjunctionIntegrationTest.kt | 6 +- .../stdlib/primitive/testutils/CallUtils.kt | 10 +- .../stdlib/primitive/testutils/CatchUtils.kt | 9 +- .../primitive/testutils/ConjunctionUtils.kt | 1 - .../primitive/testutils/PrimitiveUtils.kt | 2 +- .../solve/systemtest/TestStreamsAbolish.kt | 4 +- .../solve/systemtest/TestStreamsAnd.kt | 13 +-- .../solve/systemtest/TestStreamsArg.kt | 13 +-- .../solve/systemtest/TestStreamsArith.kt | 12 +- .../solve/systemtest/TestStreamsAssertA.kt | 5 +- .../solve/systemtest/TestStreamsAssertZ.kt | 15 +-- .../solve/systemtest/TestStreamsAtom.kt | 13 +-- .../solve/systemtest/TestStreamsAtomic.kt | 13 +-- .../solve/systemtest/TestStreamsCall.kt | 8 +- .../systemtest/TestStreamsCatchAndThrow.kt | 6 +- .../solve/systemtest/TestStreamsClause.kt | 4 +- .../solve/systemtest/TestStreamsCompound.kt | 4 +- .../solve/systemtest/TestStreamsCopyTerm.kt | 6 +- .../solve/systemtest/TestStreamsCut.kt | 4 +- .../solve/systemtest/TestStreamsFail.kt | 6 +- .../solve/systemtest/TestStreamsFindAll.kt | 13 +-- .../solve/systemtest/TestStreamsFloat.kt | 6 +- .../solve/systemtest/TestStreamsFunctor.kt | 15 +-- .../solve/systemtest/TestStreamsIfThen.kt | 4 +- .../solve/systemtest/TestStreamsIfThenElse.kt | 4 +- .../solve/systemtest/TestStreamsInteger.kt | 13 +-- .../solve/systemtest/TestStreamsIs.kt | 8 +- .../solve/systemtest/TestStreamsNonVar.kt | 13 +-- .../systemtest/TestStreamsNotProvable.kt | 8 +- .../solve/systemtest/TestStreamsNotUnify.kt | 14 +-- .../solve/systemtest/TestStreamsNumber.kt | 3 +- .../solve/systemtest/TestStreamsOnce.kt | 6 +- .../solve/systemtest/TestStreamsOr.kt | 15 +-- .../solve/systemtest/TestStreamsRepeat.kt | 6 +- .../solve/systemtest/TestStreamsRetract.kt | 4 +- .../solve/systemtest/TestStreamsSolver.kt | 8 +- .../solve/systemtest/TestStreamsTerm.kt | 5 +- .../solve/systemtest/TestStreamsTrue.kt | 6 +- .../solve/systemtest/TestStreamsUnify.kt | 14 +-- .../solve/testutils/SolverTestUtils.kt | 2 +- 74 files changed, 363 insertions(+), 342 deletions(-) diff --git a/solve-streams/build.gradle.kts b/solve-streams/build.gradle.kts index 8a74c8135..082c134a0 100644 --- a/solve-streams/build.gradle.kts +++ b/solve-streams/build.gradle.kts @@ -45,11 +45,10 @@ kotlin { dependsOn(main.defaultSourceSet) } } - } } tasks.withType { maxHeapSize = jvmMaxHeapSize jvmArgs("-Xss$jvmStackSize") -} \ No newline at end of file +} diff --git a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/SolverExtensions.kt b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/SolverExtensions.kt index d1d01d02e..af41d31b6 100644 --- a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/SolverExtensions.kt +++ b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/SolverExtensions.kt @@ -1,4 +1,5 @@ @file:JvmName("SolverExtensions") + package it.unibo.tuprolog.solve import it.unibo.tuprolog.solve.channel.InputChannel @@ -54,4 +55,4 @@ fun MutableSolver.Companion.streamsWithDefaultBuiltins( stdErr: OutputChannel = StreamsSolverFactory.defaultErrorChannel, warnings: OutputChannel = StreamsSolverFactory.defaultWarningsChannel ): MutableSolver = - StreamsSolverFactory.mutableSolverWithDefaultBuiltins(libraries, flags, staticKb, dynamicKb, stdIn, stdOut, stdErr, warnings) \ No newline at end of file + StreamsSolverFactory.mutableSolverWithDefaultBuiltins(libraries, flags, staticKb, dynamicKb, stdIn, stdOut, stdErr, warnings) diff --git a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/StreamsSolverFactory.kt b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/StreamsSolverFactory.kt index 9cb6bcf0b..ca53dc69b 100644 --- a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/StreamsSolverFactory.kt +++ b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/StreamsSolverFactory.kt @@ -47,4 +47,4 @@ object StreamsSolverFactory : SolverFactory { ): MutableSolver { TODO("Not yet implemented") } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/SideEffectManagerImpl.kt b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/SideEffectManagerImpl.kt index 554467f8e..137aa578d 100644 --- a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/SideEffectManagerImpl.kt +++ b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/SideEffectManagerImpl.kt @@ -86,8 +86,8 @@ internal data class SideEffectManagerImpl( * - if cut was called, and the first "scoped" choice point context is to be cut */ internal fun shouldCutExecuteInRuleSelection() = - clauseScopedParents.lastOrNull() in toCutContextsParent - || shouldExecuteThrowCut() + clauseScopedParents.lastOrNull() in toCutContextsParent || + shouldExecuteThrowCut() /** A method to retrieve the first ancestor catch request that has its second argument that unifies with [toUnifyArgument] */ internal fun retrieveAncestorCatchRequest(toUnifyArgument: Term): Solve.Request? { @@ -120,7 +120,6 @@ internal data class SideEffectManagerImpl( // opaque behaviour of call/1 w.r.t cut/0, results in cancellation of sub-goal work onto "cut"'s data structures copy(toCutContextsParent = toRecoverSituation.toCutContextsParent) - /** * Method to query if the throw Cut should execute; the throw cut can exit clause Scope, so it uses different data structures */ diff --git a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/SolverUtils.kt b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/SolverUtils.kt index 446bb1233..37e526c4e 100644 --- a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/SolverUtils.kt +++ b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/SolverUtils.kt @@ -7,7 +7,12 @@ package it.unibo.tuprolog.solve.solver -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Clause +import it.unibo.tuprolog.core.Directive +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Substitution +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.prepareForExecution import it.unibo.tuprolog.solve.ExecutionContext import it.unibo.tuprolog.solve.SideEffect import it.unibo.tuprolog.solve.TimeInstant @@ -104,8 +109,9 @@ fun Solve.Request.replyWith(otherResponse: Solve.Response): So fun KtList.addWithNoDuplicates(toAddSideEffects: KtList): KtList { var duplicatedCount = 0 forEach { sideEffect -> - if (toAddSideEffects.find { toAddSideEffect -> sideEffect === toAddSideEffect } !== null) + if (toAddSideEffects.find { toAddSideEffect -> sideEffect === toAddSideEffect } !== null) { duplicatedCount++ + } } return this + toAddSideEffects.drop(duplicatedCount) -} \ No newline at end of file +} diff --git a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/StreamsExecutionContext.kt b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/StreamsExecutionContext.kt index 0245069c1..840a67380 100644 --- a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/StreamsExecutionContext.kt +++ b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/StreamsExecutionContext.kt @@ -3,11 +3,21 @@ package it.unibo.tuprolog.solve.solver import it.unibo.tuprolog.core.Struct import it.unibo.tuprolog.core.Substitution import it.unibo.tuprolog.core.operators.OperatorSet -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.ExecutionContext +import it.unibo.tuprolog.solve.ExecutionContextAware +import it.unibo.tuprolog.solve.FlagStore +import it.unibo.tuprolog.solve.InputStore +import it.unibo.tuprolog.solve.OutputStore +import it.unibo.tuprolog.solve.SideEffect +import it.unibo.tuprolog.solve.SolverStrategies +import it.unibo.tuprolog.solve.StreamsSolver +import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.channel.InputChannel import it.unibo.tuprolog.solve.channel.OutputChannel import it.unibo.tuprolog.solve.exception.PrologWarning +import it.unibo.tuprolog.solve.getAllOperators import it.unibo.tuprolog.solve.library.Libraries +import it.unibo.tuprolog.solve.toOperatorSet import it.unibo.tuprolog.theory.Theory /** @@ -100,7 +110,6 @@ internal data class StreamsExecutionContext( outputChannels = outputChannels ) } - } /** Extension method to get [SideEffectManagerImpl], if this context is of right type*/ diff --git a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/fsm/FinalState.kt b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/fsm/FinalState.kt index 2fbef589e..dbf057a47 100644 --- a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/fsm/FinalState.kt +++ b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/fsm/FinalState.kt @@ -11,5 +11,4 @@ interface FinalState : State { /** The [Solve.Response] characterizing this Final State */ override val solve: Solve.Response - } diff --git a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/fsm/IntermediateState.kt b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/fsm/IntermediateState.kt index 727893b3c..3dd802f10 100644 --- a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/fsm/IntermediateState.kt +++ b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/fsm/IntermediateState.kt @@ -16,5 +16,4 @@ interface IntermediateState : State { override val context: ExecutionContext get() = solve.context - } diff --git a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateGoalEvaluation.kt b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateGoalEvaluation.kt index 9bc13e11a..e6a0dd669 100644 --- a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateGoalEvaluation.kt +++ b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateGoalEvaluation.kt @@ -32,11 +32,8 @@ internal class StateGoalEvaluation( var responses: Sequence? = null try { responses = primitive(solve) // execute primitive - } catch (exception: HaltException) { - yield(stateEndHalt(exception)) - } catch (prologError: PrologError) { // if primitive throws PrologError try to solve corresponding throw/1 request @@ -45,14 +42,12 @@ internal class StateGoalEvaluation( var allSideEffectsSoFar = emptyList() responses?.forEach { - allSideEffectsSoFar = allSideEffectsSoFar.addWithNoDuplicates(it.sideEffects) yield(ifTimeIsNotOver(stateEnd(it.copy(sideEffects = allSideEffectsSoFar)))) if (it.solution is Solution.Halt) return@sequence // if halt reached, overall computation should stop } - } ?: yield(StateRuleSelection(solve)) } diff --git a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateInit.kt b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateInit.kt index b3dae3dd6..37e034a97 100644 --- a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateInit.kt +++ b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateInit.kt @@ -35,13 +35,15 @@ internal class StateInit( else -> when { currentGoal.isWellFormed() -> currentGoal.prepareForExecutionAsGoal().also { preparedGoal -> // a primitive call or well-formed goal - yield(StateGoalEvaluation( - solve.copy( - signature = preparedGoal.extractSignature(), - arguments = preparedGoal.argsList, - context = with(solve.context) { copy(sideEffectManager = initializedSideEffectsManager) } + yield( + StateGoalEvaluation( + solve.copy( + signature = preparedGoal.extractSignature(), + arguments = preparedGoal.argsList, + context = with(solve.context) { copy(sideEffectManager = initializedSideEffectsManager) } + ) ) - )) + ) } // goal non well-formed diff --git a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateRuleSelection.kt b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateRuleSelection.kt index 9ad53ebf4..03c313e13 100644 --- a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateRuleSelection.kt +++ b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateRuleSelection.kt @@ -9,8 +9,17 @@ import it.unibo.tuprolog.solve.Solution import it.unibo.tuprolog.solve.currentTimeInstant import it.unibo.tuprolog.solve.forEachWithLookahead import it.unibo.tuprolog.solve.primitive.Solve -import it.unibo.tuprolog.solve.solver.* -import it.unibo.tuprolog.solve.solver.fsm.* +import it.unibo.tuprolog.solve.solver.StreamsExecutionContext +import it.unibo.tuprolog.solve.solver.extendParentScopeWith +import it.unibo.tuprolog.solve.solver.fsm.AlreadyExecutedState +import it.unibo.tuprolog.solve.solver.fsm.FinalState +import it.unibo.tuprolog.solve.solver.fsm.State +import it.unibo.tuprolog.solve.solver.fsm.StateMachineExecutor +import it.unibo.tuprolog.solve.solver.fsm.asAlreadyExecuted +import it.unibo.tuprolog.solve.solver.moreThanOne +import it.unibo.tuprolog.solve.solver.newSolveRequest +import it.unibo.tuprolog.solve.solver.orderWithStrategy +import it.unibo.tuprolog.solve.solver.shouldCutExecuteInRuleSelection import it.unibo.tuprolog.unify.Unificator.Companion.mguWith /** @@ -33,58 +42,58 @@ internal class StateRuleSelection( when { matchingRules.none() -> yield(stateEndFalse()) - else -> with(solve.context) { - matchingRules.orderWithStrategy(this, solverStrategies::clauseChoiceStrategy) - }.map { it.prepareForExecution().freshCopy() as Rule } - .forEachWithLookahead { refreshedRule, hasAlternatives -> - val unifyingSubstitution = currentGoal mguWith refreshedRule.head - - val wellFormedRuleBody = refreshedRule.body.apply(unifyingSubstitution) as Struct - - val subSolveRequest = - solve.newSolveRequest( - wellFormedRuleBody, - unifyingSubstitution, - isChoicePointChild = isChoicePoint, - requestIssuingInstant = currentTimeInstant() - ) - - val subInitialState = StateInit(subSolveRequest.initializeForSubRuleScope()) - .also { yield(it.asAlreadyExecuted()) } - - var cutNextSiblings = false - - // execute internally the sub-request in a sub-state-machine, to see what it will respond - subStateExecute(subInitialState).forEach { - val subState = it.wrappedState - - // find in sub-goal state sequence, the final state responding to current solveRequest - if (subState is FinalState && subState.solve.solution.query == subSolveRequest.query) { - - if (subState.solve.sideEffectManager.shouldCutExecuteInRuleSelection()) - cutNextSiblings = true - - // yield only non-false states or false states when there are no open alternatives (because no more or cut) - if (subState !is StateEnd.False || !hasAlternatives || cutNextSiblings) { - val extendedScopeSideEffectManager = subState.solve.sideEffectManager - .extendParentScopeWith(solve.context.sideEffectManager) - - yield( - stateEnd( - subState.solve.copy( - solution = subState.solve.solution.removeSubstitutionFor(refreshedRule.variables), - sideEffectManager = extendedScopeSideEffectManager + else -> + with(solve.context) { + matchingRules.orderWithStrategy(this, solverStrategies::clauseChoiceStrategy) + }.map { it.prepareForExecution().freshCopy() as Rule } + .forEachWithLookahead { refreshedRule, hasAlternatives -> + val unifyingSubstitution = currentGoal mguWith refreshedRule.head + + val wellFormedRuleBody = refreshedRule.body.apply(unifyingSubstitution) as Struct + + val subSolveRequest = + solve.newSolveRequest( + wellFormedRuleBody, + unifyingSubstitution, + isChoicePointChild = isChoicePoint, + requestIssuingInstant = currentTimeInstant() + ) + + val subInitialState = StateInit(subSolveRequest.initializeForSubRuleScope()) + .also { yield(it.asAlreadyExecuted()) } + + var cutNextSiblings = false + + // execute internally the sub-request in a sub-state-machine, to see what it will respond + subStateExecute(subInitialState).forEach { + val subState = it.wrappedState + + // find in sub-goal state sequence, the final state responding to current solveRequest + if (subState is FinalState && subState.solve.solution.query == subSolveRequest.query) { + if (subState.solve.sideEffectManager.shouldCutExecuteInRuleSelection()) { + cutNextSiblings = true + } + + // yield only non-false states or false states when there are no open alternatives (because no more or cut) + if (subState !is StateEnd.False || !hasAlternatives || cutNextSiblings) { + val extendedScopeSideEffectManager = subState.solve.sideEffectManager + .extendParentScopeWith(solve.context.sideEffectManager) + + yield( + stateEnd( + subState.solve.copy( + solution = subState.solve.solution.removeSubstitutionFor(refreshedRule.variables), + sideEffectManager = extendedScopeSideEffectManager + ) ) ) - ) - } - - if (subState is StateEnd.Halt) return@sequence // if halt reached, overall computation should stop + } - } else yield(it) // return wrapped subState as is, only if not interested in it + if (subState is StateEnd.Halt) return@sequence // if halt reached, overall computation should stop + } else yield(it) // return wrapped subState as is, only if not interested in it + } + if (cutNextSiblings) return@sequence // cut here other matching rules trial } - if (cutNextSiblings) return@sequence // cut here other matching rules trial - } } } diff --git a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/DefaultBuiltins.kt b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/DefaultBuiltins.kt index 5fc069615..0aa8c5b34 100644 --- a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/DefaultBuiltins.kt +++ b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/DefaultBuiltins.kt @@ -3,7 +3,12 @@ package it.unibo.tuprolog.solve.stdlib import it.unibo.tuprolog.solve.Signature import it.unibo.tuprolog.solve.library.AliasedLibrary import it.unibo.tuprolog.solve.primitive.Primitive -import it.unibo.tuprolog.solve.stdlib.primitive.* +import it.unibo.tuprolog.solve.stdlib.primitive.Call +import it.unibo.tuprolog.solve.stdlib.primitive.Catch +import it.unibo.tuprolog.solve.stdlib.primitive.Conjunction +import it.unibo.tuprolog.solve.stdlib.primitive.Cut +import it.unibo.tuprolog.solve.stdlib.primitive.Not +import it.unibo.tuprolog.solve.stdlib.primitive.Throw object DefaultBuiltins : AliasedLibrary by CommonBuiltins { @@ -17,4 +22,4 @@ object DefaultBuiltins : AliasedLibrary by CommonBuiltins { Not ).map { it.descriptionPair }.toMap() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Call.kt b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Call.kt index 4b8b84e93..2487390eb 100644 --- a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Call.kt +++ b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Call.kt @@ -1,10 +1,15 @@ package it.unibo.tuprolog.solve.stdlib.primitive -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.StreamsSolver import it.unibo.tuprolog.solve.exception.error.TypeError import it.unibo.tuprolog.solve.primitive.PrimitiveWrapper -import it.unibo.tuprolog.solve.solver.* +import it.unibo.tuprolog.solve.primitive.Solve +import it.unibo.tuprolog.solve.solver.StreamsExecutionContext +import it.unibo.tuprolog.solve.solver.isWellFormed +import it.unibo.tuprolog.solve.solver.newSolveRequest +import it.unibo.tuprolog.solve.solver.prepareForExecutionAsGoal +import it.unibo.tuprolog.solve.solver.replyWith +import it.unibo.tuprolog.solve.solver.resetCutWorkChanges /** * Implementation of primitive handling `call/1` behaviour diff --git a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Catch.kt b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Catch.kt index 346326aa5..ad731608d 100644 --- a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Catch.kt +++ b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Catch.kt @@ -2,11 +2,15 @@ package it.unibo.tuprolog.solve.stdlib.primitive import it.unibo.tuprolog.core.Struct import it.unibo.tuprolog.core.Term -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.StreamsSolver import it.unibo.tuprolog.solve.currentTimeInstant import it.unibo.tuprolog.solve.primitive.PrimitiveWrapper -import it.unibo.tuprolog.solve.solver.* +import it.unibo.tuprolog.solve.primitive.Solve +import it.unibo.tuprolog.solve.solver.SideEffectManagerImpl +import it.unibo.tuprolog.solve.solver.StreamsExecutionContext +import it.unibo.tuprolog.solve.solver.isSelectedThrowCatch +import it.unibo.tuprolog.solve.solver.newSolveRequest +import it.unibo.tuprolog.solve.solver.replyWith /** * Implementation of primitive handling `catch/3` behaviour @@ -23,7 +27,6 @@ internal object Catch : PrimitiveWrapper("catch", 3) { when { // if i'm the catch selected by throw/1 primitive goalResponse.sideEffectManager.isSelectedThrowCatch(request.context) -> { - val recoverGoalArgument = request.arguments.last().apply(goalResponse.solution.substitution) // attaching recover goal's solve request to catch/3 parent, to not re-execute this catch/3 if error thrown diff --git a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Conjunction.kt b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Conjunction.kt index ea3c7e728..80b229046 100644 --- a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Conjunction.kt +++ b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Conjunction.kt @@ -3,10 +3,22 @@ package it.unibo.tuprolog.solve.stdlib.primitive import it.unibo.tuprolog.core.Substitution import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.core.Tuple -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.ExecutionContext +import it.unibo.tuprolog.solve.SideEffect +import it.unibo.tuprolog.solve.Solution +import it.unibo.tuprolog.solve.StreamsSolver +import it.unibo.tuprolog.solve.forEachWithLookahead import it.unibo.tuprolog.solve.primitive.PrimitiveWrapper import it.unibo.tuprolog.solve.primitive.Solve -import it.unibo.tuprolog.solve.solver.* +import it.unibo.tuprolog.solve.solver.SideEffectManagerImpl +import it.unibo.tuprolog.solve.solver.StreamsExecutionContext +import it.unibo.tuprolog.solve.solver.addWithNoDuplicates +import it.unibo.tuprolog.solve.solver.moreThanOne +import it.unibo.tuprolog.solve.solver.newSolveRequest +import it.unibo.tuprolog.solve.solver.orderWithStrategy +import it.unibo.tuprolog.solve.solver.prepareForExecutionAsGoal +import it.unibo.tuprolog.solve.solver.replyWith +import it.unibo.tuprolog.solve.solver.shouldExecuteThrowCut /** * Implementation of primitive handling `','/2` behaviour @@ -67,16 +79,16 @@ internal object Conjunction : PrimitiveWrapper(Tuple.FU var currentSideEffects = emptyList() StreamsSolver.solveToFinalStates(goalRequest).forEachWithLookahead { goalFinalState, currentHasAlternatives -> val goalResponse = goalFinalState.solve - if (Cut.functor == goal.functor || goalResponse.sideEffectManager?.shouldExecuteThrowCut() == true) + if (Cut.functor == goal.functor || goalResponse.sideEffectManager?.shouldExecuteThrowCut() == true) { cutExecuted = true + } currentSideEffects = currentSideEffects.addWithNoDuplicates(goalResponse.sideEffects) when { goalResponse.sideEffectManager?.shouldExecuteThrowCut() == false && - goalResponse.solution is Solution.Yes && - moreThanOne(goals.asSequence()) -> { - + goalResponse.solution is Solution.Yes && + moreThanOne(goals.asSequence()) -> { val sideEffectPair = solveConjunctionGoals( mainRequest, goals.drop(1), @@ -87,24 +99,26 @@ internal object Conjunction : PrimitiveWrapper(Tuple.FU previousGoalsHadAlternatives || currentHasAlternatives ) - if (sideEffectPair.first) + if (sideEffectPair.first) { cutExecuted = true + } currentSideEffects = sideEffectPair.second } else -> // yield only non-false responses or false responses when there are no open alternatives (because no more or cut) - if (goalResponse.solution !is Solution.No || (!previousGoalsHadAlternatives && !currentHasAlternatives) || cutExecuted) + if (goalResponse.solution !is Solution.No || (!previousGoalsHadAlternatives && !currentHasAlternatives) || cutExecuted) { yield( mainRequest.replyWith( goalResponse.copy(sideEffects = accumulatedSideEffects + currentSideEffects) ) ) - + } } - if (cutExecuted || goalResponse.solution is Solution.Halt) // cut other alternatives of current and previous goals + if (cutExecuted || goalResponse.solution is Solution.Halt) { return Pair(true, accumulatedSideEffects + currentSideEffects) + } } return Pair(cutExecuted, accumulatedSideEffects + currentSideEffects) } diff --git a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Cut.kt b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Cut.kt index da05100b7..bf2359cf9 100644 --- a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Cut.kt +++ b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Cut.kt @@ -1,7 +1,7 @@ package it.unibo.tuprolog.solve.stdlib.primitive -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.primitive.PrimitiveWrapper +import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.solver.StreamsExecutionContext /** diff --git a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Not.kt b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Not.kt index 49fcf80c8..df60f1f1c 100644 --- a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Not.kt +++ b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Not.kt @@ -2,9 +2,9 @@ package it.unibo.tuprolog.solve.stdlib.primitive import it.unibo.tuprolog.core.Struct import it.unibo.tuprolog.solve.Solution -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.StreamsSolver import it.unibo.tuprolog.solve.primitive.PrimitiveWrapper +import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.solver.StreamsExecutionContext import it.unibo.tuprolog.solve.solver.newSolveRequest import it.unibo.tuprolog.solve.solver.replyWith diff --git a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Throw.kt b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Throw.kt index 8b69b3294..25434b660 100644 --- a/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Throw.kt +++ b/solve-streams/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Throw.kt @@ -4,11 +4,11 @@ import it.unibo.tuprolog.core.Struct import it.unibo.tuprolog.core.Substitution import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.solve.ExecutionContext -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.exception.PrologError import it.unibo.tuprolog.solve.exception.error.ErrorUtils import it.unibo.tuprolog.solve.exception.error.SystemError import it.unibo.tuprolog.solve.primitive.PrimitiveWrapper +import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.solver.StreamsExecutionContext import it.unibo.tuprolog.unify.Unificator.Companion.mguWith @@ -25,12 +25,10 @@ internal object Throw : PrimitiveWrapper("throw", 1) { val ancestorCatch = request.context.sideEffectManager.retrieveAncestorCatchRequest(throwArgument) when (val catcherUnifyingSubstitution = ancestorCatch?.arguments?.get(1)?.mguWith(throwArgument)) { - // no catch found that can handle thrown exception null, is Substitution.Fail -> { val errorCause = throwArgument.extractErrorCauseChain(request.context) when { - // if unhandled error is a PrologError, rethrow outside errorCause != null -> throw errorCause @@ -40,15 +38,17 @@ internal object Throw : PrimitiveWrapper("throw", 1) { } // matching catch found, it will handle exception - is Substitution.Unifier -> sequenceOf(with(request) { - val newSubstitution = - (context.substitution + catcherUnifyingSubstitution) as Substitution.Unifier + is Substitution.Unifier -> sequenceOf( + with(request) { + val newSubstitution = + (context.substitution + catcherUnifyingSubstitution) as Substitution.Unifier - replySuccess( - newSubstitution, - sideEffectManager = context.sideEffectManager.throwCut(ancestorCatch.context) - ) - }) + replySuccess( + newSubstitution, + sideEffectManager = context.sideEffectManager.throwCut(ancestorCatch.context) + ) + } + ) } } } catch (prologError: PrologError) { @@ -74,5 +74,4 @@ internal object Throw : PrimitiveWrapper("throw", 1) { cause = extra.extractErrorCauseChain(withContext) ) } - } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/SolverStrategiesTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/SolverStrategiesTest.kt index b136f2a80..3a34a6666 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/SolverStrategiesTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/SolverStrategiesTest.kt @@ -42,5 +42,4 @@ internal class SolverStrategiesTest { assertTrue { prologStandard.successCheckStrategy(Truth.TRUE, aContext) } assertFalse { prologStandard.successCheckStrategy(Atom.of("ciao"), aContext) } } - } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/StreamsSolverTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/StreamsSolverTest.kt index c9659157f..9a808b721 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/StreamsSolverTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/StreamsSolverTest.kt @@ -21,5 +21,4 @@ internal class StreamsSolverTest { assertEquals(Theory.empty(), toBeTested.staticKb) assertEquals(Theory.empty(), toBeTested.dynamicKb) } - } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/SolverUtilsTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/SolverUtilsTest.kt index 9316518bb..fb5071205 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/SolverUtilsTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/SolverUtilsTest.kt @@ -1,12 +1,33 @@ package it.unibo.tuprolog.solve.solver -import it.unibo.tuprolog.core.* -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Clause +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Scope +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Substitution +import it.unibo.tuprolog.core.Truth +import it.unibo.tuprolog.core.Tuple +import it.unibo.tuprolog.core.Var +import it.unibo.tuprolog.solve.DummyInstances +import it.unibo.tuprolog.solve.FlagStore +import it.unibo.tuprolog.solve.Signature +import it.unibo.tuprolog.solve.currentTimeInstant import it.unibo.tuprolog.solve.exception.HaltException +import it.unibo.tuprolog.solve.extractSignature +import it.unibo.tuprolog.solve.halt import it.unibo.tuprolog.solve.library.Libraries +import it.unibo.tuprolog.solve.no import it.unibo.tuprolog.solve.primitive.Solve +import it.unibo.tuprolog.solve.yes import it.unibo.tuprolog.theory.Theory -import kotlin.test.* +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith +import kotlin.test.assertFalse +import kotlin.test.assertSame +import kotlin.test.assertTrue +import kotlin.test.fail /** * Test class for SolverUtils.kt @@ -104,11 +125,13 @@ internal class SolverUtilsTest { @Test fun moreThanOneWorksLazily() { assertTrue { - moreThanOne(sequence { - yield(1) - yield(1) - fail("Should not evaluate entire sequence") - }) + moreThanOne( + sequence { + yield(1) + yield(1) + fail("Should not evaluate entire sequence") + } + ) } } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/AlreadyExecutedStateTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/AlreadyExecutedStateTest.kt index 970aa01d8..4d7dc3801 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/AlreadyExecutedStateTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/AlreadyExecutedStateTest.kt @@ -47,5 +47,4 @@ internal class AlreadyExecutedStateTest { assertSame(correct.wrappedState, toBeTested.wrappedState) } - } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/StateMachineExecutorTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/StateMachineExecutorTest.kt index 473f12e72..091319f6e 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/StateMachineExecutorTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/StateMachineExecutorTest.kt @@ -12,7 +12,12 @@ import it.unibo.tuprolog.solve.solver.fsm.testutils.StateMachineExecutorUtils.th import it.unibo.tuprolog.solve.solver.fsm.testutils.StateMachineExecutorUtils.threeShotStateAlreadyExecuted import it.unibo.tuprolog.solve.solver.fsm.testutils.StateMachineExecutorUtils.toBehavedState import it.unibo.tuprolog.solve.solver.fsm.testutils.StateMachineExecutorUtils.twoAlternativeState -import kotlin.test.* +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertSame +import kotlin.test.assertTrue +import kotlin.test.fail /** * Test class for [StateMachineExecutor] diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/AbstractTimedStateTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/AbstractTimedStateTest.kt index e90b015e9..096c01c0d 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/AbstractTimedStateTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/AbstractTimedStateTest.kt @@ -1,7 +1,10 @@ package it.unibo.tuprolog.solve.solver.fsm.impl import it.unibo.tuprolog.core.Truth -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.ExecutionContext +import it.unibo.tuprolog.solve.TimeDuration +import it.unibo.tuprolog.solve.TimeInstant +import it.unibo.tuprolog.solve.currentTimeInstant import it.unibo.tuprolog.solve.exception.TimeOutException import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.solver.fsm.State diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateGoalEvaluationTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateGoalEvaluationTest.kt index 66ca8977e..b93faea4a 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateGoalEvaluationTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateGoalEvaluationTest.kt @@ -62,5 +62,4 @@ internal class StateGoalEvaluationTest { assertOnlyOneNextState(nextStates) } } - } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateInitTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateInitTest.kt index 662e34a3a..c99126169 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateInitTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateInitTest.kt @@ -5,8 +5,8 @@ import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.core.Truth import it.unibo.tuprolog.core.prepareForExecution import it.unibo.tuprolog.solve.DummyInstances -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.SolverStrategies +import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.solver.fsm.impl.testutils.StateInitUtils.allRequests import it.unibo.tuprolog.solve.solver.fsm.impl.testutils.StateInitUtils.allWellFormedGoalRequests import it.unibo.tuprolog.solve.solver.fsm.impl.testutils.StateInitUtils.nonWellFormedGoalRequest diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateRuleSelectionTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateRuleSelectionTest.kt index 357a9128c..38df49d8b 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateRuleSelectionTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateRuleSelectionTest.kt @@ -2,10 +2,10 @@ package it.unibo.tuprolog.solve.solver.fsm.impl import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.dsl.theory.prolog -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.extractSignature import it.unibo.tuprolog.solve.library.Libraries import it.unibo.tuprolog.solve.library.Library +import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.solver.StreamsExecutionContext import it.unibo.tuprolog.solve.solver.fsm.FinalState import it.unibo.tuprolog.solve.solver.fsm.impl.testutils.StateRuleSelectionUtils.createRequest @@ -33,15 +33,20 @@ internal class StateRuleSelectionTest { private val theQuery = prolog { "f"(theQueryVariable) } /** A Solve.Request with three databases and three different facts, to test how they should be used/combined in searching */ - private val threeDBSolveRequest = Solve.Request(theQuery.extractSignature(), theQuery.argsList, + private val threeDBSolveRequest = Solve.Request( + theQuery.extractSignature(), + theQuery.argsList, StreamsExecutionContext( - libraries = Libraries(Library.aliased( - alias = "testLib", - theory = prolog { theory({ "f"("a") }) } - )), + libraries = Libraries( + Library.aliased( + alias = "testLib", + theory = prolog { theory({ "f"("a") }) } + ) + ), staticKb = prolog { theory({ "f"("b") }) }, dynamicKb = prolog { theory({ "f"("c") }) } - )) + ) + ) @Test fun noMatchingRulesFoundMakeItGoIntoFalseState() { @@ -115,5 +120,4 @@ internal class StateRuleSelectionTest { } } } - } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/integrationtest/StateIntegrationTesting.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/integrationtest/StateIntegrationTesting.kt index 807fb5f59..d1ae7a313 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/integrationtest/StateIntegrationTesting.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/integrationtest/StateIntegrationTesting.kt @@ -8,7 +8,6 @@ import it.unibo.tuprolog.solve.PrologStandardExampleTheories.prologStandardExamp import it.unibo.tuprolog.solve.PrologStandardExampleTheories.prologStandardExampleWithCutTheory import it.unibo.tuprolog.solve.PrologStandardExampleTheories.prologStandardExampleWithCutTheoryNotableGoalToSolution import it.unibo.tuprolog.solve.Solution -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.TestingClauseTheories.customReverseListTheory import it.unibo.tuprolog.solve.TestingClauseTheories.customReverseListTheoryNotableGoalToSolution import it.unibo.tuprolog.solve.TestingClauseTheories.cutConjunctionAndBacktrackingTheory @@ -23,6 +22,7 @@ import it.unibo.tuprolog.solve.TestingClauseTheories.simpleFactTheory import it.unibo.tuprolog.solve.TestingClauseTheories.simpleFactTheoryNotableGoalToSolutions import it.unibo.tuprolog.solve.assertSolutionEquals import it.unibo.tuprolog.solve.extractSignature +import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.solver.StreamsExecutionContext import it.unibo.tuprolog.solve.solver.fsm.FinalState import it.unibo.tuprolog.solve.solver.fsm.State @@ -67,7 +67,8 @@ internal class StateIntegrationTesting { finalState.solve.solution.let { // cleanUp as in StreamsSolver (it as? Solution.Yes)?.copy(substitution = it.substitution.filter { _, t -> t !is Var }) ?: it - }) + } + ) } } } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateGoalEvaluationUtils.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateGoalEvaluationUtils.kt index e8b305a4f..c92a5e7f9 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateGoalEvaluationUtils.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateGoalEvaluationUtils.kt @@ -1,7 +1,6 @@ package it.unibo.tuprolog.solve.solver.fsm.impl.testutils import it.unibo.tuprolog.core.Var -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.StreamsSolver import it.unibo.tuprolog.solve.exception.HaltException import it.unibo.tuprolog.solve.exception.PrologError @@ -10,6 +9,7 @@ import it.unibo.tuprolog.solve.exception.error.SystemError import it.unibo.tuprolog.solve.exception.error.TypeError import it.unibo.tuprolog.solve.primitive.Primitive import it.unibo.tuprolog.solve.primitive.PrimitiveWrapper +import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.solver.SideEffectManagerImpl import it.unibo.tuprolog.solve.solver.StreamsExecutionContext import it.unibo.tuprolog.solve.solver.fsm.impl.StateEnd @@ -45,15 +45,15 @@ internal object StateGoalEvaluationUtils { internal val primitiveRequestToNextStateList by lazy { mapOf( createRequestForPrimitiveResponding { sequenceOf(it.replySuccess(it.context.substitution)) } - to listOf(StateEnd.True::class), + to listOf(StateEnd.True::class), createRequestForPrimitiveResponding { sequenceOf(it.replyFail()) } - to listOf(StateEnd.False::class), + to listOf(StateEnd.False::class), createRequestForPrimitiveResponding { sequenceOf(it.replyWith(true), it.replyWith(false)) } - to listOf(StateEnd.True::class, StateEnd.False::class), + to listOf(StateEnd.True::class, StateEnd.False::class), createRequestForPrimitiveResponding { sequenceOf(it.replyException(HaltException(context = it.context))) } - to listOf(StateEnd.Halt::class), + to listOf(StateEnd.Halt::class), createRequestForPrimitiveResponding { throw HaltException(context = it.context) } - to listOf(StateEnd.Halt::class), + to listOf(StateEnd.Halt::class), createRequestForPrimitiveResponding { sequence { yieldAll(StreamsSolver.solveToResponses(createRequestForPrimitiveResponding { throw HaltException(context = it.context) })) @@ -85,4 +85,4 @@ internal object StateGoalEvaluationUtils { /** All requests that should make [StateGoalEvaluation] transit in [StateRuleSelection] */ internal val nonPrimitiveRequests by lazy { StateInitUtils.allWellFormedGoalRequests } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateInitUtils.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateInitUtils.kt index 5c9583f95..d9a4ea462 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateInitUtils.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateInitUtils.kt @@ -62,7 +62,7 @@ internal object StateInitUtils { /** Collection of [Solve.Request] that should pass [StateInit] going into [StateGoalEvaluation] */ internal val allWellFormedGoalRequests by lazy { wellFormedGoalRequestsNeedingPreparationForExecution + - wellFormedGoalRequestsNotNeedingPreparationForExecution + wellFormedGoalRequestsNotNeedingPreparationForExecution } /** Solve request with non well-formed goal */ diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateUtils.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateUtils.kt index b63394add..615f85971 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateUtils.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateUtils.kt @@ -21,7 +21,8 @@ internal object StateUtils { /** Utility function to assert that there's only one next state of given type */ internal inline fun assertOnlyOneNextState(actualNextStateSequence: Sequence) { assertEquals( - 1, actualNextStateSequence.count(), + 1, + actualNextStateSequence.count(), "Expected only one state, but ${actualNextStateSequence.toList()}" ) assertTrue { actualNextStateSequence.single() is S } @@ -50,6 +51,5 @@ internal object StateUtils { internal fun Solve.getSideEffectsManager(): SideEffectManager = when (this) { is Solve.Response -> sideEffectManager is Solve.Request<*> -> context.getSideEffectManager() - } ?: fail("SideEffectManager is not present in ${this}") - + } ?: fail("SideEffectManager is not present in $this") } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/CallTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/CallTest.kt index f0a31cac4..326660878 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/CallTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/CallTest.kt @@ -7,7 +7,6 @@ import it.unibo.tuprolog.solve.stdlib.primitive.testutils.CallUtils.assertErrorC import it.unibo.tuprolog.solve.stdlib.primitive.testutils.CallUtils.requestSolutionMap import it.unibo.tuprolog.solve.stdlib.primitive.testutils.CallUtils.requestToErrorSolutionMap import it.unibo.tuprolog.solve.stdlib.primitive.testutils.CallUtils.requestToSolutionOfCallWithCut -import it.unibo.tuprolog.solve.stdlib.primitive.testutils.PrimitiveUtils.deepCause import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ConjunctionTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ConjunctionTest.kt index f819ef14a..b3add8c5e 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ConjunctionTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ConjunctionTest.kt @@ -1,9 +1,12 @@ package it.unibo.tuprolog.solve.stdlib.primitive import it.unibo.tuprolog.dsl.theory.prolog -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.ExecutionContext +import it.unibo.tuprolog.solve.assertSolutionEquals +import it.unibo.tuprolog.solve.extractSignature import it.unibo.tuprolog.solve.library.Libraries import it.unibo.tuprolog.solve.library.Library +import it.unibo.tuprolog.solve.no import it.unibo.tuprolog.solve.primitive.PrimitiveWrapper import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.solver.StreamsExecutionContext @@ -13,6 +16,7 @@ import it.unibo.tuprolog.solve.stdlib.primitive.testutils.ConjunctionUtils.trueA import it.unibo.tuprolog.solve.stdlib.primitive.testutils.ConjunctionUtils.twoMatchesDB import it.unibo.tuprolog.solve.stdlib.primitive.testutils.PrimitiveUtils.assertOnlyOneSolution import it.unibo.tuprolog.solve.testutils.SolverTestUtils.createSolveRequest +import it.unibo.tuprolog.solve.yes import kotlin.test.Test import kotlin.collections.listOf as ktListOf @@ -64,7 +68,9 @@ internal class ConjunctionTest { val goal = "left" and "right" val request = Solve.Request( - goal.extractSignature(), goal.argsList, StreamsExecutionContext( + goal.extractSignature(), + goal.argsList, + StreamsExecutionContext( substitution = preRequestSubstitution, libraries = Libraries( Library.aliased( diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/NotTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/NotTest.kt index d51b9494b..dfa5058e8 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/NotTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/NotTest.kt @@ -2,9 +2,13 @@ package it.unibo.tuprolog.solve.stdlib.primitive import it.unibo.tuprolog.dsl.prolog import it.unibo.tuprolog.dsl.theory.PrologScopeWithTheories -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.DummyInstances +import it.unibo.tuprolog.solve.assertSolutionEquals import it.unibo.tuprolog.solve.exception.error.TypeError +import it.unibo.tuprolog.solve.halt +import it.unibo.tuprolog.solve.no import it.unibo.tuprolog.solve.testutils.SolverTestUtils.createSolveRequest +import it.unibo.tuprolog.solve.yes import kotlin.test.Ignore import kotlin.test.Test @@ -67,10 +71,11 @@ internal class NotTest { DummyInstances.executionContext, Not.signature, TypeError.Expected.CALLABLE, - prolog { numOf(1) }) + prolog { numOf(1) } + ) ) - ), solutions + ), + solutions ) } - } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/integrationtest/CutAndConjunctionIntegrationTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/integrationtest/CutAndConjunctionIntegrationTest.kt index eff16eb3d..4cdf04259 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/integrationtest/CutAndConjunctionIntegrationTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/integrationtest/CutAndConjunctionIntegrationTest.kt @@ -31,7 +31,8 @@ internal class CutAndConjunctionIntegrationTest { modifiedSimpleFactDatabaseGoals.forEach { (goal, solutionList) -> val request = createSolveRequest( - goal, simpleFactTheory, + goal, + simpleFactTheory, mapOf(Conjunction.descriptionPair, Cut.descriptionPair) ) val solutions = Conjunction.wrappedImplementation(request).map { it.solution }.asIterable() @@ -51,7 +52,8 @@ internal class CutAndConjunctionIntegrationTest { modifiedSimpleFactDatabaseGoals.forEach { (goal, solutionList) -> val request = createSolveRequest( - goal, simpleFactTheory, + goal, + simpleFactTheory, mapOf(Conjunction.descriptionPair, Cut.descriptionPair) ) val solutions = Conjunction.wrappedImplementation(request).map { it.solution }.asIterable() diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/CallUtils.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/CallUtils.kt index deddd4ee6..73168e62c 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/CallUtils.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/CallUtils.kt @@ -1,9 +1,11 @@ package it.unibo.tuprolog.solve.stdlib.primitive.testutils import it.unibo.tuprolog.dsl.theory.prolog -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.DummyInstances +import it.unibo.tuprolog.solve.Solution import it.unibo.tuprolog.solve.TestingClauseTheories.simpleFactTheory import it.unibo.tuprolog.solve.TestingClauseTheories.simpleFactTheoryNotableGoalToSolutions +import it.unibo.tuprolog.solve.changeQueriesTo import it.unibo.tuprolog.solve.exception.PrologError import it.unibo.tuprolog.solve.exception.error.InstantiationError import it.unibo.tuprolog.solve.exception.error.TypeError @@ -61,7 +63,8 @@ internal object CallUtils { }.toTypedArray() ).mapKeys { (query, _) -> createSolveRequest( - query, database = simpleFactTheory, + query, + database = simpleFactTheory, primitives = mapOf(*ktListOf(Call, Cut, Conjunction).map { it.descriptionPair }.toTypedArray()) ) } @@ -118,7 +121,8 @@ internal object CallUtils { }.toTypedArray() ).mapKeys { (query, _) -> createSolveRequest( - query, database = simpleFactTheory, + query, + database = simpleFactTheory, primitives = mapOf(*ktListOf(Call, Cut, Conjunction).map { it.descriptionPair }.toTypedArray()) ) } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/CatchUtils.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/CatchUtils.kt index 083159cff..55cff3573 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/CatchUtils.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/CatchUtils.kt @@ -11,8 +11,6 @@ import it.unibo.tuprolog.solve.stdlib.primitive.Catch import it.unibo.tuprolog.solve.stdlib.primitive.Conjunction import it.unibo.tuprolog.solve.stdlib.primitive.Throw import it.unibo.tuprolog.solve.testutils.SolverTestUtils.createSolveRequest -import it.unibo.tuprolog.solve.changeQueriesTo -import it.unibo.tuprolog.solve.yes import kotlin.collections.listOf as ktListOf /** @@ -60,9 +58,9 @@ internal object CatchUtils { prolog { Catch.functor(callRequest.arguments.single(), "X", true).run { createSolveRequest(this, callRequest.context.libraries.theory, updatedPrimitives) to - solutions.map { - yes("X" to (it.exception as PrologError).errorStruct) - } + solutions.map { + yes("X" to (it.exception as PrologError).errorStruct) + } } } }.toTypedArray() @@ -93,5 +91,4 @@ internal object CatchUtils { ) to solutionList } } - } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/ConjunctionUtils.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/ConjunctionUtils.kt index fa3a87756..379d2932f 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/ConjunctionUtils.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/ConjunctionUtils.kt @@ -36,5 +36,4 @@ internal object ConjunctionUtils { "true" and "true" and "fail" ).map { createSolveRequest(it) } } - } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/PrimitiveUtils.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/PrimitiveUtils.kt index 78d68d5f2..7d2a7c25f 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/PrimitiveUtils.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/PrimitiveUtils.kt @@ -1,8 +1,8 @@ package it.unibo.tuprolog.solve.stdlib.primitive.testutils import it.unibo.tuprolog.solve.Solution -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.exception.PrologError +import it.unibo.tuprolog.solve.primitive.Solve import kotlin.reflect.KClass import kotlin.test.assertEquals diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAbolish.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAbolish.kt index 472159f08..943da46e6 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAbolish.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAbolish.kt @@ -6,7 +6,7 @@ import it.unibo.tuprolog.solve.TestAbolish import kotlin.test.Ignore import kotlin.test.Test -class TestStreamsAbolish : TestAbolish, SolverFactory by StreamsSolverFactory { +class TestStreamsAbolish : TestAbolish, SolverFactory by StreamsSolverFactory { private val prototype = TestAbolish.prototype(this) @Test @@ -38,4 +38,4 @@ class TestStreamsAbolish : TestAbolish, SolverFactory by StreamsSolverFactory { override fun testAbolish() { prototype.testAbolish() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAnd.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAnd.kt index eaf2788ff..9e54bd7b7 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAnd.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAnd.kt @@ -1,13 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.TestAnd import kotlin.test.Ignore import kotlin.test.Test @@ -40,4 +35,4 @@ class TestStreamsAnd : TestAnd, SolverFactory by StreamsSolverFactory { override fun testTrueVarCallable() { prototype.testTrueVarCallable() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArg.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArg.kt index 244a6d6af..21b897a5e 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArg.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArg.kt @@ -1,13 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.TestArg import kotlin.test.Ignore import kotlin.test.Test @@ -90,4 +85,4 @@ class TestStreamsArg : TestArg, SolverFactory by StreamsSolverFactory { override fun testArgAFromFoo() { prototype.testArgAFromFoo() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArith.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArith.kt index 3677f50d1..24f123100 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArith.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArith.kt @@ -1,13 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.TestArith import kotlin.test.Ignore import kotlin.test.Test @@ -45,4 +40,3 @@ class TestStreamsArith : TestArith, SolverFactory by StreamsSolverFactory { prototype.testArithLessThanEq() } } - diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAssertA.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAssertA.kt index 56ae7fb67..2506bf07d 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAssertA.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAssertA.kt @@ -6,8 +6,7 @@ import it.unibo.tuprolog.solve.TestAssertA import kotlin.test.Ignore import kotlin.test.Test - -class TestStreamsAssertA : TestAssertA, SolverFactory by StreamsSolverFactory{ +class TestStreamsAssertA : TestAssertA, SolverFactory by StreamsSolverFactory { private val prototype = TestAssertA.prototype(this) @@ -39,4 +38,4 @@ class TestStreamsAssertA : TestAssertA, SolverFactory by StreamsSolverFactory{ override fun testAssertAAtomTrue() { prototype.testAssertAAtomTrue() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAssertZ.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAssertZ.kt index 70c05c4c1..44791f03f 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAssertZ.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAssertZ.kt @@ -1,17 +1,12 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.TestAssertZ import kotlin.test.Ignore import kotlin.test.Test -class TestStreamsAssertZ : TestAssertZ, SolverFactory by StreamsSolverFactory{ +class TestStreamsAssertZ : TestAssertZ, SolverFactory by StreamsSolverFactory { private val prototype = TestAssertZ.prototype(this) @@ -43,4 +38,4 @@ class TestStreamsAssertZ : TestAssertZ, SolverFactory by StreamsSolverFactory{ override fun testAssertZAtomTrue() { prototype.testAssertZAtomTrue() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtom.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtom.kt index f2e48dd17..97f598d47 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtom.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtom.kt @@ -1,13 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.TestAtom import kotlin.test.Test class TestStreamsAtom : TestAtom, SolverFactory by StreamsSolverFactory { @@ -48,4 +43,4 @@ class TestStreamsAtom : TestAtom, SolverFactory by StreamsSolverFactory { override fun testAtomNumDec() { prototype.testAtomNumDec() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtomic.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtomic.kt index 55fe3ef7b..f3d684ee9 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtomic.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtomic.kt @@ -1,13 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.TestAtomic import kotlin.test.Test class TestStreamsAtomic : TestAtomic, SolverFactory by StreamsSolverFactory { @@ -43,4 +38,4 @@ class TestStreamsAtomic : TestAtomic, SolverFactory by StreamsSolverFactory { override fun testAtomicNumDec() { prototype.testAtomicNumDec() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCall.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCall.kt index 37071d0ac..e29ef494d 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCall.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCall.kt @@ -1,16 +1,16 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.TestCall import kotlin.test.Ignore import kotlin.test.Test -class TestClassicCall : TestCall, SolverFactory by StreamsSolverFactory { +class TestStreamsCall : TestCall, SolverFactory by StreamsSolverFactory { private val prototype = TestCall.prototype(this) @Test - override fun testCallCut(){ + override fun testCallCut() { prototype.testCallCut() } @@ -70,4 +70,4 @@ class TestClassicCall : TestCall, SolverFactory by StreamsSolverFactory { override fun testCallTrue() { prototype.testCallTrue() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCatchAndThrow.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCatchAndThrow.kt index e20d8ff3a..9273d2e63 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCatchAndThrow.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCatchAndThrow.kt @@ -1,11 +1,11 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.TestCatchAndThrow import kotlin.test.Test -class TestStreamsCatchAndThrow : TestCatchAndThrow, SolverFactory by StreamsSolverFactory { +class TestStreamsCatchAndThrow : TestCatchAndThrow, SolverFactory by StreamsSolverFactory { private val prototype = TestCatchAndThrow.prototype(this) @Test @@ -17,4 +17,4 @@ class TestStreamsCatchAndThrow : TestCatchAndThrow, SolverFactory by StreamsSolv override fun testCatchFail() { prototype.testCatchFail() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsClause.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsClause.kt index 96ae9b30c..e628ea92c 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsClause.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsClause.kt @@ -7,7 +7,7 @@ import kotlin.test.Ignore import kotlin.test.Test @Ignore -class TestStreamsClause : TestClause, SolverFactory by StreamsSolverFactory { +class TestStreamsClause : TestClause, SolverFactory by StreamsSolverFactory { private val prototype = TestClause.prototype(this) @Test @@ -34,4 +34,4 @@ class TestStreamsClause : TestClause, SolverFactory by StreamsSolverFactory { override fun testClauseAtomBody() { prototype.testClauseAtomBody() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCompound.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCompound.kt index e5228b05b..4c596fd4f 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCompound.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCompound.kt @@ -5,7 +5,7 @@ import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.TestCompound import kotlin.test.Test -class TestStreamsCompound : TestCompound, SolverFactory by StreamsSolverFactory { +class TestStreamsCompound : TestCompound, SolverFactory by StreamsSolverFactory { private val prototype = TestCompound.prototype(this) @Test @@ -42,4 +42,4 @@ class TestStreamsCompound : TestCompound, SolverFactory by StreamsSolverFactory override fun testCompoundListA() { prototype.testCompoundListA() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCopyTerm.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCopyTerm.kt index 8dd69b8c6..6208d6ac2 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCopyTerm.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCopyTerm.kt @@ -1,12 +1,12 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.TestCopyTerm import kotlin.test.Ignore import kotlin.test.Test -class TestStreamsCopyTerm : TestCopyTerm, SolverFactory by StreamsSolverFactory { +class TestStreamsCopyTerm : TestCopyTerm, SolverFactory by StreamsSolverFactory { private val prototype = TestCopyTerm.prototype(this) @Test @@ -57,4 +57,4 @@ class TestStreamsCopyTerm : TestCopyTerm, SolverFactory by StreamsSolverFactory override fun testDoubleCopy() { prototype.testDoubleCopy() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCut.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCut.kt index cdb2fc10b..42f297cdd 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCut.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCut.kt @@ -6,7 +6,7 @@ import it.unibo.tuprolog.solve.TestCut import kotlin.test.Ignore import kotlin.test.Test -class TestStreamsCut: TestCut, SolverFactory by StreamsSolverFactory { +class TestStreamsCut : TestCut, SolverFactory by StreamsSolverFactory { private val prototype = TestCut.prototype(this) @@ -25,4 +25,4 @@ class TestStreamsCut: TestCut, SolverFactory by StreamsSolverFactory { override fun testCallCutFailTrue() { prototype.testCallCutFailTrue() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFail.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFail.kt index f4534557e..502a8d9f1 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFail.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFail.kt @@ -1,12 +1,12 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.TestFail import kotlin.test.Ignore import kotlin.test.Test -class TestStreamsFail : TestFail, SolverFactory by StreamsSolverFactory { +class TestStreamsFail : TestFail, SolverFactory by StreamsSolverFactory { private val prototype = TestFail.prototype(this) @Test @@ -29,4 +29,4 @@ class TestStreamsFail : TestFail, SolverFactory by StreamsSolverFactory { override fun testSetFlagWarning() { prototype.testSetFlagWarning() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFindAll.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFindAll.kt index f8ebbebfc..0676be60c 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFindAll.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFindAll.kt @@ -1,13 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.TestFindAll import kotlin.test.Ignore import kotlin.test.Test @@ -62,4 +57,4 @@ class TestStreamsFindAll : TestFindAll, SolverFactory by StreamsSolverFactory { override fun testFindXinCall() { prototype.testFindXinCall() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFloat.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFloat.kt index a70aa5540..9627b205c 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFloat.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFloat.kt @@ -1,11 +1,11 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.TestFloat import kotlin.test.Test -class TestStreamsFloat : TestFloat, SolverFactory by StreamsSolverFactory { +class TestStreamsFloat : TestFloat, SolverFactory by StreamsSolverFactory { private val prototype = TestFloat.prototype(this) @Test @@ -32,4 +32,4 @@ class TestStreamsFloat : TestFloat, SolverFactory by StreamsSolverFactory { override fun testFloatX() { prototype.testFloatX() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFunctor.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFunctor.kt index d56bd946d..9c8a6e568 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFunctor.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFunctor.kt @@ -1,19 +1,16 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.theory.Theory +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.TestFunctor import kotlin.test.Ignore import kotlin.test.Test -class TestStreamsFunctor : TestFunctor, SolverFactory by StreamsSolverFactory { +class TestStreamsFunctor : TestFunctor, SolverFactory by StreamsSolverFactory { private val prototype = TestFunctor.prototype(this) @Test - override fun testFunArity(){ + override fun testFunArity() { prototype.testFunArity() } @@ -105,4 +102,4 @@ class TestStreamsFunctor : TestFunctor, SolverFactory by StreamsSolverFactory { override fun testFunNegativeArity() { prototype.testFunNegativeArity() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIfThen.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIfThen.kt index 6261e097d..9ee13b920 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIfThen.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIfThen.kt @@ -5,7 +5,7 @@ import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.TestIfThen import kotlin.test.Test -class TestStreamsIfThen : TestIfThen, SolverFactory by StreamsSolverFactory { +class TestStreamsIfThen : TestIfThen, SolverFactory by StreamsSolverFactory { private val prototype = TestIfThen.prototype(this) @Test @@ -37,4 +37,4 @@ class TestStreamsIfThen : TestIfThen, SolverFactory by StreamsSolverFactory { override fun testIfThenXtoOne() { prototype.testIfThenXtoOne() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIfThenElse.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIfThenElse.kt index 896c475c9..9a803bd47 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIfThenElse.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIfThenElse.kt @@ -1,7 +1,7 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.TestIfThenElse import kotlin.test.Test @@ -47,4 +47,4 @@ class TestStreamsIfThenElse : TestIfThenElse, SolverFactory by StreamsSolverFact override fun testIfOrElseTrue() { prototype.testIfOrElseTrue() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsInteger.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsInteger.kt index d6b2f3d6b..20a0aa53d 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsInteger.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsInteger.kt @@ -1,13 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.TestInteger import kotlin.test.Test class TestStreamsInteger : TestInteger, SolverFactory by StreamsSolverFactory { @@ -38,4 +33,4 @@ class TestStreamsInteger : TestInteger, SolverFactory by StreamsSolverFactory { override fun testIntAtom() { prototype.testIntAtom() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIs.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIs.kt index 9e7923578..c87dcb402 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIs.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIs.kt @@ -1,12 +1,12 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.TestIs import kotlin.test.Ignore import kotlin.test.Test -class TestStreamsIs : TestIs, SolverFactory by StreamsSolverFactory { +class TestStreamsIs : TestIs, SolverFactory by StreamsSolverFactory { private val prototype = TestIs.prototype(this) @Test @@ -16,7 +16,7 @@ class TestStreamsIs : TestIs, SolverFactory by StreamsSolverFactory { @Test @Ignore - override fun testIsXY(){ + override fun testIsXY() { prototype.testIsXY() } @@ -41,4 +41,4 @@ class TestStreamsIs : TestIs, SolverFactory by StreamsSolverFactory { override fun testIsXFloat() { prototype.testIsXFloat() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNonVar.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNonVar.kt index 3aae18e19..b898b4596 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNonVar.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNonVar.kt @@ -1,13 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.TestNonVar import kotlin.test.Test class TestStreamsNonVar : TestNonVar, SolverFactory by StreamsSolverFactory { @@ -43,4 +38,4 @@ class TestStreamsNonVar : TestNonVar, SolverFactory by StreamsSolverFactory { override fun testNonVar() { prototype.testNonVar() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNotProvable.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNotProvable.kt index 8b17b6458..648b53dfa 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNotProvable.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNotProvable.kt @@ -6,7 +6,7 @@ import it.unibo.tuprolog.solve.TestNotProvable import kotlin.test.Ignore import kotlin.test.Test -class TestStreamsNotProvable : TestNotProvable, SolverFactory by StreamsSolverFactory { +class TestStreamsNotProvable : TestNotProvable, SolverFactory by StreamsSolverFactory { private val prototype = TestNotProvable.prototype(this) @Test @@ -20,7 +20,7 @@ class TestStreamsNotProvable : TestNotProvable, SolverFactory by StreamsSolverFa } @Test - @Ignore //solver returns no + @Ignore // solver returns no override fun testNPCutFail() { prototype.testNPCutFail() } @@ -43,8 +43,8 @@ class TestStreamsNotProvable : TestNotProvable, SolverFactory by StreamsSolverFa } @Test - @Ignore //solver returns no + @Ignore // solver returns no override fun testOrNotCutFail() { prototype.testOrNotCutFail() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNotUnify.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNotUnify.kt index afd276f8d..78a283ba0 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNotUnify.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNotUnify.kt @@ -1,13 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.TestNotUnify import kotlin.test.Test class TestStreamsNotUnify : TestNotUnify, SolverFactory by StreamsSolverFactory { @@ -63,5 +58,4 @@ class TestStreamsNotUnify : TestNotUnify, SolverFactory by StreamsSolverFactory override fun testFMultipleTermNotUnify() { prototype.testFMultipleTermNotUnify() } - -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNumber.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNumber.kt index 0abe430c4..e0940eade 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNumber.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNumber.kt @@ -33,5 +33,4 @@ class TestStreamsNumber : TestNumber, SolverFactory by StreamsSolverFactory { override fun testXNum() { prototype.testXNum() } - -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsOnce.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsOnce.kt index 8172053ca..fbaf66994 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsOnce.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsOnce.kt @@ -1,12 +1,12 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.TestOnce import kotlin.test.Ignore import kotlin.test.Test -class TestStreamsOnce : TestOnce, SolverFactory by StreamsSolverFactory { +class TestStreamsOnce : TestOnce, SolverFactory by StreamsSolverFactory { private val prototype = TestOnce.prototype(this) @Test @@ -40,4 +40,4 @@ class TestStreamsOnce : TestOnce, SolverFactory by StreamsSolverFactory { override fun testOnceX() { prototype.testOnceX() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsOr.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsOr.kt index 0c42e92c0..806b2c236 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsOr.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsOr.kt @@ -1,13 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.TestOr import kotlin.test.Ignore import kotlin.test.Test @@ -42,6 +37,4 @@ class TestStreamsOr : TestOr, SolverFactory by StreamsSolverFactory { override fun testOrDoubleAssignment() { prototype.testOrDoubleAssignment() } - - -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsRepeat.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsRepeat.kt index 6a66144fd..6bb16e26b 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsRepeat.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsRepeat.kt @@ -1,15 +1,15 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.TestRepeat import kotlin.test.Test -class TestStreamsRepeat : TestRepeat, SolverFactory by StreamsSolverFactory { +class TestStreamsRepeat : TestRepeat, SolverFactory by StreamsSolverFactory { private val prototype = TestRepeat.prototype(this) @Test override fun testRepeat() { prototype.testRepeat() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsRetract.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsRetract.kt index 19d957989..38953a338 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsRetract.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsRetract.kt @@ -7,7 +7,7 @@ import kotlin.test.Ignore import kotlin.test.Test @Ignore -class TestStreamsRetract : TestRetract, SolverFactory by StreamsSolverFactory { +class TestStreamsRetract : TestRetract, SolverFactory by StreamsSolverFactory { private val prototype = TestRetract.prototype(this) @Test @@ -19,4 +19,4 @@ class TestStreamsRetract : TestRetract, SolverFactory by StreamsSolverFactory override fun testRetractAtomEmptyList() { prototype.testRetractAtomEmptyList() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsSolver.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsSolver.kt index 3d653dde4..06e7dcab6 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsSolver.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsSolver.kt @@ -1,12 +1,17 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.FlagStore +import it.unibo.tuprolog.solve.MutableSolver +import it.unibo.tuprolog.solve.Solver +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.TestSolver import it.unibo.tuprolog.solve.channel.InputChannel import it.unibo.tuprolog.solve.channel.OutputChannel import it.unibo.tuprolog.solve.exception.PrologWarning import it.unibo.tuprolog.solve.library.AliasedLibrary import it.unibo.tuprolog.solve.library.Libraries import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins +import it.unibo.tuprolog.solve.streams import it.unibo.tuprolog.theory.Theory import kotlin.test.Ignore import kotlin.test.Test @@ -117,7 +122,6 @@ class TestStreamsSolver : SolverFactory, TestSolver { prototype.testIfThenElse2() } - @Test override fun testTimeout1() { prototype.testTimeout1() diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsTerm.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsTerm.kt index 2a2f278d8..b94e0ef13 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsTerm.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsTerm.kt @@ -1,8 +1,7 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.SolverFactory -import it.unibo.tuprolog.solve.TestInteger +import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.TestTerm import kotlin.test.Test @@ -39,4 +38,4 @@ class TestStreamsTerm : TestTerm, SolverFactory by StreamsSolverFactory { override fun testTermLessThanEq() { prototype.testTermLessThanEq() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsTrue.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsTrue.kt index 1e50b7ea0..ba0b4b7c4 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsTrue.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsTrue.kt @@ -1,15 +1,15 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.TestTrue import kotlin.test.Test -class TestStreamsTrue : TestTrue, SolverFactory by StreamsSolverFactory { +class TestStreamsTrue : TestTrue, SolverFactory by StreamsSolverFactory { private val prototype = TestTrue.prototype(this) @Test override fun testTrue() { prototype.testTrue() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsUnify.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsUnify.kt index 29da05422..d23c88716 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsUnify.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsUnify.kt @@ -1,13 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.TestUnify import kotlin.test.Ignore import kotlin.test.Test @@ -71,5 +66,4 @@ class TestStreamsUnify : TestUnify, SolverFactory by StreamsSolverFactory { override fun testMultipleTermUnify() { prototype.testMultipleTermUnify() } - -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/testutils/SolverTestUtils.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/testutils/SolverTestUtils.kt index 62f275f08..0da336798 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/testutils/SolverTestUtils.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/testutils/SolverTestUtils.kt @@ -2,12 +2,12 @@ package it.unibo.tuprolog.solve.testutils import it.unibo.tuprolog.core.Struct import it.unibo.tuprolog.solve.Signature -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.Solver import it.unibo.tuprolog.solve.extractSignature import it.unibo.tuprolog.solve.library.Libraries import it.unibo.tuprolog.solve.library.Library import it.unibo.tuprolog.solve.primitive.Primitive +import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.solver.StreamsExecutionContext import it.unibo.tuprolog.theory.Theory From 658aa7c89094945f25d716a73c173936d89814d6 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 14 Sep 2020 15:15:05 +0200 Subject: [PATCH 12/34] format code in :test-solve --- test-solve/build.gradle.kts | 4 +- .../it/unibo/tuprolog/solve/CustomTheories.kt | 26 ++-- .../solve/PrologStandardExampleTheories.kt | 3 +- .../it/unibo/tuprolog/solve/SolverTest.kt | 2 +- .../it/unibo/tuprolog/solve/TestAbolish.kt | 4 +- .../unibo/tuprolog/solve/TestAbolishImpl.kt | 2 +- .../kotlin/it/unibo/tuprolog/solve/TestAnd.kt | 3 +- .../it/unibo/tuprolog/solve/TestAndImpl.kt | 5 +- .../kotlin/it/unibo/tuprolog/solve/TestArg.kt | 3 +- .../it/unibo/tuprolog/solve/TestArgImpl.kt | 2 +- .../it/unibo/tuprolog/solve/TestArith.kt | 2 +- .../it/unibo/tuprolog/solve/TestArithImpl.kt | 2 +- .../it/unibo/tuprolog/solve/TestAssertA.kt | 8 +- .../unibo/tuprolog/solve/TestAssertAImpl.kt | 2 +- .../it/unibo/tuprolog/solve/TestAssertZ.kt | 6 +- .../unibo/tuprolog/solve/TestAssertZImpl.kt | 2 +- .../it/unibo/tuprolog/solve/TestAtom.kt | 2 +- .../it/unibo/tuprolog/solve/TestAtomImpl.kt | 30 ++--- .../it/unibo/tuprolog/solve/TestAtomic.kt | 2 +- .../it/unibo/tuprolog/solve/TestAtomicImpl.kt | 26 ++-- .../it/unibo/tuprolog/solve/TestCall.kt | 2 +- .../it/unibo/tuprolog/solve/TestCallImpl.kt | 10 +- .../unibo/tuprolog/solve/TestCatchAndThrow.kt | 4 +- .../tuprolog/solve/TestCatchAndThrowImpl.kt | 30 ++--- .../it/unibo/tuprolog/solve/TestClause.kt | 4 +- .../it/unibo/tuprolog/solve/TestClauseImpl.kt | 2 +- .../it/unibo/tuprolog/solve/TestCompound.kt | 4 +- .../unibo/tuprolog/solve/TestCompoundImpl.kt | 32 ++--- .../it/unibo/tuprolog/solve/TestCopyTerm.kt | 5 +- .../unibo/tuprolog/solve/TestCopyTermImpl.kt | 2 +- .../kotlin/it/unibo/tuprolog/solve/TestCut.kt | 4 +- .../it/unibo/tuprolog/solve/TestCutImpl.kt | 6 +- .../it/unibo/tuprolog/solve/TestFail.kt | 8 +- .../it/unibo/tuprolog/solve/TestFailImpl.kt | 14 +-- .../it/unibo/tuprolog/solve/TestFindAll.kt | 2 +- .../unibo/tuprolog/solve/TestFindAllImpl.kt | 2 +- .../it/unibo/tuprolog/solve/TestFloat.kt | 2 +- .../it/unibo/tuprolog/solve/TestFloatImpl.kt | 5 +- .../it/unibo/tuprolog/solve/TestFunctor.kt | 2 +- .../unibo/tuprolog/solve/TestFunctorImpl.kt | 9 +- .../it/unibo/tuprolog/solve/TestIfThen.kt | 2 +- .../it/unibo/tuprolog/solve/TestIfThenElse.kt | 2 +- .../tuprolog/solve/TestIfThenElseImpl.kt | 6 +- .../it/unibo/tuprolog/solve/TestIfThenImpl.kt | 6 +- .../it/unibo/tuprolog/solve/TestInteger.kt | 4 +- .../unibo/tuprolog/solve/TestIntegerImpl.kt | 4 +- .../kotlin/it/unibo/tuprolog/solve/TestIs.kt | 2 +- .../it/unibo/tuprolog/solve/TestIsImpl.kt | 2 +- .../it/unibo/tuprolog/solve/TestNonVar.kt | 2 +- .../it/unibo/tuprolog/solve/TestNonVarImpl.kt | 4 +- .../unibo/tuprolog/solve/TestNotProvable.kt | 2 +- .../tuprolog/solve/TestNotProvableImpl.kt | 17 +-- .../it/unibo/tuprolog/solve/TestNotUnify.kt | 3 +- .../unibo/tuprolog/solve/TestNotUnifyImpl.kt | 2 +- .../it/unibo/tuprolog/solve/TestNumber.kt | 4 +- .../it/unibo/tuprolog/solve/TestNumberImpl.kt | 2 +- .../it/unibo/tuprolog/solve/TestOnce.kt | 4 +- .../it/unibo/tuprolog/solve/TestOnceImpl.kt | 72 +++++------ .../kotlin/it/unibo/tuprolog/solve/TestOr.kt | 2 +- .../it/unibo/tuprolog/solve/TestOrImpl.kt | 2 +- .../it/unibo/tuprolog/solve/TestRepeat.kt | 4 +- .../it/unibo/tuprolog/solve/TestRepeatImpl.kt | 6 +- .../it/unibo/tuprolog/solve/TestRetract.kt | 2 +- .../unibo/tuprolog/solve/TestRetractImpl.kt | 5 +- .../it/unibo/tuprolog/solve/TestSolver.kt | 3 +- .../it/unibo/tuprolog/solve/TestSolverImpl.kt | 117 +++++++++++++----- .../it/unibo/tuprolog/solve/TestTerm.kt | 2 +- .../it/unibo/tuprolog/solve/TestTermImpl.kt | 4 +- .../it/unibo/tuprolog/solve/TestTrue.kt | 4 +- .../it/unibo/tuprolog/solve/TestTrueImpl.kt | 6 +- .../it/unibo/tuprolog/solve/TestUnify.kt | 2 +- .../it/unibo/tuprolog/solve/TestUnifyImpl.kt | 2 +- .../it/unibo/tuprolog/solve/TestUtils.kt | 8 +- .../tuprolog/solve/TestingClauseTheories.kt | 15 ++- .../tuprolog/solve/TestingTermOperators.kt | 6 +- .../tuprolog/solve/TimeRelatedTheories.kt | 2 +- .../unibo/tuprolog/solve/SolveResponseTest.kt | 5 - .../solve/TimeRepresentationKtTest.kt | 1 - .../it/unibo/tuprolog/solve/UtilsTest.kt | 2 - .../solve/exception/HaltExceptionTest.kt | 1 - .../solve/exception/PrologErrorTest.kt | 16 +-- .../exception/error/EvaluationErrorTest.kt | 2 +- .../exception/error/TypeErrorExpectedTest.kt | 6 +- .../error/testutils/TypeErrorExpectedUtils.kt | 1 - .../exception/testutils/PrologErrorUtils.kt | 1 - .../solve/function/ArithmeticEvaluatorTest.kt | 1 - .../solve/function/ComputeRequestTest.kt | 4 +- ...ReduceTest.kt => ExpressionReducerTest.kt} | 3 +- .../solve/function/FunctionWrapperTest.kt | 1 - .../solve/function/PrologFunctionTest.kt | 1 - .../testutils/ArithmeticEvaluatorUtils.kt | 12 +- .../solve/function/testutils/ComputeUtils.kt | 5 +- .../testutils/ExpressionEvaluatorUtils.kt | 9 +- .../testutils/FunctionWrapperUtils.kt | 4 +- .../tuprolog/solve/library/LibrariesTest.kt | 4 +- .../solve/library/LibraryAliasedTest.kt | 1 - .../library/impl/LibraryAliasedImplTest.kt | 1 - .../solve/library/impl/LibraryImplTest.kt | 16 ++- .../solve/library/testutils/LibraryUtils.kt | 3 +- .../solve/primitive/AbstractWrapperTest.kt | 8 +- .../solve/primitive/PrimitiveWrapperTest.kt | 4 +- .../tuprolog/solve/primitive/SignatureTest.kt | 17 ++- .../testutils/PrimitiveWrapperUtils.kt | 8 +- .../solve/primitive/testutils/WrapperUtils.kt | 11 +- .../solve/stdlib/function/ArcTangentTest.kt | 3 +- .../solve/stdlib/function/BitwiseAndTest.kt | 3 +- .../stdlib/function/BitwiseComplementTest.kt | 3 +- .../stdlib/function/BitwiseLeftShiftTest.kt | 3 +- .../solve/stdlib/function/BitwiseOrTest.kt | 3 +- .../stdlib/function/BitwiseRightShiftTest.kt | 3 +- .../solve/stdlib/function/CosineTest.kt | 3 +- .../solve/stdlib/function/ExponentialTest.kt | 3 +- .../stdlib/function/ExponentiationTest.kt | 3 +- .../function/FloatFractionalPartTest.kt | 3 +- .../stdlib/function/FloatIntegerPartTest.kt | 5 +- .../stdlib/function/NaturalLogarithmTest.kt | 3 +- .../solve/stdlib/function/SineTest.kt | 3 +- .../solve/stdlib/function/SquareRootTest.kt | 3 +- .../function/testutils/FloatFunctionUtils.kt | 1 - .../solve/stdlib/magic/MagicCutTest.kt | 2 +- .../stdlib/primitive/ArithmeticEqualTest.kt | 3 +- .../ArithmeticGreaterThanOrEqualToTest.kt | 2 +- .../primitive/ArithmeticGreaterThanTest.kt | 3 +- .../ArithmeticLowerThanOrEqualToTest.kt | 2 +- .../primitive/ArithmeticLowerThanTest.kt | 3 +- .../primitive/ArithmeticNotEqualTest.kt | 3 +- .../solve/stdlib/primitive/HaltTest.kt | 2 +- .../tuprolog/solve/stdlib/primitive/IsTest.kt | 21 ++-- .../StandardGreaterThanOrEqualTest.kt | 2 +- .../primitive/StandardGreaterThanTest.kt | 2 +- .../primitive/StandardLowerThanOrEqualTest.kt | 2 +- .../stdlib/primitive/StandardLowerThanTest.kt | 2 +- .../stdlib/primitive/StandardNotEqualTest.kt | 2 +- .../primitive/StandardOrderEqualTest.kt | 2 +- .../stdlib/primitive/TermGreaterThanTest.kt | 1 - .../stdlib/primitive/TermIdenticalTest.kt | 1 - .../stdlib/primitive/TermLowerThanTest.kt | 1 - .../stdlib/primitive/TermNotIdenticalTest.kt | 1 - .../primitive/TypeTestingPrimitivesTest.kt | 2 - .../primitive/testutils/ArithmeticUtils.kt | 9 +- .../testutils/BinaryRelationUtils.kt | 4 +- .../primitive/testutils/PrimitiveUtils.kt | 3 +- .../primitive/testutils/TermOrderingUtils.kt | 9 +- .../stdlib/primitive/testutils/TermUtils.kt | 104 +++++++++++----- .../primitive/testutils/TypeTestingUtils.kt | 27 ++-- .../tuprolog/solve/testutils/SolutionUtils.kt | 3 +- .../tuprolog/solve/testutils/SolveUtils.kt | 16 ++- .../it/unibo/tuprolog/solve/TestUtils.kt | 2 +- .../solve/CurrentTimeInstantKtJsTest.kt | 1 - .../it/unibo/tuprolog/solve/TestUtils.kt | 2 +- 150 files changed, 574 insertions(+), 475 deletions(-) rename test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/{ExpressionReduceTest.kt => ExpressionReducerTest.kt} (96%) diff --git a/test-solve/build.gradle.kts b/test-solve/build.gradle.kts index fa1dc241b..585b7c950 100644 --- a/test-solve/build.gradle.kts +++ b/test-solve/build.gradle.kts @@ -30,9 +30,7 @@ kotlin { } js { - - - val main = compilations["main"] + val main = compilations["main"] val test = compilations["test"] main.defaultSourceSet { diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/CustomTheories.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/CustomTheories.kt index c1977f668..4c02303cc 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/CustomTheories.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/CustomTheories.kt @@ -49,22 +49,22 @@ object CustomTheories { ("a"(2) then "c"("X")).hasSolutions( { yes("X" to 2) } ), - (("a"("X") and "!") then "b"("X")).hasSolutions( + (("a"("X") and "!") then "b"("X")).hasSolutions( { yes("X" to 1) } ), - (("a"("X") and "!") then "c"("X")).hasSolutions( + (("a"("X") and "!") then "c"("X")).hasSolutions( { no() } ), - (("a"("X") and ("X" greaterThan 1)) then "b"("X")).hasSolutions( + (("a"("X") and ("X" greaterThan 1)) then "b"("X")).hasSolutions( { no() } ), - (("a"("X") and ("X" greaterThan 1)) then "c"("X")).hasSolutions( + (("a"("X") and ("X" greaterThan 1)) then "c"("X")).hasSolutions( { yes("X" to 2) } ), - (("a"("X") and "!" and ("X" greaterThan 1)) then "b"("X")).hasSolutions( + (("a"("X") and "!" and ("X" greaterThan 1)) then "b"("X")).hasSolutions( { no() } ), - (("a"("X") and "!" and ("X" greaterThan 1)) then "c"("X")).hasSolutions( + (("a"("X") and "!" and ("X" greaterThan 1)) then "c"("X")).hasSolutions( { no() } ) ) @@ -92,22 +92,22 @@ object CustomTheories { ("a"(2) then "c"("X")).hasSolutions( { yes("X" to 2) } ), - (("a"("X") and "!") then "b"("X")).hasSolutions( + (("a"("X") and "!") then "b"("X")).hasSolutions( { no() } ), - (("a"("X") and "!") then "c"("X")).hasSolutions( + (("a"("X") and "!") then "c"("X")).hasSolutions( { yes("X" to 2) } ), - (("a"("X") and ("X" greaterThan 1)) then "b"("X")).hasSolutions( + (("a"("X") and ("X" greaterThan 1)) then "b"("X")).hasSolutions( { no() } ), - (("a"("X") and ("X" greaterThan 1)) then "c"("X")).hasSolutions( + (("a"("X") and ("X" greaterThan 1)) then "c"("X")).hasSolutions( { yes("X" to 2) } ), - (("a"("X") and "!" and ("X" greaterThan 1)) then "b"("X")).hasSolutions( + (("a"("X") and "!" and ("X" greaterThan 1)) then "b"("X")).hasSolutions( { no() } ), - (("a"("X") and "!" and ("X" greaterThan 1)) then "c"("X")).hasSolutions( + (("a"("X") and "!" and ("X" greaterThan 1)) then "c"("X")).hasSolutions( { yes("X" to 2) } ) ) @@ -217,4 +217,4 @@ object CustomTheories { ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/PrologStandardExampleTheories.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/PrologStandardExampleTheories.kt index ce6e22bfe..2ad241cc2 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/PrologStandardExampleTheories.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/PrologStandardExampleTheories.kt @@ -3,7 +3,6 @@ package it.unibo.tuprolog.solve import it.unibo.tuprolog.dsl.theory.prolog import it.unibo.tuprolog.solve.PrologStandardExampleTheories.prologStandardExampleTheory import it.unibo.tuprolog.solve.TestingClauseTheories.instantiationError -import it.unibo.tuprolog.solve.TestingClauseTheories.replaceAllFunctors import it.unibo.tuprolog.solve.TestingClauseTheories.systemError import it.unibo.tuprolog.solve.TestingClauseTheories.timeOutException import it.unibo.tuprolog.solve.TestingClauseTheories.typeError @@ -81,7 +80,7 @@ object PrologStandardExampleTheories { val prologStandardExampleWithCutTheory by lazy { prolog { theory({ "p"("X", "Y") `if` ("q"("X") and "!" and "r"("X", "Y")) }) + - theoryOf(*prologStandardExampleTheory.clauses.drop(1).toTypedArray()) + theoryOf(*prologStandardExampleTheory.clauses.drop(1).toTypedArray()) } } diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/SolverTest.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/SolverTest.kt index 09c4d263a..01cbd23a0 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/SolverTest.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/SolverTest.kt @@ -12,4 +12,4 @@ interface SolverTest { /** A long test max duration */ val longDuration: TimeDuration get() = 4 * mediumDuration -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAbolish.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAbolish.kt index c58b79ece..0821e295c 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAbolish.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAbolish.kt @@ -3,7 +3,7 @@ package it.unibo.tuprolog.solve interface TestAbolish : SolverTest { companion object { fun prototype(solverFactory: SolverFactory): TestAbolish = - TestAbolishImpl(solverFactory) + TestAbolishImpl(solverFactory) } /** @@ -55,4 +55,4 @@ interface TestAbolish : SolverTest { * producing exception `type_error(atom,5)`. */ fun testAbolish() -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAbolishImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAbolishImpl.kt index d0d9c4fe2..556ad9e48 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAbolishImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAbolishImpl.kt @@ -124,4 +124,4 @@ internal class TestAbolishImpl(private val solverFactory: SolverFactory) : TestA ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAnd.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAnd.kt index 96ff3787f..531d22a47 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAnd.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAnd.kt @@ -18,5 +18,4 @@ interface TestAnd : SolverTest { fun testNoFooIsCallable() fun testTrueVarCallable() - -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAndImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAndImpl.kt index 998990670..90a32586c 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAndImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAndImpl.kt @@ -35,7 +35,7 @@ internal class TestAndImpl(private val solverFactory: SolverFactory) : TestAnd { } } - override fun testFailIsCallable() { //goal + override fun testFailIsCallable() { // goal prolog { val solver = solverFactory.solverWithDefaultBuiltins() @@ -85,5 +85,4 @@ internal class TestAndImpl(private val solverFactory: SolverFactory) : TestAnd { ) } } - -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestArg.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestArg.kt index 96d92951e..7984443b2 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestArg.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestArg.kt @@ -144,5 +144,4 @@ interface TestArg : SolverTest { * producing exception type_error(integer,a). */ fun testArgAFromFoo() - -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestArgImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestArgImpl.kt index 018bc9e17..9efc70513 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestArgImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestArgImpl.kt @@ -258,4 +258,4 @@ internal class TestArgImpl(private val solverFactory: SolverFactory) : TestArg { ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestArith.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestArith.kt index 9f43c39e8..13e418910 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestArith.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestArith.kt @@ -199,4 +199,4 @@ interface TestArith : SolverTest { * producing exception type_error(evaluable, floot/1). */ fun testArithLessThanEq() -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestArithImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestArithImpl.kt index 2e53f60a0..d4ec45e59 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestArithImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestArithImpl.kt @@ -405,4 +405,4 @@ internal class TestArithImpl(private val solverFactory: SolverFactory) : TestAri ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAssertA.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAssertA.kt index 771177db2..47098b11c 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAssertA.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAssertA.kt @@ -3,10 +3,10 @@ package it.unibo.tuprolog.solve /** * Tests of asserta */ -interface TestAssertA : SolverTest{ - companion object{ +interface TestAssertA : SolverTest { + companion object { fun prototype(solverFactory: SolverFactory): TestAssertA = - TestAssertAImpl(solverFactory) + TestAssertAImpl(solverFactory) } /** @@ -59,4 +59,4 @@ interface TestAssertA : SolverTest{ * producing exception permission_error(modify,private_procedure,atom/1). */ fun testAssertAAtomTrue() -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAssertAImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAssertAImpl.kt index f2e374f05..72780eb30 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAssertAImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAssertAImpl.kt @@ -117,4 +117,4 @@ internal class TestAssertAImpl(private val solverFactory: SolverFactory) : TestA ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAssertZ.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAssertZ.kt index b193cecfe..17094380e 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAssertZ.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAssertZ.kt @@ -4,9 +4,9 @@ package it.unibo.tuprolog.solve * Tests of assertz */ interface TestAssertZ : SolverTest { - companion object{ + companion object { fun prototype(solverFactory: SolverFactory): TestAssertZ = - TestAssertZImpl(solverFactory) + TestAssertZImpl(solverFactory) } /** @@ -57,4 +57,4 @@ interface TestAssertZ : SolverTest { * producing exception permission_error(modify,private_procedure,atom/1). */ fun testAssertZAtomTrue() -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAssertZImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAssertZImpl.kt index e33e0cdec..6349e0ff4 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAssertZImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAssertZImpl.kt @@ -117,4 +117,4 @@ internal class TestAssertZImpl(private val solverFactory: SolverFactory) : TestA ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAtom.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAtom.kt index e103f2ceb..f3988c352 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAtom.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAtom.kt @@ -71,4 +71,4 @@ interface TestAtom : SolverTest { * fails on a solver initialized with default built-ins and with and empty theory. */ fun testAtomNumDec() -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAtomImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAtomImpl.kt index 35f2a44de..8ea87d6c6 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAtomImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAtomImpl.kt @@ -13,8 +13,8 @@ internal class TestAtomImpl(private val solverFactory: SolverFactory) : TestAtom val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - ktListOf(query.yes()), - solutions + ktListOf(query.yes()), + solutions ) } } @@ -27,8 +27,8 @@ internal class TestAtomImpl(private val solverFactory: SolverFactory) : TestAtom val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - ktListOf(query.yes()), - solutions + ktListOf(query.yes()), + solutions ) } } @@ -41,8 +41,8 @@ internal class TestAtomImpl(private val solverFactory: SolverFactory) : TestAtom val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - ktListOf(query.no()), - solutions + ktListOf(query.no()), + solutions ) } } @@ -55,8 +55,8 @@ internal class TestAtomImpl(private val solverFactory: SolverFactory) : TestAtom val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - ktListOf(query.no()), - solutions + ktListOf(query.no()), + solutions ) } } @@ -69,8 +69,8 @@ internal class TestAtomImpl(private val solverFactory: SolverFactory) : TestAtom val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - ktListOf(query.yes()), - solutions + ktListOf(query.yes()), + solutions ) } } @@ -83,8 +83,8 @@ internal class TestAtomImpl(private val solverFactory: SolverFactory) : TestAtom val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - ktListOf(query.no()), - solutions + ktListOf(query.no()), + solutions ) } } @@ -97,9 +97,9 @@ internal class TestAtomImpl(private val solverFactory: SolverFactory) : TestAtom val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - ktListOf(query.no()), - solutions + ktListOf(query.no()), + solutions ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAtomic.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAtomic.kt index ad89d27cf..43b4c1bde 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAtomic.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAtomic.kt @@ -62,4 +62,4 @@ interface TestAtomic : SolverTest { * succeeds on a solver initialized with default built-ins and with and empty theory. */ fun testAtomicNumDec() -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAtomicImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAtomicImpl.kt index 7aefd2af1..c87160055 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAtomicImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestAtomicImpl.kt @@ -13,8 +13,8 @@ internal class TestAtomicImpl(private val solverFactory: SolverFactory) : TestAt val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - ktListOf(query.yes()), - solutions + ktListOf(query.yes()), + solutions ) } } @@ -27,8 +27,8 @@ internal class TestAtomicImpl(private val solverFactory: SolverFactory) : TestAt val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - ktListOf(query.no()), - solutions + ktListOf(query.no()), + solutions ) } } @@ -41,8 +41,8 @@ internal class TestAtomicImpl(private val solverFactory: SolverFactory) : TestAt val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - ktListOf(query.no()), - solutions + ktListOf(query.no()), + solutions ) } } @@ -55,8 +55,8 @@ internal class TestAtomicImpl(private val solverFactory: SolverFactory) : TestAt val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - ktListOf(query.yes()), - solutions + ktListOf(query.yes()), + solutions ) } } @@ -69,8 +69,8 @@ internal class TestAtomicImpl(private val solverFactory: SolverFactory) : TestAt val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - ktListOf(query.yes()), - solutions + ktListOf(query.yes()), + solutions ) } } @@ -83,9 +83,9 @@ internal class TestAtomicImpl(private val solverFactory: SolverFactory) : TestAt val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - ktListOf(query.yes()), - solutions + ktListOf(query.yes()), + solutions ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCall.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCall.kt index 7a8c24762..5e2c531ef 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCall.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCall.kt @@ -111,4 +111,4 @@ interface TestCall : SolverTest { * producing exception `type_error(callable,(1; true))`. */ fun testCallTrue() -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCallImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCallImpl.kt index e634b0b22..d52561d6d 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCallImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCallImpl.kt @@ -167,8 +167,7 @@ internal class TestCallImpl(private val solverFactory: SolverFactory) : TestCall DummyInstances.executionContext, Signature("call", 1), TypeError.Expected.CALLABLE, - fail and 1 //solver returns 1 - + fail and 1 // solver returns 1 ) ) @@ -192,8 +191,7 @@ internal class TestCallImpl(private val solverFactory: SolverFactory) : TestCall DummyInstances.executionContext, Signature("call", 1), TypeError.Expected.CALLABLE, - write(3) and 1 //solver returns 1 - + write(3) and 1 // solver returns 1 ) ) @@ -217,7 +215,7 @@ internal class TestCallImpl(private val solverFactory: SolverFactory) : TestCall DummyInstances.executionContext, Signature("call", 1), TypeError.Expected.CALLABLE, - (1 or true) //solver returns 1 + (1 or true) // solver returns 1 ) ) @@ -226,4 +224,4 @@ internal class TestCallImpl(private val solverFactory: SolverFactory) : TestCall ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCatchAndThrow.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCatchAndThrow.kt index 64ddeb135..5dfdd4881 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCatchAndThrow.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCatchAndThrow.kt @@ -3,7 +3,7 @@ package it.unibo.tuprolog.solve interface TestCatchAndThrow : SolverTest { companion object { fun prototype(solverFactory: SolverFactory): TestCatchAndThrow = - TestCatchAndThrowImpl(solverFactory) + TestCatchAndThrowImpl(solverFactory) } /** @@ -24,4 +24,4 @@ interface TestCatchAndThrow : SolverTest { * fails on a solver initialized with default built-ins and with and empty theory, */ fun testCatchFail() -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCatchAndThrowImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCatchAndThrowImpl.kt index 3b4c27696..442fa49ee 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCatchAndThrowImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCatchAndThrowImpl.kt @@ -1,6 +1,5 @@ package it.unibo.tuprolog.solve - import it.unibo.tuprolog.dsl.theory.prolog import it.unibo.tuprolog.solve.exception.error.SystemError @@ -13,16 +12,16 @@ internal class TestCatchAndThrowImpl(private val solverFactory: SolverFactory) : val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - kotlin.collections.listOf( - query.halt( - SystemError.forUncaughtException( - DummyInstances.executionContext, - atomOf("blabla") - - ) - ) - ), - solutions + kotlin.collections.listOf( + query.halt( + SystemError.forUncaughtException( + DummyInstances.executionContext, + atomOf("blabla") + + ) + ) + ), + solutions ) } } @@ -35,10 +34,11 @@ internal class TestCatchAndThrowImpl(private val solverFactory: SolverFactory) : val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - kotlin.collections.listOf( - query.no()), - solutions + kotlin.collections.listOf( + query.no() + ), + solutions ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestClause.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestClause.kt index 8e2bd01da..09aae7a45 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestClause.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestClause.kt @@ -3,7 +3,7 @@ package it.unibo.tuprolog.solve interface TestClause : SolverTest { companion object { fun prototype(solverFactory: SolverFactory): TestClause = - TestClauseImpl(solverFactory) + TestClauseImpl(solverFactory) } /** @@ -54,4 +54,4 @@ interface TestClause : SolverTest { * producing exception `permission_error(access,private_procedure,atom/1)`. */ fun testClauseAtomBody() -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestClauseImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestClauseImpl.kt index 1991731c9..0448809e3 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestClauseImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestClauseImpl.kt @@ -114,4 +114,4 @@ internal class TestClauseImpl(private val solverFactory: SolverFactory) : TestCl ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCompound.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCompound.kt index f07068946..e2c248258 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCompound.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCompound.kt @@ -3,7 +3,7 @@ package it.unibo.tuprolog.solve interface TestCompound : SolverTest { companion object { fun prototype(solverFactory: SolverFactory): TestCompound = - TestCompoundImpl(solverFactory) + TestCompoundImpl(solverFactory) } /** @@ -68,4 +68,4 @@ interface TestCompound : SolverTest { * succeeds on a solver initialized with default built-ins and with and empty theory, */ fun testCompoundListA() -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCompoundImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCompoundImpl.kt index 2527974b6..1782ff1fe 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCompoundImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCompoundImpl.kt @@ -11,8 +11,8 @@ internal class TestCompoundImpl(private val solverFactory: SolverFactory) : Test val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - kotlin.collections.listOf(query.no()), - solutions + kotlin.collections.listOf(query.no()), + solutions ) } } @@ -21,12 +21,12 @@ internal class TestCompoundImpl(private val solverFactory: SolverFactory) : Test prolog { val solver = solverFactory.solverWithDefaultBuiltins() - val query = compound(- 33.3) + val query = compound(-33.3) val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - kotlin.collections.listOf(query.no()), - solutions + kotlin.collections.listOf(query.no()), + solutions ) } } @@ -39,8 +39,8 @@ internal class TestCompoundImpl(private val solverFactory: SolverFactory) : Test val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - kotlin.collections.listOf(query.yes()), - solutions + kotlin.collections.listOf(query.yes()), + solutions ) } } @@ -53,8 +53,8 @@ internal class TestCompoundImpl(private val solverFactory: SolverFactory) : Test val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - kotlin.collections.listOf(query.no()), - solutions + kotlin.collections.listOf(query.no()), + solutions ) } } @@ -67,8 +67,8 @@ internal class TestCompoundImpl(private val solverFactory: SolverFactory) : Test val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - kotlin.collections.listOf(query.no()), - solutions + kotlin.collections.listOf(query.no()), + solutions ) } } @@ -81,8 +81,8 @@ internal class TestCompoundImpl(private val solverFactory: SolverFactory) : Test val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - kotlin.collections.listOf(query.yes()), - solutions + kotlin.collections.listOf(query.yes()), + solutions ) } } @@ -95,9 +95,9 @@ internal class TestCompoundImpl(private val solverFactory: SolverFactory) : Test val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - kotlin.collections.listOf(query.yes()), - solutions + kotlin.collections.listOf(query.yes()), + solutions ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCopyTerm.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCopyTerm.kt index f846990f0..714e91093 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCopyTerm.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCopyTerm.kt @@ -3,7 +3,7 @@ package it.unibo.tuprolog.solve interface TestCopyTerm : SolverTest { companion object { fun prototype(solverFactory: SolverFactory): TestCopyTerm = - TestCopyTermImpl(solverFactory) + TestCopyTermImpl(solverFactory) } /** @@ -15,7 +15,6 @@ interface TestCopyTerm : SolverTest { */ fun testCopyXNum() - /** * Tests the queries * ```prolog @@ -90,4 +89,4 @@ interface TestCopyTerm : SolverTest { * fails on a solver initialized with default built-ins and with and empty theory. */ fun testDoubleCopy() -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCopyTermImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCopyTermImpl.kt index 70a66e4e6..8793f8887 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCopyTermImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCopyTermImpl.kt @@ -128,4 +128,4 @@ class TestCopyTermImpl(private val solverFactory: SolverFactory) : TestCopyTerm ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCut.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCut.kt index 47a10db22..4b55b61c1 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCut.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCut.kt @@ -1,7 +1,5 @@ package it.unibo.tuprolog.solve -import it.unibo.tuprolog.solve.SolverTest - interface TestCut : SolverTest { companion object { fun prototype(solverFactory: SolverFactory): TestCut = @@ -34,4 +32,4 @@ interface TestCut : SolverTest { * succeeds on a solver initialized with default built-ins and with and empty theory. */ fun testCallCutFailTrue() -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCutImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCutImpl.kt index c158b11d1..f5cd5b971 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCutImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestCutImpl.kt @@ -2,7 +2,7 @@ package it.unibo.tuprolog.solve import it.unibo.tuprolog.dsl.theory.prolog -internal class TestCutImpl(private val solverFactory: SolverFactory) : TestCut{ +internal class TestCutImpl(private val solverFactory: SolverFactory) : TestCut { override fun testCut() { prolog { val solver = solverFactory.solverWithDefaultBuiltins() @@ -35,7 +35,7 @@ internal class TestCutImpl(private val solverFactory: SolverFactory) : TestCut{ prolog { val solver = solverFactory.solverWithDefaultBuiltins() - val query = (call("!") and fail or true ) + val query = (call("!") and fail or true) val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( @@ -44,4 +44,4 @@ internal class TestCutImpl(private val solverFactory: SolverFactory) : TestCut{ ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFail.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFail.kt index 7318c3cdb..822746c5c 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFail.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFail.kt @@ -1,9 +1,9 @@ package it.unibo.tuprolog.solve -interface TestFail: SolverTest { +interface TestFail : SolverTest { companion object { fun prototype(solverFactory: SolverFactory): TestFail = - TestFailImpl(solverFactory) + TestFailImpl(solverFactory) } /** @@ -12,7 +12,7 @@ interface TestFail: SolverTest { * ?- fail. * ``` * fails on a solver initialized with default built-ins and with and empty theory, - */ + */ fun testFail() /** @@ -42,4 +42,4 @@ interface TestFail: SolverTest { * fails on a solver initialized with default built-ins and with and empty theory, */ fun testSetFlagWarning() -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFailImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFailImpl.kt index 86877fb25..05208b31d 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFailImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFailImpl.kt @@ -13,8 +13,8 @@ internal class TestFailImpl(private val solverFactory: SolverFactory) : TestFail val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - kotlin.collections.listOf(query.no()), - solutions + kotlin.collections.listOf(query.no()), + solutions ) } } @@ -50,8 +50,8 @@ internal class TestFailImpl(private val solverFactory: SolverFactory) : TestFail val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - kotlin.collections.listOf(query.no()), - solutions + kotlin.collections.listOf(query.no()), + solutions ) } } @@ -64,9 +64,9 @@ internal class TestFailImpl(private val solverFactory: SolverFactory) : TestFail val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - kotlin.collections.listOf(query.no()), - solutions + kotlin.collections.listOf(query.no()), + solutions ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFindAll.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFindAll.kt index 85910aea6..8b74efa4d 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFindAll.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFindAll.kt @@ -98,4 +98,4 @@ interface TestFindAll : SolverTest { * producing exception `type_error(callable, 1)`. */ fun testFindXinCall() -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFindAllImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFindAllImpl.kt index 427af2707..5bd0053f2 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFindAllImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFindAllImpl.kt @@ -160,4 +160,4 @@ internal class TestFindAllImpl(private val solverFactory: SolverFactory) : TestF ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFloat.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFloat.kt index d7a77844f..2f2d6508f 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFloat.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFloat.kt @@ -50,4 +50,4 @@ interface TestFloat : SolverTest { * fails on a solver initialized with default built-ins and with and empty theory, */ fun testFloatX() -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFloatImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFloatImpl.kt index 45f1fbe87..be3f1a66c 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFloatImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFloatImpl.kt @@ -21,7 +21,7 @@ internal class TestFloatImpl(private val solverFactory: SolverFactory) : TestFlo prolog { val solver = solverFactory.solverWithDefaultBuiltins() - val query = float(- 3.3) + val query = float(-3.3) val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( @@ -72,5 +72,4 @@ internal class TestFloatImpl(private val solverFactory: SolverFactory) : TestFlo ) } } - -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFunctor.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFunctor.kt index e08f5e821..9765af4d3 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFunctor.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFunctor.kt @@ -170,4 +170,4 @@ interface TestFunctor : SolverTest { * producing exception `domain_error(not_less_than_zero,-1)`. */ fun testFunNegativeArity() -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFunctorImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFunctorImpl.kt index 1d3d5119f..d765b78c5 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFunctorImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestFunctorImpl.kt @@ -91,7 +91,7 @@ internal class TestFunctorImpl(private val solverFactory: SolverFactory) : TestF } } - override fun testFunXNameYArity() { //solver says exception_error + override fun testFunXNameYArity() { // solver says exception_error prolog { val solver = solverFactory.solverWithDefaultBuiltins() @@ -105,7 +105,7 @@ internal class TestFunctorImpl(private val solverFactory: SolverFactory) : TestF } } - override fun testFunDecNum() { //solver says exception_error + override fun testFunDecNum() { // solver says exception_error prolog { val solver = solverFactory.solverWithDefaultBuiltins() @@ -270,7 +270,8 @@ internal class TestFunctorImpl(private val solverFactory: SolverFactory) : TestF val solver = solverFactory.solverWithDefaultBuiltins() val query = current_prolog_flag("max_arity", A) and ( - (X `is` (A + 1)) and functor(T, "foo", X)) + (X `is` (A + 1)) and functor(T, "foo", X) + ) val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( @@ -311,4 +312,4 @@ internal class TestFunctorImpl(private val solverFactory: SolverFactory) : TestF ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestIfThen.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestIfThen.kt index 23bd03f56..ccc3a8b19 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestIfThen.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestIfThen.kt @@ -62,4 +62,4 @@ interface TestIfThen : SolverTest { * producing 2 solutions which binds variable `X` to `1` and `X` to `2` . */ fun testIfThenOrWithDoubleSub() -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestIfThenElse.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestIfThenElse.kt index 4fa07fd69..fca5f3d38 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestIfThenElse.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestIfThenElse.kt @@ -81,4 +81,4 @@ interface TestIfThenElse : SolverTest { * producing 1 solution which binds variable `X` to `1`. */ fun testIfOrElseTrue() -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestIfThenElseImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestIfThenElseImpl.kt index 438d9c505..b65887970 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestIfThenElseImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestIfThenElseImpl.kt @@ -2,7 +2,7 @@ package it.unibo.tuprolog.solve import it.unibo.tuprolog.dsl.theory.prolog -internal class TestIfThenElseImpl(private val solverFactory: SolverFactory) : TestIfThenElse{ +internal class TestIfThenElseImpl(private val solverFactory: SolverFactory) : TestIfThenElse { override fun testIfTrueElseFail() { prolog { val solver = solverFactory.solverWithDefaultBuiltins() @@ -91,7 +91,7 @@ internal class TestIfThenElseImpl(private val solverFactory: SolverFactory) : Te prolog { val solver = solverFactory.solverWithDefaultBuiltins() - val query = ";"("->"(true,("X" `=` 1) or ("X" `=` 2)), true) + val query = ";"("->"(true, ("X" `=` 1) or ("X" `=` 2)), true) val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( @@ -119,4 +119,4 @@ internal class TestIfThenElseImpl(private val solverFactory: SolverFactory) : Te ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestIfThenImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestIfThenImpl.kt index c13967717..65dfe452d 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestIfThenImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestIfThenImpl.kt @@ -2,7 +2,7 @@ package it.unibo.tuprolog.solve import it.unibo.tuprolog.dsl.theory.prolog -internal class TestIfThenImpl(private val solverFactory: SolverFactory) : TestIfThen{ +internal class TestIfThenImpl(private val solverFactory: SolverFactory) : TestIfThen { override fun testIfThenTrue() { prolog { val solver = solverFactory.solverWithDefaultBuiltins() @@ -77,7 +77,7 @@ internal class TestIfThenImpl(private val solverFactory: SolverFactory) : TestIf prolog { val solver = solverFactory.solverWithDefaultBuiltins() - val query = "->"(true,("X" `=` 1) or ("X" `=` 2)) + val query = "->"(true, ("X" `=` 1) or ("X" `=` 2)) val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( @@ -91,4 +91,4 @@ internal class TestIfThenImpl(private val solverFactory: SolverFactory) : TestIf ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestInteger.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestInteger.kt index 2631d66e5..8c16f4c90 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestInteger.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestInteger.kt @@ -3,7 +3,7 @@ package it.unibo.tuprolog.solve /** * Tests of Integer */ -interface TestInteger : SolverTest{ +interface TestInteger : SolverTest { companion object { fun prototype(solverFactory: SolverFactory): TestInteger = TestIntegerImpl(solverFactory) @@ -53,4 +53,4 @@ interface TestInteger : SolverTest{ * fails on a solver initialized with default built-ins and with and empty theory. */ fun testIntAtom() -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestIntegerImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestIntegerImpl.kt index d8bb23b34..eaa8d9b5f 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestIntegerImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestIntegerImpl.kt @@ -3,7 +3,7 @@ package it.unibo.tuprolog.solve import it.unibo.tuprolog.dsl.theory.prolog import kotlin.collections.listOf as ktListOf -internal class TestIntegerImpl(private val solverFactory: SolverFactory) : TestInteger{ +internal class TestIntegerImpl(private val solverFactory: SolverFactory) : TestInteger { override fun testIntPositiveNum() { prolog { val solver = solverFactory.solverWithDefaultBuiltins() @@ -73,4 +73,4 @@ internal class TestIntegerImpl(private val solverFactory: SolverFactory) : TestI ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestIs.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestIs.kt index 20184b937..0e4e5ef38 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestIs.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestIs.kt @@ -64,4 +64,4 @@ interface TestIs : SolverTest { * producing 1 solution which binds variable `X` to `3.0`. */ fun testIsXFloat() -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestIsImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestIsImpl.kt index 817f90693..e01ac2de7 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestIsImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestIsImpl.kt @@ -107,4 +107,4 @@ internal class TestIsImpl(private val solverFactory: SolverFactory) : TestIs { ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNonVar.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNonVar.kt index 92c61cd1b..a37d43f6f 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNonVar.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNonVar.kt @@ -67,4 +67,4 @@ interface TestNonVar : SolverTest { * producing 1 solution with no variable bindings. */ fun testNonVar() -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNonVarImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNonVarImpl.kt index 7810a1ec5..22590f930 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNonVarImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNonVarImpl.kt @@ -19,7 +19,7 @@ internal class TestNonVarImpl(private val solverFactory: SolverFactory) : TestNo } } - override fun testNonVarFoo() { //foo + override fun testNonVarFoo() { // foo prolog { val solver = solverFactory.solverWithDefaultBuiltins() @@ -33,7 +33,7 @@ internal class TestNonVarImpl(private val solverFactory: SolverFactory) : TestNo } } - override fun testNonVarFooCl() { //Foo (CapsLock) + override fun testNonVarFooCl() { // Foo (CapsLock) prolog { val solver = solverFactory.solverWithDefaultBuiltins() diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNotProvable.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNotProvable.kt index 4ede4fa4b..6cc98bcf1 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNotProvable.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNotProvable.kt @@ -71,4 +71,4 @@ interface TestNotProvable : SolverTest { * producing exception `instantiation_error`. */ fun testNPX() -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNotProvableImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNotProvableImpl.kt index 3424c4021..ea7c66416 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNotProvableImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNotProvableImpl.kt @@ -9,12 +9,13 @@ class TestNotProvableImpl(private val solverFactory: SolverFactory) : TestNotPro prolog { val solver = solverFactory.solverWithDefaultBuiltins() - val query = "not"(true) + val query = "not"(true) val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( kotlin.collections.listOf( - query.no()), + query.no() + ), solutions ) } @@ -24,12 +25,13 @@ class TestNotProvableImpl(private val solverFactory: SolverFactory) : TestNotPro prolog { val solver = solverFactory.solverWithDefaultBuiltins() - val query = "not"("!") + val query = "not"("!") val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( kotlin.collections.listOf( - query.no()), + query.no() + ), solutions ) } @@ -39,12 +41,13 @@ class TestNotProvableImpl(private val solverFactory: SolverFactory) : TestNotPro prolog { val solver = solverFactory.solverWithDefaultBuiltins() - val query = "not"(("!" and fail)) + val query = "not"(("!" and fail)) val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( kotlin.collections.listOf( - query.yes()), + query.yes() + ), solutions ) } @@ -130,4 +133,4 @@ class TestNotProvableImpl(private val solverFactory: SolverFactory) : TestNotPro ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNotUnify.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNotUnify.kt index 4af291c14..36f7f329b 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNotUnify.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNotUnify.kt @@ -95,5 +95,4 @@ interface TestNotUnify : SolverTest { * succeeds on a solver initialized with default built-ins and with and empty theory. */ fun testFMultipleTermNotUnify() - -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNotUnifyImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNotUnifyImpl.kt index 4578c2fd3..dcdc2de7b 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNotUnifyImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNotUnifyImpl.kt @@ -144,4 +144,4 @@ internal class TestNotUnifyImpl(private val solverFactory: SolverFactory) : Test ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNumber.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNumber.kt index 77fc8a329..5d11f9a59 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNumber.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNumber.kt @@ -3,7 +3,7 @@ package it.unibo.tuprolog.solve /** * Tests of number */ -interface TestNumber : SolverTest{ +interface TestNumber : SolverTest { companion object { fun prototype(solverFactory: SolverFactory): TestNumber = TestNumberImpl(solverFactory) @@ -53,4 +53,4 @@ interface TestNumber : SolverTest{ * fails on a solver initialized with default built-ins and with and empty theory. */ fun testXNum() -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNumberImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNumberImpl.kt index e6f0ada26..a67c5c008 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNumberImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestNumberImpl.kt @@ -72,4 +72,4 @@ internal class TestNumberImpl(private val solverFactory: SolverFactory) : TestNu ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestOnce.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestOnce.kt index 7aa114043..216002843 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestOnce.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestOnce.kt @@ -3,7 +3,7 @@ package it.unibo.tuprolog.solve interface TestOnce : SolverTest { companion object { fun prototype(solverFactory: SolverFactory): TestOnce = - TestOnceImpl(solverFactory) + TestOnceImpl(solverFactory) } /** @@ -62,4 +62,4 @@ interface TestOnce : SolverTest { * producing exception `instantiation_error`. */ fun testOnceX() -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestOnceImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestOnceImpl.kt index 01a90178e..4ad328e78 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestOnceImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestOnceImpl.kt @@ -13,8 +13,8 @@ internal class TestOnceImpl(private val solverFactory: SolverFactory) : TestOnce val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - kotlin.collections.listOf(query.yes()), - solutions + kotlin.collections.listOf(query.yes()), + solutions ) } } @@ -27,13 +27,13 @@ internal class TestOnceImpl(private val solverFactory: SolverFactory) : TestOnce val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - with(query) { - kotlin.collections.listOf( - yes("X" to 1), - yes("X" to 2) - ) - }, - solutions + with(query) { + kotlin.collections.listOf( + yes("X" to 1), + yes("X" to 2) + ) + }, + solutions ) } } @@ -46,8 +46,8 @@ internal class TestOnceImpl(private val solverFactory: SolverFactory) : TestOnce val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - kotlin.collections.listOf(query.yes()), - solutions + kotlin.collections.listOf(query.yes()), + solutions ) } } @@ -60,8 +60,8 @@ internal class TestOnceImpl(private val solverFactory: SolverFactory) : TestOnce val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - kotlin.collections.listOf(query.no()), - solutions + kotlin.collections.listOf(query.no()), + solutions ) } } @@ -74,18 +74,18 @@ internal class TestOnceImpl(private val solverFactory: SolverFactory) : TestOnce val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - kotlin.collections.listOf( - query.halt( - TypeError.forGoal( - DummyInstances.executionContext, - Signature("once", 1), - TypeError.Expected.CALLABLE, - numOf(3) - - ) - ) - ), - solutions + kotlin.collections.listOf( + query.halt( + TypeError.forGoal( + DummyInstances.executionContext, + Signature("once", 1), + TypeError.Expected.CALLABLE, + numOf(3) + + ) + ) + ), + solutions ) } } @@ -98,17 +98,17 @@ internal class TestOnceImpl(private val solverFactory: SolverFactory) : TestOnce val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - kotlin.collections.listOf( - query.halt( - InstantiationError.forGoal( - DummyInstances.executionContext, - Signature("once", 1), - varOf("X") - ) - ) - ), - solutions + kotlin.collections.listOf( + query.halt( + InstantiationError.forGoal( + DummyInstances.executionContext, + Signature("once", 1), + varOf("X") + ) + ) + ), + solutions ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestOr.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestOr.kt index 9abee3fb8..bd0f3a5df 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestOr.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestOr.kt @@ -58,4 +58,4 @@ interface TestOr : SolverTest { * producing 2 solutions which bind variable `X` to the values `1` and `2`, respectively. */ fun testOrDoubleAssignment() -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestOrImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestOrImpl.kt index cb9c363a7..6be46c30a 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestOrImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestOrImpl.kt @@ -88,4 +88,4 @@ internal class TestOrImpl(private val solverFactory: SolverFactory) : TestOr { ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestRepeat.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestRepeat.kt index b7044eaad..8c8d6c6de 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestRepeat.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestRepeat.kt @@ -3,7 +3,7 @@ package it.unibo.tuprolog.solve interface TestRepeat : SolverTest { companion object { fun prototype(solverFactory: SolverFactory): TestRepeat = - TestRepeatImpl(solverFactory) + TestRepeatImpl(solverFactory) } /** @@ -14,4 +14,4 @@ interface TestRepeat : SolverTest { * fails on a solver initialized with default built-ins and with and empty theory, */ fun testRepeat() -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestRepeatImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestRepeatImpl.kt index 367fe823c..ce1690a31 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestRepeatImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestRepeatImpl.kt @@ -11,9 +11,9 @@ internal class TestRepeatImpl(private val solverFactory: SolverFactory) : TestRe val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - kotlin.collections.listOf(query.no()), - solutions + kotlin.collections.listOf(query.no()), + solutions ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestRetract.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestRetract.kt index 7c707979a..7247d75d2 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestRetract.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestRetract.kt @@ -25,4 +25,4 @@ interface TestRetract : SolverTest { * producing exception `permission_error(modify,private_procedure,atom/1)`. */ fun testRetractAtomEmptyList() -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestRetractImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestRetractImpl.kt index e82033ae0..4daf57dac 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestRetractImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestRetractImpl.kt @@ -3,7 +3,6 @@ package it.unibo.tuprolog.solve import it.unibo.tuprolog.dsl.theory.prolog import it.unibo.tuprolog.solve.exception.error.DomainError import it.unibo.tuprolog.solve.exception.error.PermissionError -import it.unibo.tuprolog.solve.exception.error.TypeError internal class TestRetractImpl(private val solverFactory: SolverFactory) : TestRetract { override fun testRetractNumIfX() { @@ -48,9 +47,9 @@ internal class TestRetractImpl(private val solverFactory: SolverFactory) : TestR "atom" / 1 ) ) - ), //Permission_error + ), // Permission_error solutions ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestSolver.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestSolver.kt index 04bdd7756..9839d1297 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestSolver.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestSolver.kt @@ -23,9 +23,9 @@ import it.unibo.tuprolog.solve.TestingClauseTheories.simpleCutAndConjunctionTheo import it.unibo.tuprolog.solve.TestingClauseTheories.simpleCutTheoryNotableGoalToSolutions import it.unibo.tuprolog.solve.TestingClauseTheories.simpleFactTheoryNotableGoalToSolutions import it.unibo.tuprolog.solve.TimeRelatedTheories.lessThan500MsGoalToSolution +import it.unibo.tuprolog.solve.TimeRelatedTheories.slightlyMoreThan500MsGoalToSolution import it.unibo.tuprolog.solve.TimeRelatedTheories.slightlyMoreThan600MsGoalToSolution import it.unibo.tuprolog.solve.TimeRelatedTheories.slightlyMoreThan700MsGoalToSolution -import it.unibo.tuprolog.solve.TimeRelatedTheories.slightlyMoreThan500MsGoalToSolution /** A prototype class for testing solver implementations */ interface TestSolver : SolverTest { @@ -183,4 +183,3 @@ interface TestSolver : SolverTest { /** atom_concat/3 test */ fun testAtomConcat() } - diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestSolverImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestSolverImpl.kt index ea7dc5f8a..2ff43b038 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestSolverImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestSolverImpl.kt @@ -68,8 +68,61 @@ import it.unibo.tuprolog.solve.flags.Unknown import it.unibo.tuprolog.solve.flags.Unknown.ERROR import it.unibo.tuprolog.solve.flags.Unknown.FAIL import it.unibo.tuprolog.solve.flags.Unknown.WARNING -import it.unibo.tuprolog.solve.stdlib.primitive.* -import it.unibo.tuprolog.solve.stdlib.rule.* +import it.unibo.tuprolog.solve.stdlib.primitive.Abolish +import it.unibo.tuprolog.solve.stdlib.primitive.Arg +import it.unibo.tuprolog.solve.stdlib.primitive.ArithmeticEqual +import it.unibo.tuprolog.solve.stdlib.primitive.ArithmeticGreaterThan +import it.unibo.tuprolog.solve.stdlib.primitive.ArithmeticGreaterThanOrEqualTo +import it.unibo.tuprolog.solve.stdlib.primitive.ArithmeticLowerThan +import it.unibo.tuprolog.solve.stdlib.primitive.ArithmeticLowerThanOrEqualTo +import it.unibo.tuprolog.solve.stdlib.primitive.ArithmeticNotEqual +import it.unibo.tuprolog.solve.stdlib.primitive.Assert +import it.unibo.tuprolog.solve.stdlib.primitive.AssertA +import it.unibo.tuprolog.solve.stdlib.primitive.AssertZ +import it.unibo.tuprolog.solve.stdlib.primitive.Atom +import it.unibo.tuprolog.solve.stdlib.primitive.AtomChars +import it.unibo.tuprolog.solve.stdlib.primitive.Atomic +import it.unibo.tuprolog.solve.stdlib.primitive.Between +import it.unibo.tuprolog.solve.stdlib.primitive.Callable +import it.unibo.tuprolog.solve.stdlib.primitive.Clause +import it.unibo.tuprolog.solve.stdlib.primitive.Compound +import it.unibo.tuprolog.solve.stdlib.primitive.CopyTerm +import it.unibo.tuprolog.solve.stdlib.primitive.CurrentOp +import it.unibo.tuprolog.solve.stdlib.primitive.CurrentPrologFlag +import it.unibo.tuprolog.solve.stdlib.primitive.EnsureExecutable +import it.unibo.tuprolog.solve.stdlib.primitive.FindAll +import it.unibo.tuprolog.solve.stdlib.primitive.Functor +import it.unibo.tuprolog.solve.stdlib.primitive.Ground +import it.unibo.tuprolog.solve.stdlib.primitive.Halt +import it.unibo.tuprolog.solve.stdlib.primitive.Integer +import it.unibo.tuprolog.solve.stdlib.primitive.Is +import it.unibo.tuprolog.solve.stdlib.primitive.Natural +import it.unibo.tuprolog.solve.stdlib.primitive.NewLine +import it.unibo.tuprolog.solve.stdlib.primitive.NonVar +import it.unibo.tuprolog.solve.stdlib.primitive.NotUnifiableWith +import it.unibo.tuprolog.solve.stdlib.primitive.Number +import it.unibo.tuprolog.solve.stdlib.primitive.Repeat +import it.unibo.tuprolog.solve.stdlib.primitive.Retract +import it.unibo.tuprolog.solve.stdlib.primitive.RetractAll +import it.unibo.tuprolog.solve.stdlib.primitive.Sleep +import it.unibo.tuprolog.solve.stdlib.primitive.TermGreaterThan +import it.unibo.tuprolog.solve.stdlib.primitive.TermGreaterThanOrEqualTo +import it.unibo.tuprolog.solve.stdlib.primitive.TermIdentical +import it.unibo.tuprolog.solve.stdlib.primitive.TermLowerThan +import it.unibo.tuprolog.solve.stdlib.primitive.TermLowerThanOrEqualTo +import it.unibo.tuprolog.solve.stdlib.primitive.TermNotIdentical +import it.unibo.tuprolog.solve.stdlib.primitive.TermNotSame +import it.unibo.tuprolog.solve.stdlib.primitive.TermSame +import it.unibo.tuprolog.solve.stdlib.primitive.UnifiesWith +import it.unibo.tuprolog.solve.stdlib.primitive.Univ +import it.unibo.tuprolog.solve.stdlib.primitive.Var +import it.unibo.tuprolog.solve.stdlib.primitive.Write +import it.unibo.tuprolog.solve.stdlib.rule.Append +import it.unibo.tuprolog.solve.stdlib.rule.Arrow +import it.unibo.tuprolog.solve.stdlib.rule.Member +import it.unibo.tuprolog.solve.stdlib.rule.Not +import it.unibo.tuprolog.solve.stdlib.rule.Once +import it.unibo.tuprolog.solve.stdlib.rule.Semicolon import kotlin.test.assertEquals import kotlin.test.assertNotNull import kotlin.test.assertTrue @@ -272,9 +325,9 @@ internal class TestSolverImpl(private val solverFactory: SolverFactory) : TestSo val assertX = "assert$suffix" val query = assertX("f"(1)) and - assertX("f"(2)) and - assertX("f"(3)) and - "f"(X) + assertX("f"(2)) and + assertX("f"(3)) and + "f"(X) val solutions = solver.solve(query, mediumDuration).toList() val ints = if (inverse) (3 downTo 1) else (1..3) @@ -316,12 +369,12 @@ internal class TestSolverImpl(private val solverFactory: SolverFactory) : TestSo } val query = write(atomOf("atom")) and - write(atomOf("a string")) and - write(varOf("A_Var")) and - write(numOf(1)) and - write(numOf(2.1)) and - write("f"("x")) and - nl + write(atomOf("a string")) and + write(varOf("A_Var")) and + write(numOf(1)) and + write(numOf(2.1)) and + write("f"("x")) and + nl val solutions = solver.solve(query, mediumDuration).toList() @@ -433,11 +486,11 @@ internal class TestSolverImpl(private val solverFactory: SolverFactory) : TestSo clause { "getg"(G) `if` findall(X, "g"(X), G) }, clause { "ftog"(F, G) `if` ( - retract("f"(X)) and - assert("g"(X)) and - "getf"(F) and - "getg"(G) - ) + retract("f"(X)) and + assert("g"(X)) and + "getf"(F) and + "getg"(G) + ) } ) ) @@ -559,7 +612,6 @@ internal class TestSolverImpl(private val solverFactory: SolverFactory) : TestSo ) } - /** Test with [simpleCutTheoryNotableGoalToSolutions] */ override fun testSimpleCutAlternatives() { assertSolverSolutionsCorrect( @@ -716,11 +768,11 @@ internal class TestSolverImpl(private val solverFactory: SolverFactory) : TestSo /** A test in which all testing goals are called through the Catch primitive */ override fun testCatchPrimitiveTransparency() { prolog { - fun Struct.containsHaltPrimitive(): Boolean = when (functor) { "halt" -> true - else -> argsSequence.filterIsInstance() - .any { it.containsHaltPrimitive() } + else -> + argsSequence.filterIsInstance() + .any { it.containsHaltPrimitive() } } allPrologTestingTheoriesToRespectiveGoalsAndSolutions.mapValues { (_, listOfGoalToSolutions) -> @@ -850,7 +902,8 @@ internal class TestSolverImpl(private val solverFactory: SolverFactory) : TestSo assertSolutionEquals( ktListOf( query.no() - ), solutions + ), + solutions ) } } @@ -873,7 +926,8 @@ internal class TestSolverImpl(private val solverFactory: SolverFactory) : TestSo assertSolutionEquals( ktListOf( query.yes(N to 2) - ), solutions + ), + solutions ) } } @@ -916,7 +970,8 @@ internal class TestSolverImpl(private val solverFactory: SolverFactory) : TestSo assertSolutionEquals( ktListOf( query.yes(N to 2) - ), solutions + ), + solutions ) } } @@ -938,7 +993,8 @@ internal class TestSolverImpl(private val solverFactory: SolverFactory) : TestSo assertSolutionEquals( ktListOf( query.yes(N to 2) - ), solutions + ), + solutions ) } } @@ -958,7 +1014,8 @@ internal class TestSolverImpl(private val solverFactory: SolverFactory) : TestSo assertSolutionEquals( ktListOf( query.yes() - ), solutions + ), + solutions ) } } @@ -980,7 +1037,8 @@ internal class TestSolverImpl(private val solverFactory: SolverFactory) : TestSo assertSolutionEquals( ktListOf( query.yes() - ), solutions + ), + solutions ) } } @@ -1000,7 +1058,8 @@ internal class TestSolverImpl(private val solverFactory: SolverFactory) : TestSo assertSolutionEquals( ktListOf( query.yes(N to 1) - ), solutions + ), + solutions ) } } @@ -1124,7 +1183,6 @@ internal class TestSolverImpl(private val solverFactory: SolverFactory) : TestSo } override fun testFunctor() { - prolog { val solver = solverFactory.solverWithDefaultBuiltins() @@ -1335,7 +1393,6 @@ internal class TestSolverImpl(private val solverFactory: SolverFactory) : TestSo ), solutions ) - } } @@ -1426,4 +1483,4 @@ internal class TestSolverImpl(private val solverFactory: SolverFactory) : TestSo mediumDuration ) } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestTerm.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestTerm.kt index fecae644a..fa1c8339e 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestTerm.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestTerm.kt @@ -252,4 +252,4 @@ interface TestTerm : SolverTest { * succeeds on a solver initialized with default built-ins and with and empty theory. */ fun testTermLessThanEq() -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestTermImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestTermImpl.kt index 730605854..279d1f8b2 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestTermImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestTermImpl.kt @@ -1,8 +1,6 @@ package it.unibo.tuprolog.solve import it.unibo.tuprolog.dsl.theory.prolog -import it.unibo.tuprolog.solve.exception.error.InstantiationError -import it.unibo.tuprolog.solve.exception.error.TypeError internal class TestTermImpl(private val solverFactory: SolverFactory) : TestTerm { override fun testTermDiff() { @@ -424,4 +422,4 @@ internal class TestTermImpl(private val solverFactory: SolverFactory) : TestTerm ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestTrue.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestTrue.kt index 1f7b96770..60dbed44d 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestTrue.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestTrue.kt @@ -3,7 +3,7 @@ package it.unibo.tuprolog.solve interface TestTrue : SolverTest { companion object { fun prototype(solverFactory: SolverFactory): TestTrue = - TestTrueImpl(solverFactory) + TestTrueImpl(solverFactory) } /** @@ -14,4 +14,4 @@ interface TestTrue : SolverTest { * succeeds on a solver initialized with default built-ins and with and empty theory, */ fun testTrue() -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestTrueImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestTrueImpl.kt index 4d28b0a04..7eabb7e8d 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestTrueImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestTrueImpl.kt @@ -11,9 +11,9 @@ internal class TestTrueImpl(private val solverFactory: SolverFactory) : TestTrue val solutions = solver.solve(query, mediumDuration).toList() assertSolutionEquals( - kotlin.collections.listOf(query.yes()), - solutions + kotlin.collections.listOf(query.yes()), + solutions ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestUnify.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestUnify.kt index 18c7d79a5..1f1ae672a 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestUnify.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestUnify.kt @@ -110,4 +110,4 @@ interface TestUnify : SolverTest { * the variable `B` to `g(g(D,D),g(D,D))` and the variable `C` to `g(D,D)`. */ fun testMultipleTermUnify() -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestUnifyImpl.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestUnifyImpl.kt index 8c32c3e07..8bcead13c 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestUnifyImpl.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestUnifyImpl.kt @@ -164,4 +164,4 @@ internal class TestUnifyImpl(private val solverFactory: SolverFactory) : TestUni ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestUtils.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestUtils.kt index 520f886ee..8e61ef966 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestUtils.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestUtils.kt @@ -9,11 +9,8 @@ package it.unibo.tuprolog.solve import it.unibo.tuprolog.core.Struct import it.unibo.tuprolog.core.Substitution -import it.unibo.tuprolog.core.Tuple import it.unibo.tuprolog.solve.exception.PrologError import it.unibo.tuprolog.solve.exception.TuPrologRuntimeException -import it.unibo.tuprolog.solve.exception.error.InstantiationError -import it.unibo.tuprolog.solve.exception.error.TypeError import it.unibo.tuprolog.solve.primitive.PrimitiveWrapper import it.unibo.tuprolog.solve.rule.RuleWrapper import kotlin.jvm.JvmName @@ -70,7 +67,6 @@ inline fun assertOverFailure(throwExpression: () -> Unit * **these variables are compared only by name**, because instances will differ */ fun assertSolutionEquals(expected: Solution, actual: Solution) { - fun reportMsg(expected: Any, actual: Any, motivation: String = "") = "Expected: `$expected`\nActual\t: `$actual`" + if (motivation.isNotBlank()) " ($motivation)" else "" @@ -80,8 +76,6 @@ fun assertSolutionEquals(expected: Solution, actual: Solution) { fun assertSameQuery(expected: Solution, actual: Solution) = assertEquals(expected.query, actual.query, reportMsg(expected, actual)) - - when { expected is Solution.Halt -> { assertSameClass(expected, actual) @@ -198,7 +192,7 @@ fun Solver.logKBs() { /** Utility function to log passed goal and solutions */ fun logGoalAndSolutions(goal: Struct, solutions: Iterable) { - println("?- ${goal}.") + println("?- $goal.") solutions.forEach { when (it) { is Solution.Yes -> { diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestingClauseTheories.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestingClauseTheories.kt index 76d606f76..cf901d398 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestingClauseTheories.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestingClauseTheories.kt @@ -1,6 +1,9 @@ package it.unibo.tuprolog.solve -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.TermVisitor +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.dsl.theory.prolog import it.unibo.tuprolog.solve.PrologStandardExampleTheories.allPrologStandardTestingTheoryToRespectiveGoalsAndSolutions import it.unibo.tuprolog.solve.exception.HaltException @@ -303,7 +306,7 @@ object TestingClauseTheories { { "my_rev"(emptyList, "L2", "L2") `if` "!" }, { "my_rev"(consOf("X", "Xs"), "L2", "Acc") `if` - "my_rev"("Xs", "L2", consOf("X", "Acc")) + "my_rev"("Xs", "L2", consOf("X", "Acc")) } ) } @@ -342,10 +345,10 @@ object TestingClauseTheories { { "range"("N", "N", listOf("N")) `if` "!" }, { "range"("M", "N", consOf("M", "Ns")) `if` ( - "<"("M", "N") and - ("M1" `is` (varOf("M") + 1)) and - "range"("M1", "N", "Ns") - ) + "<"("M", "N") and + ("M1" `is` (varOf("M") + 1)) and + "range"("M1", "N", "Ns") + ) } ) } diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestingTermOperators.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestingTermOperators.kt index 21432dd0f..ec728ce6a 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestingTermOperators.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestingTermOperators.kt @@ -44,7 +44,8 @@ object TestingTermOperators { "@>="(intOf(1), intOf(1)).hasSolutions({ yes() }), "@>="("stringTest", "stringTest").hasSolutions({ yes() }), "@>="("stringTest", "stringTest1").hasSolutions({ no() }), - "@>="("stringTest", intOf(1)).hasSolutions({ yes() } + "@>="("stringTest", intOf(1)).hasSolutions( + { yes() } ) ) } @@ -132,5 +133,4 @@ object TestingTermOperators { ) } } - -} \ No newline at end of file +} diff --git a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TimeRelatedTheories.kt b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TimeRelatedTheories.kt index c57165767..629f6a8b3 100644 --- a/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TimeRelatedTheories.kt +++ b/test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TimeRelatedTheories.kt @@ -95,4 +95,4 @@ object TimeRelatedTheories { ) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/SolveResponseTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/SolveResponseTest.kt index 7d7212927..19116897b 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/SolveResponseTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/SolveResponseTest.kt @@ -1,12 +1,8 @@ package it.unibo.tuprolog.solve import it.unibo.tuprolog.solve.primitive.Solve -import it.unibo.tuprolog.solve.testutils.SolveUtils.aDynamicKB import it.unibo.tuprolog.solve.testutils.SolveUtils.aSideEffectManager import it.unibo.tuprolog.solve.testutils.SolveUtils.aSolution -import it.unibo.tuprolog.solve.testutils.SolveUtils.aStaticKB -import it.unibo.tuprolog.solve.testutils.SolveUtils.someFlags -import it.unibo.tuprolog.solve.testutils.SolveUtils.someLibraries import it.unibo.tuprolog.solve.testutils.SolveUtils.someSideEffects import kotlin.test.Test import kotlin.test.assertEquals @@ -40,5 +36,4 @@ internal class SolveResponseTest { fun equalsWorksAsExpected() { assertEquals(aResponse.copy(), aResponse) } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/TimeRepresentationKtTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/TimeRepresentationKtTest.kt index 5da7952bd..9f77d86cd 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/TimeRepresentationKtTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/TimeRepresentationKtTest.kt @@ -27,5 +27,4 @@ internal class TimeRepresentationKtTest { } } } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/UtilsTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/UtilsTest.kt index 8ebb9be34..36be9f8e0 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/UtilsTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/UtilsTest.kt @@ -14,7 +14,6 @@ internal class UtilsTest { @Test fun foreachWithLookAheadWorksExactlyLikeNormalForeach() { - // should not launch exception emptyList().forEachWithLookahead { _, _ -> throw IllegalStateException() } @@ -34,5 +33,4 @@ internal class UtilsTest { } } } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/exception/HaltExceptionTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/exception/HaltExceptionTest.kt index 72abbe1eb..f27cca824 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/exception/HaltExceptionTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/exception/HaltExceptionTest.kt @@ -36,5 +36,4 @@ internal class HaltExceptionTest { assertSameMessageCauseContextStatus(aMessage, aCause, aDifferentContext, anExitStatus, toBeTested) } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/exception/PrologErrorTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/exception/PrologErrorTest.kt index 80885160a..c6fa2b73e 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/exception/PrologErrorTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/exception/PrologErrorTest.kt @@ -70,13 +70,15 @@ internal class PrologErrorTest { @Test fun errorIsComputedCorrectly() { assertErrorStructCorrect(underTestPrologError) - assertErrorStructCorrect(object : PrologError(context = aContext, type = aType) { - override fun updateContext(newContext: ExecutionContext): PrologError = - of(this.message, this.cause, this.contexts.setFirst(newContext), this.type, this.extraData) - - override fun pushContext(newContext: ExecutionContext): PrologError = - of(this.message, this.cause, this.contexts.addLast(newContext), this.type, this.extraData) - }) + assertErrorStructCorrect( + object : PrologError(context = aContext, type = aType) { + override fun updateContext(newContext: ExecutionContext): PrologError = + of(this.message, this.cause, this.contexts.setFirst(newContext), this.type, this.extraData) + + override fun pushContext(newContext: ExecutionContext): PrologError = + of(this.message, this.cause, this.contexts.addLast(newContext), this.type, this.extraData) + } + ) } @Test diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/exception/error/EvaluationErrorTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/exception/error/EvaluationErrorTest.kt index a7f76209f..2e70dc3a7 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/exception/error/EvaluationErrorTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/exception/error/EvaluationErrorTest.kt @@ -47,4 +47,4 @@ internal class EvaluationErrorTest { fun evaluationErrorErrorTypeCorrect() { assertEquals(testErrorType, aCallableTypeError.errorType) } -} \ No newline at end of file +} diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/exception/error/TypeErrorExpectedTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/exception/error/TypeErrorExpectedTest.kt index 569366c5e..db3e350f9 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/exception/error/TypeErrorExpectedTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/exception/error/TypeErrorExpectedTest.kt @@ -4,7 +4,11 @@ import it.unibo.tuprolog.core.Atom import it.unibo.tuprolog.core.Struct import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.solve.exception.error.testutils.TypeErrorExpectedUtils -import kotlin.test.* +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertNull +import kotlin.test.assertSame +import kotlin.test.fail /** * Test class for [TypeError.Expected] diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/exception/error/testutils/TypeErrorExpectedUtils.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/exception/error/testutils/TypeErrorExpectedUtils.kt index aecfb2fb4..e490803a3 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/exception/error/testutils/TypeErrorExpectedUtils.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/exception/error/testutils/TypeErrorExpectedUtils.kt @@ -18,5 +18,4 @@ internal object TypeErrorExpectedUtils { internal val allNamesToInstances by lazy { predefinedErrorNamesToInstances } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/exception/testutils/PrologErrorUtils.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/exception/testutils/PrologErrorUtils.kt index 5dd57b6ec..844b0570c 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/exception/testutils/PrologErrorUtils.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/exception/testutils/PrologErrorUtils.kt @@ -65,5 +65,4 @@ internal object PrologErrorUtils { prologError.errorStruct ) } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/ArithmeticEvaluatorTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/ArithmeticEvaluatorTest.kt index 0b0ee0f29..1a31396d9 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/ArithmeticEvaluatorTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/ArithmeticEvaluatorTest.kt @@ -32,5 +32,4 @@ internal class ArithmeticEvaluatorTest { assertEquals(result, toBeTested) } } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/ComputeRequestTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/ComputeRequestTest.kt index 35691022d..dd6d04cba 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/ComputeRequestTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/ComputeRequestTest.kt @@ -2,6 +2,8 @@ package it.unibo.tuprolog.solve.function import it.unibo.tuprolog.core.Struct import it.unibo.tuprolog.core.Truth +import it.unibo.tuprolog.solve.TimeDuration +import it.unibo.tuprolog.solve.currentTimeInstant import it.unibo.tuprolog.solve.function.testutils.ComputeUtils.aRequestIssuingInstant import it.unibo.tuprolog.solve.function.testutils.ComputeUtils.aResult import it.unibo.tuprolog.solve.function.testutils.ComputeUtils.aSignature @@ -13,8 +15,6 @@ import it.unibo.tuprolog.solve.function.testutils.ComputeUtils.assertContainsCor import it.unibo.tuprolog.solve.function.testutils.ComputeUtils.createRequest import it.unibo.tuprolog.solve.function.testutils.ComputeUtils.defaultResponse import it.unibo.tuprolog.solve.function.testutils.ComputeUtils.varargArgumentList -import it.unibo.tuprolog.solve.TimeDuration -import it.unibo.tuprolog.solve.currentTimeInstant import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/ExpressionReduceTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/ExpressionReducerTest.kt similarity index 96% rename from test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/ExpressionReduceTest.kt rename to test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/ExpressionReducerTest.kt index 341014c9f..823afdc7e 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/ExpressionReduceTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/ExpressionReducerTest.kt @@ -10,7 +10,7 @@ import kotlin.test.assertEquals import kotlin.test.assertSame /** - * Test class for [ExpressionEvaluator] + * Test class for [ExpressionReducerTest] * * @author Enrico */ @@ -32,5 +32,4 @@ internal class ExpressionReducerTest { assertEquals(output, toBeTested) } } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/FunctionWrapperTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/FunctionWrapperTest.kt index 9f51c254a..0b6765f94 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/FunctionWrapperTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/FunctionWrapperTest.kt @@ -37,5 +37,4 @@ internal class FunctionWrapperTest { } } } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/PrologFunctionTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/PrologFunctionTest.kt index 2722f0091..960868245 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/PrologFunctionTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/PrologFunctionTest.kt @@ -44,5 +44,4 @@ internal class PrologFunctionTest { } } } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/testutils/ArithmeticEvaluatorUtils.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/testutils/ArithmeticEvaluatorUtils.kt index 3cbf835af..40e575dc3 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/testutils/ArithmeticEvaluatorUtils.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/testutils/ArithmeticEvaluatorUtils.kt @@ -1,15 +1,19 @@ package it.unibo.tuprolog.solve.function.testutils -import it.unibo.tuprolog.core.* -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.CommonBuiltins -import it.unibo.tuprolog.solve.function.ArithmeticEvaluator +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Real +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.solve.ExecutionContext import it.unibo.tuprolog.solve.Signature import it.unibo.tuprolog.solve.exception.error.EvaluationError import it.unibo.tuprolog.solve.exception.error.InstantiationError import it.unibo.tuprolog.solve.exception.error.TypeError +import it.unibo.tuprolog.solve.function.ArithmeticEvaluator +import it.unibo.tuprolog.solve.library.Libraries import it.unibo.tuprolog.solve.primitive.Solve +import it.unibo.tuprolog.solve.stdlib.CommonBuiltins /** * Utils singleton to help testing [ArithmeticEvaluator] diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/testutils/ComputeUtils.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/testutils/ComputeUtils.kt index 702bbc4ea..99592c685 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/testutils/ComputeUtils.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/testutils/ComputeUtils.kt @@ -4,12 +4,12 @@ import it.unibo.tuprolog.core.Atom import it.unibo.tuprolog.core.Empty import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.core.Truth -import it.unibo.tuprolog.solve.Signature -import it.unibo.tuprolog.solve.function.Compute import it.unibo.tuprolog.solve.DummyInstances import it.unibo.tuprolog.solve.ExecutionContext +import it.unibo.tuprolog.solve.Signature import it.unibo.tuprolog.solve.TimeDuration import it.unibo.tuprolog.solve.TimeInstant +import it.unibo.tuprolog.solve.function.Compute import kotlin.test.assertEquals import kotlin.test.assertTrue @@ -62,5 +62,4 @@ internal object ComputeUtils { requestIssuingInstant: TimeInstant = aRequestIssuingInstant, executionMaxDuration: TimeDuration = anExecutionMaxDuration ) = Compute.Request(signature, arguments, executionContext, requestIssuingInstant, executionMaxDuration) - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/testutils/ExpressionEvaluatorUtils.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/testutils/ExpressionEvaluatorUtils.kt index 68044ed35..cd9b14a31 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/testutils/ExpressionEvaluatorUtils.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/testutils/ExpressionEvaluatorUtils.kt @@ -3,13 +3,13 @@ package it.unibo.tuprolog.solve.function.testutils import it.unibo.tuprolog.core.Atom import it.unibo.tuprolog.core.Struct import it.unibo.tuprolog.core.Term -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.library.Library +import it.unibo.tuprolog.solve.DummyInstances +import it.unibo.tuprolog.solve.ExecutionContext import it.unibo.tuprolog.solve.Signature import it.unibo.tuprolog.solve.function.ExpressionEvaluator import it.unibo.tuprolog.solve.function.PrologFunction -import it.unibo.tuprolog.solve.DummyInstances -import it.unibo.tuprolog.solve.ExecutionContext +import it.unibo.tuprolog.solve.library.Libraries +import it.unibo.tuprolog.solve.library.Library import it.unibo.tuprolog.solve.primitive.Solve /** @@ -96,5 +96,4 @@ internal object ExpressionEvaluatorUtils { arguments = emptyList(), context = createContextWithFunctionBy(signature, function) ) - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/testutils/FunctionWrapperUtils.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/testutils/FunctionWrapperUtils.kt index c5865f953..68850cf5c 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/testutils/FunctionWrapperUtils.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/function/testutils/FunctionWrapperUtils.kt @@ -2,14 +2,14 @@ package it.unibo.tuprolog.solve.function.testutils import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.core.Truth +import it.unibo.tuprolog.solve.DummyInstances +import it.unibo.tuprolog.solve.ExecutionContext import it.unibo.tuprolog.solve.Signature import it.unibo.tuprolog.solve.extractSignature import it.unibo.tuprolog.solve.function.Compute import it.unibo.tuprolog.solve.function.FunctionWrapper import it.unibo.tuprolog.solve.function.PrologFunction import it.unibo.tuprolog.solve.primitive.testutils.WrapperUtils -import it.unibo.tuprolog.solve.DummyInstances -import it.unibo.tuprolog.solve.ExecutionContext import kotlin.test.assertTrue /** diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/library/LibrariesTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/library/LibrariesTest.kt index f01451deb..b8f538d82 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/library/LibrariesTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/library/LibrariesTest.kt @@ -115,7 +115,7 @@ internal class LibrariesTest { @Test fun primitivesShouldReturnAllAliasedPrimitivesEvenAfterOverriding() { val correct = aliasLibraryMap(overridingLibrary.alias, overriddenLibrary.primitives) + - library.primitives.map { aliasPrimitiveOrFunction(library.alias, it) } + library.primitives.map { aliasPrimitiveOrFunction(library.alias, it) } val toBeTested = Libraries(library, overridingLibrary) assertEquals(correct, toBeTested.primitives) @@ -144,7 +144,7 @@ internal class LibrariesTest { @Test fun functionsShouldReturnAllAliasedPrimitivesEvenAfterOverriding() { val correct = aliasLibraryMap(overridingLibrary.alias, overriddenLibrary.functions) + - library.functions.map { aliasPrimitiveOrFunction(library.alias, it) } + library.functions.map { aliasPrimitiveOrFunction(library.alias, it) } val toBeTested = Libraries(library, overridingLibrary) assertEquals(correct, toBeTested.functions) diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/library/LibraryAliasedTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/library/LibraryAliasedTest.kt index e8295551f..8a8b4e131 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/library/LibraryAliasedTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/library/LibraryAliasedTest.kt @@ -21,5 +21,4 @@ internal class LibraryAliasedTest { assertEquals(Libraries(library, overridingLibrary), toBeTested) } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/library/impl/LibraryAliasedImplTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/library/impl/LibraryAliasedImplTest.kt index 3ed5b84d5..a11a1c7d4 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/library/impl/LibraryAliasedImplTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/library/impl/LibraryAliasedImplTest.kt @@ -32,5 +32,4 @@ internal class LibraryAliasedImplTest { ) } } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/library/impl/LibraryImplTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/library/impl/LibraryImplTest.kt index d59618795..8e80e9122 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/library/impl/LibraryImplTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/library/impl/LibraryImplTest.kt @@ -12,7 +12,11 @@ import it.unibo.tuprolog.solve.library.Library import it.unibo.tuprolog.solve.library.testutils.LibraryUtils import it.unibo.tuprolog.solve.library.testutils.LibraryUtils.makeLib import it.unibo.tuprolog.theory.Theory -import kotlin.test.* +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertTrue +import kotlin.test.fail /** * Test class for [LibraryImpl] and [Library] @@ -100,10 +104,12 @@ internal class LibraryImplTest { primitives.keys.forEach { signature -> assertTrue { libraryInstance.hasPrimitive(signature) } } - (theory.rules.map { it.head.extractSignature() } + Signature( - "ciao", - 3 - )).forEach { + ( + theory.rules.map { it.head.extractSignature() } + Signature( + "ciao", + 3 + ) + ).forEach { assertFalse { libraryInstance.hasPrimitive(it) } } } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/library/testutils/LibraryUtils.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/library/testutils/LibraryUtils.kt index 802f4f1dd..e19d5f01c 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/library/testutils/LibraryUtils.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/library/testutils/LibraryUtils.kt @@ -9,12 +9,12 @@ import it.unibo.tuprolog.core.operators.OperatorSet import it.unibo.tuprolog.core.operators.Specifier import it.unibo.tuprolog.solve.ExecutionContext import it.unibo.tuprolog.solve.Signature -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.function.Compute import it.unibo.tuprolog.solve.function.PrologFunction import it.unibo.tuprolog.solve.library.AliasedLibrary import it.unibo.tuprolog.solve.library.Library import it.unibo.tuprolog.solve.primitive.Primitive +import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.theory.Theory /** @@ -113,7 +113,6 @@ internal object LibraryUtils { ) } - /** A method to disambiguate use of Library.of reference */ internal fun libraryWithAliasConstructor( opSet: OperatorSet, diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/primitive/AbstractWrapperTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/primitive/AbstractWrapperTest.kt index 77c390d78..33d2977d2 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/primitive/AbstractWrapperTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/primitive/AbstractWrapperTest.kt @@ -47,11 +47,11 @@ internal class AbstractWrapperTest { // this class was added since Kotlin/JS won't pass tests using "object literals" // maybe in future releases of Kotlin the problem will be solved - constructor(name: String, arity: Int, vararg: Boolean, value: T) - : this(Signature(name, arity, vararg), value) + constructor(name: String, arity: Int, vararg: Boolean, value: T) : + this(Signature(name, arity, vararg), value) - constructor(name: String, arity: Int, value: T) - : this(Signature(name, arity, false), value) + constructor(name: String, arity: Int, value: T) : + this(Signature(name, arity, false), value) override val wrappedImplementation: T = value } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/primitive/PrimitiveWrapperTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/primitive/PrimitiveWrapperTest.kt index 6d54505f4..6c6e57140 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/primitive/PrimitiveWrapperTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/primitive/PrimitiveWrapperTest.kt @@ -1,5 +1,7 @@ package it.unibo.tuprolog.solve.primitive +import it.unibo.tuprolog.solve.assertOverFailure +import it.unibo.tuprolog.solve.exception.error.InstantiationError import it.unibo.tuprolog.solve.primitive.PrimitiveWrapper.Companion.ensuringAllArgumentsAreInstantiated import it.unibo.tuprolog.solve.primitive.testutils.PrimitiveWrapperUtils.allGroundRequests import it.unibo.tuprolog.solve.primitive.testutils.PrimitiveWrapperUtils.createPrimitiveRequest @@ -9,8 +11,6 @@ import it.unibo.tuprolog.solve.primitive.testutils.PrimitiveWrapperUtils.nonAllG import it.unibo.tuprolog.solve.primitive.testutils.PrimitiveWrapperUtils.primitive import it.unibo.tuprolog.solve.primitive.testutils.WrapperUtils.wrapperToMatchingSignatureRequest import it.unibo.tuprolog.solve.primitive.testutils.WrapperUtils.wrapperToNotMatchingSignatureRequest -import it.unibo.tuprolog.solve.assertOverFailure -import it.unibo.tuprolog.solve.exception.error.InstantiationError import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/primitive/SignatureTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/primitive/SignatureTest.kt index 4237e9e7e..fe86b4856 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/primitive/SignatureTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/primitive/SignatureTest.kt @@ -1,9 +1,22 @@ package it.unibo.tuprolog.solve.primitive -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Indicator +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Numeric +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.Truth +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.solve.Signature import it.unibo.tuprolog.solve.extractSignature -import kotlin.test.* +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith +import kotlin.test.assertFalse +import kotlin.test.assertNull +import kotlin.test.assertTrue +import kotlin.test.fail /** * Test class for [Signature] diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/primitive/testutils/PrimitiveWrapperUtils.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/primitive/testutils/PrimitiveWrapperUtils.kt index 90cade644..8a227eabe 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/primitive/testutils/PrimitiveWrapperUtils.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/primitive/testutils/PrimitiveWrapperUtils.kt @@ -1,12 +1,12 @@ package it.unibo.tuprolog.solve.primitive.testutils import it.unibo.tuprolog.core.Term -import it.unibo.tuprolog.solve.primitive.Primitive -import it.unibo.tuprolog.solve.primitive.PrimitiveWrapper -import it.unibo.tuprolog.solve.Signature -import it.unibo.tuprolog.solve.extractSignature import it.unibo.tuprolog.solve.DummyInstances import it.unibo.tuprolog.solve.ExecutionContext +import it.unibo.tuprolog.solve.Signature +import it.unibo.tuprolog.solve.extractSignature +import it.unibo.tuprolog.solve.primitive.Primitive +import it.unibo.tuprolog.solve.primitive.PrimitiveWrapper import it.unibo.tuprolog.solve.primitive.Solve import kotlin.test.assertTrue diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/primitive/testutils/WrapperUtils.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/primitive/testutils/WrapperUtils.kt index 99a77f107..ce089722a 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/primitive/testutils/WrapperUtils.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/primitive/testutils/WrapperUtils.kt @@ -1,7 +1,13 @@ package it.unibo.tuprolog.solve.primitive.testutils +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Real +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.Truth +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.solve.AbstractWrapper -import it.unibo.tuprolog.core.* import it.unibo.tuprolog.solve.Signature import it.unibo.tuprolog.solve.extractSignature import kotlin.collections.List as KtList @@ -20,7 +26,8 @@ internal object WrapperUtils { Signature("ciao", 0), listOf(Atom.of("ciao")), listOf( - Atom.of("ciaO"), Atom.of("cc") + Atom.of("ciaO"), + Atom.of("cc") ) ), Triple( diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/ArcTangentTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/ArcTangentTest.kt index 2255f67ba..554f8dd1d 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/ArcTangentTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/ArcTangentTest.kt @@ -2,8 +2,8 @@ package it.unibo.tuprolog.solve.stdlib.function import it.unibo.tuprolog.core.Integer import it.unibo.tuprolog.core.Real -import it.unibo.tuprolog.solve.stdlib.function.testutils.FunctionUtils.computeOf import it.unibo.tuprolog.solve.Signature +import it.unibo.tuprolog.solve.stdlib.function.testutils.FunctionUtils.computeOf import kotlin.math.PI import kotlin.test.Test import kotlin.test.assertEquals @@ -27,5 +27,4 @@ internal class ArcTangentTest { ArcTangent.computeOf(Integer.of(1)).`as`().value.toDouble() * 4 ) } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/BitwiseAndTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/BitwiseAndTest.kt index d8b2b6d91..9cbcac34e 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/BitwiseAndTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/BitwiseAndTest.kt @@ -1,9 +1,9 @@ package it.unibo.tuprolog.solve.stdlib.function import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.solve.Signature import it.unibo.tuprolog.solve.stdlib.function.testutils.FunctionUtils import it.unibo.tuprolog.solve.stdlib.function.testutils.FunctionUtils.computeOf -import it.unibo.tuprolog.solve.Signature import kotlin.test.Test import kotlin.test.assertEquals @@ -34,5 +34,4 @@ internal class BitwiseAndTest { fun rejectedInputs() { FunctionUtils.assertRejectsNonIntegerParameters(BitwiseAnd) } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/BitwiseComplementTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/BitwiseComplementTest.kt index 49d693710..cfe3c9eb0 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/BitwiseComplementTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/BitwiseComplementTest.kt @@ -1,9 +1,9 @@ package it.unibo.tuprolog.solve.stdlib.function import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.solve.Signature import it.unibo.tuprolog.solve.stdlib.function.testutils.FunctionUtils import it.unibo.tuprolog.solve.stdlib.function.testutils.FunctionUtils.computeOf -import it.unibo.tuprolog.solve.Signature import kotlin.test.Test import kotlin.test.assertEquals @@ -31,5 +31,4 @@ internal class BitwiseComplementTest { fun rejectedInputs() { FunctionUtils.assertRejectsNonIntegerParameters(BitwiseComplement) } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/BitwiseLeftShiftTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/BitwiseLeftShiftTest.kt index 47623047e..45a77e3d6 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/BitwiseLeftShiftTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/BitwiseLeftShiftTest.kt @@ -1,9 +1,9 @@ package it.unibo.tuprolog.solve.stdlib.function import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.solve.Signature import it.unibo.tuprolog.solve.stdlib.function.testutils.FunctionUtils import it.unibo.tuprolog.solve.stdlib.function.testutils.FunctionUtils.computeOf -import it.unibo.tuprolog.solve.Signature import kotlin.test.Test import kotlin.test.assertEquals @@ -34,5 +34,4 @@ internal class BitwiseLeftShiftTest { fun rejectedInputs() { FunctionUtils.assertRejectsNonIntegerParameters(BitwiseLeftShift) } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/BitwiseOrTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/BitwiseOrTest.kt index 7a9a320b2..c8840248b 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/BitwiseOrTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/BitwiseOrTest.kt @@ -1,9 +1,9 @@ package it.unibo.tuprolog.solve.stdlib.function import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.solve.Signature import it.unibo.tuprolog.solve.stdlib.function.testutils.FunctionUtils import it.unibo.tuprolog.solve.stdlib.function.testutils.FunctionUtils.computeOf -import it.unibo.tuprolog.solve.Signature import kotlin.test.Test import kotlin.test.assertEquals @@ -34,5 +34,4 @@ internal class BitwiseOrTest { fun rejectedInputs() { FunctionUtils.assertRejectsNonIntegerParameters(BitwiseOr) } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/BitwiseRightShiftTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/BitwiseRightShiftTest.kt index 072b82303..f34d470d5 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/BitwiseRightShiftTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/BitwiseRightShiftTest.kt @@ -1,9 +1,9 @@ package it.unibo.tuprolog.solve.stdlib.function import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.solve.Signature import it.unibo.tuprolog.solve.stdlib.function.testutils.FunctionUtils import it.unibo.tuprolog.solve.stdlib.function.testutils.FunctionUtils.computeOf -import it.unibo.tuprolog.solve.Signature import kotlin.test.Test import kotlin.test.assertEquals @@ -34,5 +34,4 @@ internal class BitwiseRightShiftTest { fun rejectedInputs() { FunctionUtils.assertRejectsNonIntegerParameters(BitwiseRightShift) } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/CosineTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/CosineTest.kt index 35bad78a2..73dba8450 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/CosineTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/CosineTest.kt @@ -2,8 +2,8 @@ package it.unibo.tuprolog.solve.stdlib.function import it.unibo.tuprolog.core.Numeric import it.unibo.tuprolog.core.Real -import it.unibo.tuprolog.solve.stdlib.function.testutils.FunctionUtils.computeOf import it.unibo.tuprolog.solve.Signature +import it.unibo.tuprolog.solve.stdlib.function.testutils.FunctionUtils.computeOf import kotlin.math.PI import kotlin.test.Test import kotlin.test.assertEquals @@ -28,5 +28,4 @@ internal class CosineTest { toBeTested < 6.123233995736767E-17 && toBeTested > 6.123233995736765E-17 } } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/ExponentialTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/ExponentialTest.kt index b08bb283e..b7a2bacc7 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/ExponentialTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/ExponentialTest.kt @@ -2,8 +2,8 @@ package it.unibo.tuprolog.solve.stdlib.function import it.unibo.tuprolog.core.Integer import it.unibo.tuprolog.core.Numeric -import it.unibo.tuprolog.solve.stdlib.function.testutils.FunctionUtils.computeOf import it.unibo.tuprolog.solve.Signature +import it.unibo.tuprolog.solve.stdlib.function.testutils.FunctionUtils.computeOf import kotlin.math.E import kotlin.test.Test import kotlin.test.assertEquals @@ -27,5 +27,4 @@ internal class ExponentialTest { Exponential.computeOf(Integer.of(1)) ) } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/ExponentiationTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/ExponentiationTest.kt index 625060b02..556318201 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/ExponentiationTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/ExponentiationTest.kt @@ -2,8 +2,8 @@ package it.unibo.tuprolog.solve.stdlib.function import it.unibo.tuprolog.core.Integer import it.unibo.tuprolog.core.Numeric -import it.unibo.tuprolog.solve.stdlib.function.testutils.FunctionUtils.computeOf import it.unibo.tuprolog.solve.Signature +import it.unibo.tuprolog.solve.stdlib.function.testutils.FunctionUtils.computeOf import kotlin.test.Test import kotlin.test.assertEquals @@ -29,5 +29,4 @@ internal class ExponentiationTest { ) ) } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/FloatFractionalPartTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/FloatFractionalPartTest.kt index a761060e8..d9f6a564a 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/FloatFractionalPartTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/FloatFractionalPartTest.kt @@ -2,9 +2,9 @@ package it.unibo.tuprolog.solve.stdlib.function import it.unibo.tuprolog.core.Numeric import it.unibo.tuprolog.core.Real +import it.unibo.tuprolog.solve.Signature import it.unibo.tuprolog.solve.stdlib.function.testutils.FloatFunctionUtils import it.unibo.tuprolog.solve.stdlib.function.testutils.FunctionUtils.computeOf -import it.unibo.tuprolog.solve.Signature import kotlin.test.Test import kotlin.test.assertEquals @@ -30,5 +30,4 @@ internal class FloatFractionalPartTest { ) } } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/FloatIntegerPartTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/FloatIntegerPartTest.kt index 2270f6b0a..0e0fd1df7 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/FloatIntegerPartTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/FloatIntegerPartTest.kt @@ -1,9 +1,9 @@ import it.unibo.tuprolog.core.Numeric import it.unibo.tuprolog.core.Real +import it.unibo.tuprolog.solve.Signature import it.unibo.tuprolog.solve.stdlib.function.FloatIntegerPart import it.unibo.tuprolog.solve.stdlib.function.testutils.FloatFunctionUtils import it.unibo.tuprolog.solve.stdlib.function.testutils.FunctionUtils.computeOf -import it.unibo.tuprolog.solve.Signature import kotlin.test.Test /** @@ -28,7 +28,7 @@ internal class FloatIntegerPartTest { kotlin.test.assertEquals(expected, actual) - if(loggingOn) println("".padEnd(80, '-')) + if (loggingOn) println("".padEnd(80, '-')) } } @@ -47,5 +47,4 @@ internal class FloatIntegerPartTest { ) } } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/NaturalLogarithmTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/NaturalLogarithmTest.kt index 588a0ba58..179b1584d 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/NaturalLogarithmTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/NaturalLogarithmTest.kt @@ -2,8 +2,8 @@ package it.unibo.tuprolog.solve.stdlib.function import it.unibo.tuprolog.core.Numeric import it.unibo.tuprolog.core.Real -import it.unibo.tuprolog.solve.stdlib.function.testutils.FunctionUtils.computeOf import it.unibo.tuprolog.solve.Signature +import it.unibo.tuprolog.solve.stdlib.function.testutils.FunctionUtils.computeOf import kotlin.math.E import kotlin.test.Test import kotlin.test.assertEquals @@ -27,5 +27,4 @@ internal class NaturalLogarithmTest { NaturalLogarithm.computeOf(Real.of(E)) ) } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/SineTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/SineTest.kt index de1938f8d..34791df98 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/SineTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/SineTest.kt @@ -1,8 +1,8 @@ package it.unibo.tuprolog.solve.stdlib.function import it.unibo.tuprolog.core.Numeric -import it.unibo.tuprolog.solve.stdlib.function.testutils.FunctionUtils.computeOf import it.unibo.tuprolog.solve.Signature +import it.unibo.tuprolog.solve.stdlib.function.testutils.FunctionUtils.computeOf import kotlin.math.PI import kotlin.test.Test import kotlin.test.assertEquals @@ -26,5 +26,4 @@ internal class SineTest { Sine.computeOf(Numeric.of(PI / 2.0)) ) } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/SquareRootTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/SquareRootTest.kt index 571a27a11..5d17b0a97 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/SquareRootTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/SquareRootTest.kt @@ -2,8 +2,8 @@ package it.unibo.tuprolog.solve.stdlib.function import it.unibo.tuprolog.core.Numeric import it.unibo.tuprolog.core.Real -import it.unibo.tuprolog.solve.stdlib.function.testutils.FunctionUtils.computeOf import it.unibo.tuprolog.solve.Signature +import it.unibo.tuprolog.solve.stdlib.function.testutils.FunctionUtils.computeOf import kotlin.test.Test import kotlin.test.assertEquals @@ -26,5 +26,4 @@ internal class SquareRootTest { SquareRoot.computeOf(Real.of(1.21)) ) } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/testutils/FloatFunctionUtils.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/testutils/FloatFunctionUtils.kt index 5272b6c41..4f581c74c 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/testutils/FloatFunctionUtils.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/function/testutils/FloatFunctionUtils.kt @@ -18,5 +18,4 @@ internal object FloatFunctionUtils { -2.0000000001 to (-2.0 to -0.0000000001), -1984984.02 to (-1984984.0 to -0.02) ) - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/magic/MagicCutTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/magic/MagicCutTest.kt index 5f2ca90e4..91268a582 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/magic/MagicCutTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/magic/MagicCutTest.kt @@ -43,4 +43,4 @@ class MagicCutTest { assertEquals(MagicCut, MagicCut.freshCopy(Scope.of(Var.anonymous()))) assertEquals(MagicCut, MagicCut.freshCopy(Scope.of(Var.anonymous(), Var.anonymous()))) } -} \ No newline at end of file +} diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ArithmeticEqualTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ArithmeticEqualTest.kt index 825ce1840..fd740e87e 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ArithmeticEqualTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ArithmeticEqualTest.kt @@ -1,7 +1,7 @@ package it.unibo.tuprolog.solve.stdlib.primitive -import it.unibo.tuprolog.solve.stdlib.primitive.testutils.BinaryRelationUtils.assertCorrectResponse import it.unibo.tuprolog.solve.stdlib.primitive.testutils.ArithmeticUtils.equalQueryToResult +import it.unibo.tuprolog.solve.stdlib.primitive.testutils.BinaryRelationUtils.assertCorrectResponse import kotlin.test.Test /** @@ -17,5 +17,4 @@ internal class ArithmeticEqualTest { assertCorrectResponse(ArithmeticEqual, input, result) } } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ArithmeticGreaterThanOrEqualToTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ArithmeticGreaterThanOrEqualToTest.kt index e695dff81..37b51842a 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ArithmeticGreaterThanOrEqualToTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ArithmeticGreaterThanOrEqualToTest.kt @@ -1,7 +1,7 @@ package it.unibo.tuprolog.solve.stdlib.primitive -import it.unibo.tuprolog.solve.stdlib.primitive.testutils.BinaryRelationUtils.assertCorrectResponse import it.unibo.tuprolog.solve.stdlib.primitive.testutils.ArithmeticUtils.greaterOrEqualQueryToResult +import it.unibo.tuprolog.solve.stdlib.primitive.testutils.BinaryRelationUtils.assertCorrectResponse import kotlin.test.Test /** diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ArithmeticGreaterThanTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ArithmeticGreaterThanTest.kt index 48737702c..345e4e8a2 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ArithmeticGreaterThanTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ArithmeticGreaterThanTest.kt @@ -1,7 +1,7 @@ package it.unibo.tuprolog.solve.stdlib.primitive -import it.unibo.tuprolog.solve.stdlib.primitive.testutils.BinaryRelationUtils.assertCorrectResponse import it.unibo.tuprolog.solve.stdlib.primitive.testutils.ArithmeticUtils.greaterQueryToResult +import it.unibo.tuprolog.solve.stdlib.primitive.testutils.BinaryRelationUtils.assertCorrectResponse import kotlin.test.Test /** @@ -17,5 +17,4 @@ internal class ArithmeticGreaterThanTest { assertCorrectResponse(ArithmeticGreaterThan, input, result) } } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ArithmeticLowerThanOrEqualToTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ArithmeticLowerThanOrEqualToTest.kt index 5b32998bd..3df569c5c 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ArithmeticLowerThanOrEqualToTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ArithmeticLowerThanOrEqualToTest.kt @@ -1,7 +1,7 @@ package it.unibo.tuprolog.solve.stdlib.primitive -import it.unibo.tuprolog.solve.stdlib.primitive.testutils.BinaryRelationUtils.assertCorrectResponse import it.unibo.tuprolog.solve.stdlib.primitive.testutils.ArithmeticUtils.lowerOrEqualQueryToResult +import it.unibo.tuprolog.solve.stdlib.primitive.testutils.BinaryRelationUtils.assertCorrectResponse import kotlin.test.Test /** diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ArithmeticLowerThanTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ArithmeticLowerThanTest.kt index ee2ca8fc5..665f101af 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ArithmeticLowerThanTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ArithmeticLowerThanTest.kt @@ -1,7 +1,7 @@ package it.unibo.tuprolog.solve.stdlib.primitive -import it.unibo.tuprolog.solve.stdlib.primitive.testutils.BinaryRelationUtils.assertCorrectResponse import it.unibo.tuprolog.solve.stdlib.primitive.testutils.ArithmeticUtils.lowerQueryToResult +import it.unibo.tuprolog.solve.stdlib.primitive.testutils.BinaryRelationUtils.assertCorrectResponse import kotlin.test.Test /** @@ -17,5 +17,4 @@ internal class ArithmeticLowerThanTest { assertCorrectResponse(ArithmeticLowerThan, input, result) } } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ArithmeticNotEqualTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ArithmeticNotEqualTest.kt index 3bdc3138d..bd236f6a4 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ArithmeticNotEqualTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ArithmeticNotEqualTest.kt @@ -1,7 +1,7 @@ package it.unibo.tuprolog.solve.stdlib.primitive -import it.unibo.tuprolog.solve.stdlib.primitive.testutils.BinaryRelationUtils.assertCorrectResponse import it.unibo.tuprolog.solve.stdlib.primitive.testutils.ArithmeticUtils.notEqualQueryToResult +import it.unibo.tuprolog.solve.stdlib.primitive.testutils.BinaryRelationUtils.assertCorrectResponse import kotlin.test.Test /** @@ -17,5 +17,4 @@ internal class ArithmeticNotEqualTest { assertCorrectResponse(ArithmeticNotEqual, input, result) } } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/HaltTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/HaltTest.kt index 4b6f4cb3b..a8b56181c 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/HaltTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/HaltTest.kt @@ -1,10 +1,10 @@ package it.unibo.tuprolog.solve.stdlib.primitive import it.unibo.tuprolog.core.Atom -import it.unibo.tuprolog.solve.stdlib.primitive.testutils.PrimitiveUtils.createSolveRequest import it.unibo.tuprolog.solve.assertOverFailure import it.unibo.tuprolog.solve.exception.HaltException import it.unibo.tuprolog.solve.exception.TuPrologRuntimeException +import it.unibo.tuprolog.solve.stdlib.primitive.testutils.PrimitiveUtils.createSolveRequest import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/IsTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/IsTest.kt index 3d68c0e58..868333123 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/IsTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/IsTest.kt @@ -1,11 +1,14 @@ package it.unibo.tuprolog.solve.stdlib.primitive import it.unibo.tuprolog.core.Substitution -import it.unibo.tuprolog.solve.stdlib.primitive.testutils.ArithmeticUtils.isQueryToResult import it.unibo.tuprolog.solve.Solution import it.unibo.tuprolog.solve.exception.TuPrologRuntimeException +import it.unibo.tuprolog.solve.stdlib.primitive.testutils.ArithmeticUtils.isQueryToResult import kotlin.reflect.KClass -import kotlin.test.* +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertTrue +import kotlin.test.fail /** * Test class for [Is] @@ -33,14 +36,14 @@ internal class IsTest { } } } - else -> try { - Is.wrappedImplementation(input) - fail("Expected: $expectedResult but no exception was thrown") - } catch (e: TuPrologRuntimeException) { - assertEquals(expectedResult as KClass<*>, e::class) - } + else -> + try { + Is.wrappedImplementation(input) + fail("Expected: $expectedResult but no exception was thrown") + } catch (e: TuPrologRuntimeException) { + assertEquals(expectedResult as KClass<*>, e::class) + } } } } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/StandardGreaterThanOrEqualTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/StandardGreaterThanOrEqualTest.kt index 7461aabb3..99a8a0033 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/StandardGreaterThanOrEqualTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/StandardGreaterThanOrEqualTest.kt @@ -10,4 +10,4 @@ internal class StandardGreaterThanOrEqualTest { TermOrderingUtils.assertCorrectResponse(TermGreaterThanOrEqualTo, input, result) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/StandardGreaterThanTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/StandardGreaterThanTest.kt index 000bb3875..0c8b7094a 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/StandardGreaterThanTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/StandardGreaterThanTest.kt @@ -9,4 +9,4 @@ internal class StandardGreaterThanTest { TermOrderingUtils.assertCorrectResponse(TermGreaterThan, input, result) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/StandardLowerThanOrEqualTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/StandardLowerThanOrEqualTest.kt index 96e6d4f21..8d7468fac 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/StandardLowerThanOrEqualTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/StandardLowerThanOrEqualTest.kt @@ -10,4 +10,4 @@ class StandardLowerThanOrEqualTest { TermOrderingUtils.assertCorrectResponse(TermLowerThanOrEqualTo, input, result) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/StandardLowerThanTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/StandardLowerThanTest.kt index 8326c7809..f75725e05 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/StandardLowerThanTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/StandardLowerThanTest.kt @@ -10,4 +10,4 @@ internal class StandardLowerThanTest { TermOrderingUtils.assertCorrectResponse(TermLowerThan, input, result) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/StandardNotEqualTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/StandardNotEqualTest.kt index e996b968e..c11524131 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/StandardNotEqualTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/StandardNotEqualTest.kt @@ -11,4 +11,4 @@ internal class StandardNotEqualTest { TermOrderingUtils.assertCorrectResponse(TermNotSame, input, result) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/StandardOrderEqualTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/StandardOrderEqualTest.kt index f2425d735..3dbdbf21e 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/StandardOrderEqualTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/StandardOrderEqualTest.kt @@ -11,4 +11,4 @@ internal class StandardOrderEqualTest { TermOrderingUtils.assertCorrectResponse(TermSame, input, result) } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermGreaterThanTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermGreaterThanTest.kt index cdfe9f670..57c0e8c9e 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermGreaterThanTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermGreaterThanTest.kt @@ -16,5 +16,4 @@ internal class TermGreaterThanTest { assertCorrectResponse(TermGreaterThan, input, result) } } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermIdenticalTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermIdenticalTest.kt index 2af169a6d..1ab108619 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermIdenticalTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermIdenticalTest.kt @@ -16,5 +16,4 @@ internal class TermIdenticalTest { assertCorrectResponse(TermIdentical, input, result) } } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermLowerThanTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermLowerThanTest.kt index 6886ef051..310baf1c3 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermLowerThanTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermLowerThanTest.kt @@ -16,5 +16,4 @@ internal class TermLowerThanTest { assertCorrectResponse(TermLowerThan, input, result) } } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermNotIdenticalTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermNotIdenticalTest.kt index ec81fe602..90a5d9af5 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermNotIdenticalTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TermNotIdenticalTest.kt @@ -16,5 +16,4 @@ internal class TermNotIdenticalTest { assertCorrectResponse(TermNotIdentical, input, result) } } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TypeTestingPrimitivesTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TypeTestingPrimitivesTest.kt index 17b0ea04c..208ca5bd1 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TypeTestingPrimitivesTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/TypeTestingPrimitivesTest.kt @@ -21,7 +21,6 @@ import it.unibo.tuprolog.solve.stdlib.primitive.Integer as IntegerPrimitive import it.unibo.tuprolog.solve.stdlib.primitive.Number as NumberTerm import it.unibo.tuprolog.solve.stdlib.primitive.Var as VarPrimitive - /** * Tests for primitives * [AtomPrimitive], @@ -98,5 +97,4 @@ internal class TypeTestingPrimitivesTest { fun nonVarTypeTestingWorksCorrectly() { assertTypeTestingWorks(NonVar, nonVarQueryToResult) } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/ArithmeticUtils.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/ArithmeticUtils.kt index 638b55a55..86ecf35ec 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/ArithmeticUtils.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/ArithmeticUtils.kt @@ -4,7 +4,13 @@ import it.unibo.tuprolog.core.Substitution import it.unibo.tuprolog.dsl.prolog import it.unibo.tuprolog.solve.exception.error.EvaluationError import it.unibo.tuprolog.solve.exception.error.InstantiationError -import it.unibo.tuprolog.solve.stdlib.primitive.* +import it.unibo.tuprolog.solve.stdlib.primitive.ArithmeticEqual +import it.unibo.tuprolog.solve.stdlib.primitive.ArithmeticGreaterThan +import it.unibo.tuprolog.solve.stdlib.primitive.ArithmeticGreaterThanOrEqualTo +import it.unibo.tuprolog.solve.stdlib.primitive.ArithmeticLowerThan +import it.unibo.tuprolog.solve.stdlib.primitive.ArithmeticLowerThanOrEqualTo +import it.unibo.tuprolog.solve.stdlib.primitive.ArithmeticNotEqual +import it.unibo.tuprolog.solve.stdlib.primitive.Is import it.unibo.tuprolog.solve.stdlib.primitive.testutils.PrimitiveUtils.createSolveRequest /** @@ -109,5 +115,4 @@ internal object ArithmeticUtils { ).mapKeys { (query, _) -> createSolveRequest(query) } } } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/BinaryRelationUtils.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/BinaryRelationUtils.kt index 43ae995d4..20e8333b4 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/BinaryRelationUtils.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/BinaryRelationUtils.kt @@ -2,9 +2,9 @@ package it.unibo.tuprolog.solve.stdlib.primitive.testutils import it.unibo.tuprolog.solve.ExecutionContext import it.unibo.tuprolog.solve.Solution -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.exception.TuPrologRuntimeException import it.unibo.tuprolog.solve.primitive.BinaryRelation +import it.unibo.tuprolog.solve.primitive.Solve import kotlin.reflect.KClass import kotlin.test.assertFailsWith import kotlin.test.assertTrue @@ -31,4 +31,4 @@ object BinaryRelationUtils { ?.let { assertFailsWith(expectedResult) { termRelation.wrappedImplementation(input) } } ?: fail("Bad written test data!") } -} \ No newline at end of file +} diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/PrimitiveUtils.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/PrimitiveUtils.kt index 879fea8fd..5d1fd4039 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/PrimitiveUtils.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/PrimitiveUtils.kt @@ -3,9 +3,9 @@ package it.unibo.tuprolog.solve.stdlib.primitive.testutils import it.unibo.tuprolog.core.Struct import it.unibo.tuprolog.solve.DummyInstances import it.unibo.tuprolog.solve.ExecutionContext -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.extractSignature import it.unibo.tuprolog.solve.library.Libraries +import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.stdlib.CommonBuiltins import it.unibo.tuprolog.theory.Theory @@ -31,5 +31,4 @@ internal object PrimitiveUtils { query.argsList, contextWith(database) ) - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/TermOrderingUtils.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/TermOrderingUtils.kt index a8748ee85..18ff662c0 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/TermOrderingUtils.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/TermOrderingUtils.kt @@ -6,7 +6,12 @@ import it.unibo.tuprolog.solve.Solution import it.unibo.tuprolog.solve.exception.TuPrologRuntimeException import it.unibo.tuprolog.solve.primitive.BinaryRelation import it.unibo.tuprolog.solve.primitive.Solve -import it.unibo.tuprolog.solve.stdlib.primitive.* +import it.unibo.tuprolog.solve.stdlib.primitive.TermGreaterThan +import it.unibo.tuprolog.solve.stdlib.primitive.TermGreaterThanOrEqualTo +import it.unibo.tuprolog.solve.stdlib.primitive.TermLowerThan +import it.unibo.tuprolog.solve.stdlib.primitive.TermLowerThanOrEqualTo +import it.unibo.tuprolog.solve.stdlib.primitive.TermNotSame +import it.unibo.tuprolog.solve.stdlib.primitive.TermSame import kotlin.reflect.KClass import kotlin.test.assertFailsWith import kotlin.test.assertTrue @@ -102,4 +107,4 @@ internal object TermOrderingUtils { ).mapKeys { (query, _) -> PrimitiveUtils.createSolveRequest(query) } } } -} \ No newline at end of file +} diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/TermUtils.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/TermUtils.kt index 647d8a72f..45a37f23d 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/TermUtils.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/TermUtils.kt @@ -1,7 +1,12 @@ package it.unibo.tuprolog.solve.stdlib.primitive.testutils import it.unibo.tuprolog.dsl.prolog -import it.unibo.tuprolog.solve.stdlib.primitive.* +import it.unibo.tuprolog.solve.stdlib.primitive.TermGreaterThan +import it.unibo.tuprolog.solve.stdlib.primitive.TermGreaterThanOrEqualTo +import it.unibo.tuprolog.solve.stdlib.primitive.TermIdentical +import it.unibo.tuprolog.solve.stdlib.primitive.TermLowerThan +import it.unibo.tuprolog.solve.stdlib.primitive.TermLowerThanOrEqualTo +import it.unibo.tuprolog.solve.stdlib.primitive.TermNotIdentical import it.unibo.tuprolog.solve.stdlib.primitive.testutils.PrimitiveUtils.createSolveRequest /** @@ -13,10 +18,14 @@ internal object TermUtils { internal val equalQueryToResult by lazy { prolog { mapOf( - TermIdentical.functor(structOf("a", atomOf("c")), - structOf("a", atomOf("c"))) to true, - TermIdentical.functor(structOf("a", atomOf("c")), - structOf("a", atomOf("x"))) to false, + TermIdentical.functor( + structOf("a", atomOf("c")), + structOf("a", atomOf("c")) + ) to true, + TermIdentical.functor( + structOf("a", atomOf("c")), + structOf("a", atomOf("x")) + ) to false, TermIdentical.functor(varOf("X"), varOf("X")) to true, TermIdentical.functor(varOf("X"), varOf("Y")) to false ).mapKeys { (query, _) -> createSolveRequest(query) } @@ -27,10 +36,14 @@ internal object TermUtils { internal val notEqualQueryToResult by lazy { prolog { mapOf( - TermNotIdentical.functor(structOf("a", atomOf("c")), - structOf("a", atomOf("c"))) to false, - TermNotIdentical.functor(structOf("a", atomOf("c")), - structOf("a", atomOf("x"))) to true, + TermNotIdentical.functor( + structOf("a", atomOf("c")), + structOf("a", atomOf("c")) + ) to false, + TermNotIdentical.functor( + structOf("a", atomOf("c")), + structOf("a", atomOf("x")) + ) to true, TermNotIdentical.functor(varOf("X"), varOf("X")) to false, TermNotIdentical.functor(varOf("X"), varOf("Y")) to true ).mapKeys { (query, _) -> createSolveRequest(query) } @@ -41,12 +54,18 @@ internal object TermUtils { internal val greaterQueryToResult by lazy { prolog { mapOf( - TermGreaterThan.functor(structOf("a", atomOf("a")), - structOf("a", atomOf("a"))) to false, - TermGreaterThan.functor(structOf("a", atomOf("a")), - structOf("a", atomOf("b"))) to false, - TermGreaterThan.functor(structOf("a", atomOf("b")), - structOf("a", atomOf("a"))) to true, + TermGreaterThan.functor( + structOf("a", atomOf("a")), + structOf("a", atomOf("a")) + ) to false, + TermGreaterThan.functor( + structOf("a", atomOf("a")), + structOf("a", atomOf("b")) + ) to false, + TermGreaterThan.functor( + structOf("a", atomOf("b")), + structOf("a", atomOf("a")) + ) to true, TermGreaterThan.functor(varOf("X"), varOf("X")) to false, TermGreaterThan.functor(atomOf("a"), varOf("Y")) to true, TermGreaterThan.functor(varOf("Y"), atomOf("a")) to false @@ -58,12 +77,18 @@ internal object TermUtils { internal val greaterOrEqualQueryToResult by lazy { prolog { mapOf( - TermGreaterThanOrEqualTo.functor(structOf("a", atomOf("a")), - structOf("a", atomOf("a"))) to true, - TermGreaterThanOrEqualTo.functor(structOf("a", atomOf("a")), - structOf("a", atomOf("b"))) to false, - TermGreaterThanOrEqualTo.functor(structOf("a", atomOf("b")), - structOf("a", atomOf("a"))) to true, + TermGreaterThanOrEqualTo.functor( + structOf("a", atomOf("a")), + structOf("a", atomOf("a")) + ) to true, + TermGreaterThanOrEqualTo.functor( + structOf("a", atomOf("a")), + structOf("a", atomOf("b")) + ) to false, + TermGreaterThanOrEqualTo.functor( + structOf("a", atomOf("b")), + structOf("a", atomOf("a")) + ) to true, TermGreaterThanOrEqualTo.functor(varOf("X"), varOf("X")) to true, TermGreaterThanOrEqualTo.functor(atomOf("a"), varOf("Y")) to true, TermGreaterThanOrEqualTo.functor(varOf("Y"), atomOf("a")) to false @@ -75,12 +100,18 @@ internal object TermUtils { internal val lowerQueryToResult by lazy { prolog { mapOf( - TermLowerThan.functor(structOf("a", atomOf("a")), - structOf("a", atomOf("a"))) to false, - TermLowerThan.functor(structOf("a", atomOf("a")), - structOf("a", atomOf("b"))) to true, - TermLowerThan.functor(structOf("a", atomOf("b")), - structOf("a", atomOf("a"))) to false, + TermLowerThan.functor( + structOf("a", atomOf("a")), + structOf("a", atomOf("a")) + ) to false, + TermLowerThan.functor( + structOf("a", atomOf("a")), + structOf("a", atomOf("b")) + ) to true, + TermLowerThan.functor( + structOf("a", atomOf("b")), + structOf("a", atomOf("a")) + ) to false, TermLowerThan.functor(varOf("X"), varOf("X")) to false, TermLowerThan.functor(atomOf("a"), varOf("Y")) to false, TermLowerThan.functor(varOf("Y"), atomOf("a")) to true @@ -92,17 +123,22 @@ internal object TermUtils { internal val lowerOrEqualQueryToResult by lazy { prolog { mapOf( - TermLowerThanOrEqualTo.functor(structOf("a", atomOf("a")), - structOf("a", atomOf("a"))) to true, - TermLowerThanOrEqualTo.functor(structOf("a", atomOf("a")), - structOf("a", atomOf("b"))) to true, - TermLowerThanOrEqualTo.functor(structOf("a", atomOf("b")), - structOf("a", atomOf("a"))) to false, + TermLowerThanOrEqualTo.functor( + structOf("a", atomOf("a")), + structOf("a", atomOf("a")) + ) to true, + TermLowerThanOrEqualTo.functor( + structOf("a", atomOf("a")), + structOf("a", atomOf("b")) + ) to true, + TermLowerThanOrEqualTo.functor( + structOf("a", atomOf("b")), + structOf("a", atomOf("a")) + ) to false, TermLowerThanOrEqualTo.functor(varOf("X"), varOf("X")) to true, TermLowerThanOrEqualTo.functor(atomOf("a"), varOf("Y")) to false, TermLowerThanOrEqualTo.functor(varOf("Y"), atomOf("a")) to true ).mapKeys { (query, _) -> createSolveRequest(query) } } } - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/TypeTestingUtils.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/TypeTestingUtils.kt index 1f0386406..597112639 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/TypeTestingUtils.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/TypeTestingUtils.kt @@ -1,18 +1,29 @@ package it.unibo.tuprolog.solve.stdlib.primitive.testutils -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom import it.unibo.tuprolog.core.Clause +import it.unibo.tuprolog.core.Constant +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Numeric +import it.unibo.tuprolog.core.Real +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.dsl.PrologScope import it.unibo.tuprolog.dsl.prolog import it.unibo.tuprolog.solve.Solution -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.exception.TuPrologRuntimeException import it.unibo.tuprolog.solve.exception.error.InstantiationError import it.unibo.tuprolog.solve.exception.error.TypeError +import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.primitive.UnaryPredicate -import it.unibo.tuprolog.solve.stdlib.primitive.* +import it.unibo.tuprolog.solve.stdlib.primitive.Atomic +import it.unibo.tuprolog.solve.stdlib.primitive.Callable +import it.unibo.tuprolog.solve.stdlib.primitive.Compound +import it.unibo.tuprolog.solve.stdlib.primitive.EnsureExecutable +import it.unibo.tuprolog.solve.stdlib.primitive.Ground +import it.unibo.tuprolog.solve.stdlib.primitive.NonVar import it.unibo.tuprolog.utils.squared -import kotlin.collections.List import kotlin.reflect.KClass import kotlin.test.assertFailsWith import kotlin.test.assertTrue @@ -63,9 +74,9 @@ object TypeTestingUtils { private val commonArgs: List = PrologScope.empty().let { baseArgs + - baseArgs.squared { x, y -> it.tupleOf(x, y) } + - baseArgs.squared { x, y -> it.structOf(";", x, y) } + - baseArgs.squared { x, y -> it.structOf("->", x, y) } + baseArgs.squared { x, y -> it.tupleOf(x, y) } + + baseArgs.squared { x, y -> it.structOf(";", x, y) } + + baseArgs.squared { x, y -> it.structOf("->", x, y) } }.toList() private inline fun typeTest( @@ -169,4 +180,4 @@ object TypeTestingUtils { } } ?: fail("Bad written test data!") } -} \ No newline at end of file +} diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/testutils/SolutionUtils.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/testutils/SolutionUtils.kt index 1005fb538..58e79a433 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/testutils/SolutionUtils.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/testutils/SolutionUtils.kt @@ -3,10 +3,10 @@ package it.unibo.tuprolog.solve.testutils import it.unibo.tuprolog.core.Scope import it.unibo.tuprolog.core.Struct import it.unibo.tuprolog.core.Substitution -import it.unibo.tuprolog.solve.extractSignature import it.unibo.tuprolog.solve.DummyInstances import it.unibo.tuprolog.solve.Solution import it.unibo.tuprolog.solve.exception.TuPrologRuntimeException +import it.unibo.tuprolog.solve.extractSignature /** * Utils singleton to help testing [Solution] @@ -22,5 +22,4 @@ internal object SolutionUtils { internal val aSubstitution = with(solutionScope) { Substitution.of(varOf("A"), Struct.of("c", varOf("B"))) } internal val theQuerySolved = with(solutionScope) { Struct.of("f", Struct.of("c", varOf("B"))) } internal val anException = TuPrologRuntimeException(context = DummyInstances.executionContext) - } diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/testutils/SolveUtils.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/testutils/SolveUtils.kt index 0096c575a..823f6126c 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/testutils/SolveUtils.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/testutils/SolveUtils.kt @@ -1,7 +1,18 @@ package it.unibo.tuprolog.solve.testutils -import it.unibo.tuprolog.core.* -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Fact +import it.unibo.tuprolog.core.Substitution +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.Truth +import it.unibo.tuprolog.solve.DummyInstances +import it.unibo.tuprolog.solve.ExecutionContext +import it.unibo.tuprolog.solve.SideEffect +import it.unibo.tuprolog.solve.SideEffectManager +import it.unibo.tuprolog.solve.Signature +import it.unibo.tuprolog.solve.Solution +import it.unibo.tuprolog.solve.TimeDuration +import it.unibo.tuprolog.solve.TimeInstant import it.unibo.tuprolog.solve.exception.TuPrologRuntimeException import it.unibo.tuprolog.solve.library.Libraries import it.unibo.tuprolog.solve.library.Library @@ -104,5 +115,4 @@ internal object SolveUtils { requestIssuingInstant: TimeInstant = aRequestIssuingInstant, executionMaxDuration: TimeDuration = anExecutionMaxDuration ) = Solve.Request(signature, arguments, executionContext, requestIssuingInstant, executionMaxDuration) - } diff --git a/test-solve/src/jsMain/kotlin/it/unibo/tuprolog/solve/TestUtils.kt b/test-solve/src/jsMain/kotlin/it/unibo/tuprolog/solve/TestUtils.kt index 97daf6b23..b25ef8a3b 100644 --- a/test-solve/src/jsMain/kotlin/it/unibo/tuprolog/solve/TestUtils.kt +++ b/test-solve/src/jsMain/kotlin/it/unibo/tuprolog/solve/TestUtils.kt @@ -6,4 +6,4 @@ actual fun internalsOf(x: () -> Any): String { actual fun log(x: () -> Any) { console.log(x()) -} \ No newline at end of file +} diff --git a/test-solve/src/jsTest/kotlin/it/unibo/tuprolog/solve/CurrentTimeInstantKtJsTest.kt b/test-solve/src/jsTest/kotlin/it/unibo/tuprolog/solve/CurrentTimeInstantKtJsTest.kt index c80ebf8b3..ef599f078 100644 --- a/test-solve/src/jsTest/kotlin/it/unibo/tuprolog/solve/CurrentTimeInstantKtJsTest.kt +++ b/test-solve/src/jsTest/kotlin/it/unibo/tuprolog/solve/CurrentTimeInstantKtJsTest.kt @@ -22,5 +22,4 @@ internal class CurrentTimeInstantKtJsTest { our - official < TOLERANCE } } - } diff --git a/test-solve/src/jvmMain/kotlin/it/unibo/tuprolog/solve/TestUtils.kt b/test-solve/src/jvmMain/kotlin/it/unibo/tuprolog/solve/TestUtils.kt index 4768c92cf..cbc3080a3 100644 --- a/test-solve/src/jvmMain/kotlin/it/unibo/tuprolog/solve/TestUtils.kt +++ b/test-solve/src/jvmMain/kotlin/it/unibo/tuprolog/solve/TestUtils.kt @@ -6,4 +6,4 @@ actual fun internalsOf(x: () -> Any): String { actual fun log(x: () -> Any) { System.err.println(x()) -} \ No newline at end of file +} From abf1c7ab65a3ab4682bbcbc472fdf33fb16f7ac7 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 14 Sep 2020 15:29:26 +0200 Subject: [PATCH 13/34] format code in :dsl-core --- dsl-core/build.gradle.kts | 20 ------------------- .../unibo/tuprolog/dsl/AnyToTermConverter.kt | 14 ++++++++----- .../tuprolog/dsl/AnyToTermConverterImpl.kt | 2 +- .../it/unibo/tuprolog/dsl/PrologAwareScope.kt | 2 +- .../it/unibo/tuprolog/dsl/PrologExtensions.kt | 3 ++- .../it/unibo/tuprolog/dsl/PrologScope.kt | 15 +++++++++++--- .../it/unibo/tuprolog/dsl/PrologScopeImpl.kt | 4 ++-- .../unibo/tuprolog/dsl/PrologStdLibScope.kt | 2 +- .../unibo/tuprolog/dsl/VariablesAwareScope.kt | 2 +- .../tuprolog/dsl/PlatformSpecificValues.kt | 2 +- .../it/unibo/tuprolog/dsl/TestProlog.kt | 9 +++++++-- .../tuprolog/dsl/AnyToTermConverterImpl.kt | 2 +- .../tuprolog/dsl/PlatformSpecificValues.kt | 2 +- .../tuprolog/dsl/AnyToTermConverterImpl.kt | 2 +- .../tuprolog/dsl/PlatformSpecificValues.kt | 2 +- 15 files changed, 41 insertions(+), 42 deletions(-) diff --git a/dsl-core/build.gradle.kts b/dsl-core/build.gradle.kts index daf8cfd7c..9c10f82d3 100644 --- a/dsl-core/build.gradle.kts +++ b/dsl-core/build.gradle.kts @@ -1,29 +1,9 @@ -// Project specific kotlin multiplatform configuration kotlin { - sourceSets { val commonMain by getting { dependencies { -// api("com.github.gciatto:kt-math-metadata:0.+") api(project(":core")) } } - - // Default source set for JVM-specific sources and dependencies: - jvm { - compilations["main"].defaultSourceSet { - dependencies { -// api(project(":core")) - } - } - } - - js { - compilations["main"].defaultSourceSet { - dependencies { -// api(project(":core")) - } - } - } } } diff --git a/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/AnyToTermConverter.kt b/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/AnyToTermConverter.kt index 1ac4dc365..c0b88a1da 100644 --- a/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/AnyToTermConverter.kt +++ b/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/AnyToTermConverter.kt @@ -1,13 +1,17 @@ package it.unibo.tuprolog.dsl -import it.unibo.tuprolog.core.* -import kotlin.js.JsName +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Real +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.ToTermConvertible +import it.unibo.tuprolog.core.Truth +import it.unibo.tuprolog.core.Var import org.gciatto.kt.math.BigDecimal import org.gciatto.kt.math.BigInteger - +import kotlin.js.JsName import it.unibo.tuprolog.core.toTerm as extToTerm - internal interface AnyToTermConverter { @JsName("prologScope") @@ -60,4 +64,4 @@ internal interface AnyToTermConverter { return AnyToTermConverterImpl(prologScope) } } -} \ No newline at end of file +} diff --git a/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/AnyToTermConverterImpl.kt b/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/AnyToTermConverterImpl.kt index e0623e8f1..22cc297c6 100644 --- a/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/AnyToTermConverterImpl.kt +++ b/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/AnyToTermConverterImpl.kt @@ -1,3 +1,3 @@ package it.unibo.tuprolog.dsl -expect class AnyToTermConverterImpl(prologScope: PrologScope) : AnyToTermConverter \ No newline at end of file +expect class AnyToTermConverterImpl(prologScope: PrologScope) : AnyToTermConverter diff --git a/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/PrologAwareScope.kt b/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/PrologAwareScope.kt index 80027b2e2..6520593c5 100644 --- a/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/PrologAwareScope.kt +++ b/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/PrologAwareScope.kt @@ -8,4 +8,4 @@ interface PrologAwareScope : Scope { @JsName("anyToTerm") fun Any.toTerm(): Term -} \ No newline at end of file +} diff --git a/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/PrologExtensions.kt b/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/PrologExtensions.kt index cc408676f..5dcdf45cc 100644 --- a/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/PrologExtensions.kt +++ b/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/PrologExtensions.kt @@ -1,4 +1,5 @@ @file:JvmName("PrologExtensions") + package it.unibo.tuprolog.dsl import kotlin.js.JsName @@ -10,4 +11,4 @@ fun prolog(function: PrologScope.() -> R): R = PrologScope.empty().function( /** Utility method to launch conversion failed errors */ internal fun Any.raiseErrorConvertingTo(`class`: KClass<*>): Nothing = - throw IllegalArgumentException("Cannot convert ${this::class} into $`class`") \ No newline at end of file + throw IllegalArgumentException("Cannot convert ${this::class} into $`class`") diff --git a/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/PrologScope.kt b/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/PrologScope.kt index 82d286430..7a8a065d0 100644 --- a/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/PrologScope.kt +++ b/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/PrologScope.kt @@ -1,6 +1,16 @@ package it.unibo.tuprolog.dsl -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Clause +import it.unibo.tuprolog.core.Cons +import it.unibo.tuprolog.core.Directive +import it.unibo.tuprolog.core.Fact +import it.unibo.tuprolog.core.Indicator +import it.unibo.tuprolog.core.Rule +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Substitution +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.Tuple +import it.unibo.tuprolog.core.Var import kotlin.js.JsName import it.unibo.tuprolog.core.List as LogicList import it.unibo.tuprolog.core.Set as LogicSet @@ -187,9 +197,8 @@ interface PrologScope : PrologStdLibScope, VariablesAwareScope { fun Substitution.containsValue(term: Any): Boolean = this.containsValue(term.toTerm()) - companion object { @JsName("empty") fun empty(): PrologScope = PrologScopeImpl() } -} \ No newline at end of file +} diff --git a/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/PrologScopeImpl.kt b/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/PrologScopeImpl.kt index 81c6dced2..80ea9c89d 100644 --- a/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/PrologScopeImpl.kt +++ b/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/PrologScopeImpl.kt @@ -5,8 +5,8 @@ import it.unibo.tuprolog.core.Term internal class PrologScopeImpl : PrologScope, Scope by Scope.empty() { - private val anyToTermConverter = AnyToTermConverter.of(this); + private val anyToTermConverter = AnyToTermConverter.of(this) override fun Any.toTerm(): Term = anyToTermConverter.toTerm(this) -} \ No newline at end of file +} diff --git a/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/PrologStdLibScope.kt b/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/PrologStdLibScope.kt index ea19ec3a8..178375f80 100644 --- a/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/PrologStdLibScope.kt +++ b/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/PrologStdLibScope.kt @@ -228,4 +228,4 @@ interface PrologStdLibScope : PrologAwareScope { // write_term/3 // writeq/1 // writeq/2 -} \ No newline at end of file +} diff --git a/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/VariablesAwareScope.kt b/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/VariablesAwareScope.kt index 1666db2db..6d369acd2 100644 --- a/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/VariablesAwareScope.kt +++ b/dsl-core/src/commonMain/kotlin/it/unibo/tuprolog/dsl/VariablesAwareScope.kt @@ -30,4 +30,4 @@ interface VariablesAwareScope : PrologAwareScope { val X: Var get() = varOf("X") val Y: Var get() = varOf("Y") val Z: Var get() = varOf("Z") -} \ No newline at end of file +} diff --git a/dsl-core/src/commonTest/kotlin/it/unibo/tuprolog/dsl/PlatformSpecificValues.kt b/dsl-core/src/commonTest/kotlin/it/unibo/tuprolog/dsl/PlatformSpecificValues.kt index ca30a7f46..2698baf61 100644 --- a/dsl-core/src/commonTest/kotlin/it/unibo/tuprolog/dsl/PlatformSpecificValues.kt +++ b/dsl-core/src/commonTest/kotlin/it/unibo/tuprolog/dsl/PlatformSpecificValues.kt @@ -6,4 +6,4 @@ expect object PlatformSpecificValues { val THREE_POINT_ONE_FLOAT: Numeric val ONE_POINT_ZERO: Numeric val MINUS_THREE: Numeric -} \ No newline at end of file +} diff --git a/dsl-core/src/commonTest/kotlin/it/unibo/tuprolog/dsl/TestProlog.kt b/dsl-core/src/commonTest/kotlin/it/unibo/tuprolog/dsl/TestProlog.kt index da175abfb..940a48f40 100644 --- a/dsl-core/src/commonTest/kotlin/it/unibo/tuprolog/dsl/TestProlog.kt +++ b/dsl-core/src/commonTest/kotlin/it/unibo/tuprolog/dsl/TestProlog.kt @@ -1,8 +1,13 @@ package it.unibo.tuprolog.dsl -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Cons +import it.unibo.tuprolog.core.Integer import it.unibo.tuprolog.core.List +import it.unibo.tuprolog.core.Real import it.unibo.tuprolog.core.Set +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.Tuple import it.unibo.tuprolog.dsl.PlatformSpecificValues.MINUS_THREE import it.unibo.tuprolog.dsl.PlatformSpecificValues.ONE_POINT_ZERO import it.unibo.tuprolog.dsl.PlatformSpecificValues.THREE_POINT_ONE_FLOAT @@ -120,4 +125,4 @@ class TestProlog { tupleOf("a", "b") } } -} \ No newline at end of file +} diff --git a/dsl-core/src/jsMain/kotlin/it/unibo/tuprolog/dsl/AnyToTermConverterImpl.kt b/dsl-core/src/jsMain/kotlin/it/unibo/tuprolog/dsl/AnyToTermConverterImpl.kt index d2f449aaf..1d57bd734 100644 --- a/dsl-core/src/jsMain/kotlin/it/unibo/tuprolog/dsl/AnyToTermConverterImpl.kt +++ b/dsl-core/src/jsMain/kotlin/it/unibo/tuprolog/dsl/AnyToTermConverterImpl.kt @@ -24,4 +24,4 @@ actual class AnyToTermConverterImpl actual constructor(override val prologScope: override fun Number.toReal(): Real { return Real.of(numberCache) } -} \ No newline at end of file +} diff --git a/dsl-core/src/jsTest/kotlin/it/unibo/tuprolog/dsl/PlatformSpecificValues.kt b/dsl-core/src/jsTest/kotlin/it/unibo/tuprolog/dsl/PlatformSpecificValues.kt index 79cfbc932..bddd8b4ff 100644 --- a/dsl-core/src/jsTest/kotlin/it/unibo/tuprolog/dsl/PlatformSpecificValues.kt +++ b/dsl-core/src/jsTest/kotlin/it/unibo/tuprolog/dsl/PlatformSpecificValues.kt @@ -10,4 +10,4 @@ actual object PlatformSpecificValues { actual val ONE_POINT_ZERO: Numeric = Integer.of(1) actual val MINUS_THREE: Numeric = Real.of("-3.0") -} \ No newline at end of file +} diff --git a/dsl-core/src/jvmMain/kotlin/it/unibo/tuprolog/dsl/AnyToTermConverterImpl.kt b/dsl-core/src/jvmMain/kotlin/it/unibo/tuprolog/dsl/AnyToTermConverterImpl.kt index 2abc8ef33..c60202e1b 100644 --- a/dsl-core/src/jvmMain/kotlin/it/unibo/tuprolog/dsl/AnyToTermConverterImpl.kt +++ b/dsl-core/src/jvmMain/kotlin/it/unibo/tuprolog/dsl/AnyToTermConverterImpl.kt @@ -14,4 +14,4 @@ actual class AnyToTermConverterImpl actual constructor(override val prologScope: override fun Number.toReal(): Real { return Real.of(this.toString()) } -} \ No newline at end of file +} diff --git a/dsl-core/src/jvmTest/kotlin/it/unibo/tuprolog/dsl/PlatformSpecificValues.kt b/dsl-core/src/jvmTest/kotlin/it/unibo/tuprolog/dsl/PlatformSpecificValues.kt index da7837ce1..98acdf2d0 100644 --- a/dsl-core/src/jvmTest/kotlin/it/unibo/tuprolog/dsl/PlatformSpecificValues.kt +++ b/dsl-core/src/jvmTest/kotlin/it/unibo/tuprolog/dsl/PlatformSpecificValues.kt @@ -10,4 +10,4 @@ actual object PlatformSpecificValues { actual val ONE_POINT_ZERO: Numeric = Real.of("1.0") actual val MINUS_THREE: Numeric = Integer.of(-3) -} \ No newline at end of file +} From 5495de2ef3e145dbaffdb8e2623939b9faca5e54 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 14 Sep 2020 15:31:04 +0200 Subject: [PATCH 14/34] format code in :dsl-unify --- dsl-unify/build.gradle.kts | 20 ------------------- .../tuprolog/dsl/unify/PrologExtensions.kt | 3 ++- .../dsl/unify/PrologScopeWithUnification.kt | 5 +++-- .../unify/PrologScopeWithUnificationImpl.kt | 2 +- .../it/unibo/tuprolog/dsl/unify/Prova.kt | 2 +- 5 files changed, 7 insertions(+), 25 deletions(-) diff --git a/dsl-unify/build.gradle.kts b/dsl-unify/build.gradle.kts index 91b274fea..6fed1cb0b 100644 --- a/dsl-unify/build.gradle.kts +++ b/dsl-unify/build.gradle.kts @@ -1,30 +1,10 @@ -// Project specific kotlin multiplatform configuration kotlin { - sourceSets { val commonMain by getting { dependencies { -// api("com.github.gciatto:kt-math-metadata:0.+") api(project(":dsl-core")) api(project(":unify")) } } - - // Default source set for JVM-specific sources and dependencies: - jvm { - compilations["main"].defaultSourceSet { - dependencies { -// api(project(":core")) - } - } - } - - js { - compilations["main"].defaultSourceSet { - dependencies { -// api(project(":core")) - } - } - } } } diff --git a/dsl-unify/src/commonMain/kotlin/it/unibo/tuprolog/dsl/unify/PrologExtensions.kt b/dsl-unify/src/commonMain/kotlin/it/unibo/tuprolog/dsl/unify/PrologExtensions.kt index 7b8d18a20..18ec619ae 100644 --- a/dsl-unify/src/commonMain/kotlin/it/unibo/tuprolog/dsl/unify/PrologExtensions.kt +++ b/dsl-unify/src/commonMain/kotlin/it/unibo/tuprolog/dsl/unify/PrologExtensions.kt @@ -1,4 +1,5 @@ @file:JvmName("PrologExtensions") + package it.unibo.tuprolog.dsl.unify import it.unibo.tuprolog.core.Fact @@ -26,4 +27,4 @@ fun PrologScopeWithUnification.fact(function: PrologScopeWithUnification.() -> T @JsName("prolog") fun prolog(function: PrologScopeWithUnification.() -> R): R { return PrologScopeWithUnification.empty().function() -} \ No newline at end of file +} diff --git a/dsl-unify/src/commonMain/kotlin/it/unibo/tuprolog/dsl/unify/PrologScopeWithUnification.kt b/dsl-unify/src/commonMain/kotlin/it/unibo/tuprolog/dsl/unify/PrologScopeWithUnification.kt index 94bdc5174..4ed6cb5c4 100644 --- a/dsl-unify/src/commonMain/kotlin/it/unibo/tuprolog/dsl/unify/PrologScopeWithUnification.kt +++ b/dsl-unify/src/commonMain/kotlin/it/unibo/tuprolog/dsl/unify/PrologScopeWithUnification.kt @@ -1,6 +1,7 @@ package it.unibo.tuprolog.dsl.unify -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Substitution +import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.dsl.PrologScope import it.unibo.tuprolog.unify.Unificator import kotlin.js.JsName @@ -38,4 +39,4 @@ interface PrologScopeWithUnification : PrologScope, Unificator { @JsName("of") fun of(unificator: Unificator): PrologScopeWithUnification = PrologScopeWithUnificationImpl(unificator) } -} \ No newline at end of file +} diff --git a/dsl-unify/src/commonMain/kotlin/it/unibo/tuprolog/dsl/unify/PrologScopeWithUnificationImpl.kt b/dsl-unify/src/commonMain/kotlin/it/unibo/tuprolog/dsl/unify/PrologScopeWithUnificationImpl.kt index 622da798e..feb7ed1d6 100644 --- a/dsl-unify/src/commonMain/kotlin/it/unibo/tuprolog/dsl/unify/PrologScopeWithUnificationImpl.kt +++ b/dsl-unify/src/commonMain/kotlin/it/unibo/tuprolog/dsl/unify/PrologScopeWithUnificationImpl.kt @@ -7,4 +7,4 @@ class PrologScopeWithUnificationImpl(unificator: Unificator) : PrologScopeWithUnification, PrologScope by PrologScope.empty(), Unificator by unificator { constructor() : this(Unificator.default) -} \ No newline at end of file +} diff --git a/dsl-unify/src/commonTest/kotlin/it/unibo/tuprolog/dsl/unify/Prova.kt b/dsl-unify/src/commonTest/kotlin/it/unibo/tuprolog/dsl/unify/Prova.kt index 34cdacde4..863b51dec 100644 --- a/dsl-unify/src/commonTest/kotlin/it/unibo/tuprolog/dsl/unify/Prova.kt +++ b/dsl-unify/src/commonTest/kotlin/it/unibo/tuprolog/dsl/unify/Prova.kt @@ -10,4 +10,4 @@ class Prova { println("f"("X") mguWith "f"(1)) } } -} \ No newline at end of file +} From 30eafdb27a6697a75c044f374603d5848b44d7a4 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 14 Sep 2020 15:32:43 +0200 Subject: [PATCH 15/34] format code in :dsl-solve --- dsl-solve/build.gradle.kts | 20 ------------------- .../tuprolog/dsl/solve/PrologExtensions.kt | 3 ++- .../dsl/solve/PrologScopeWithResolution.kt | 4 ++-- .../solve/PrologScopeWithResolutionImpl.kt | 8 ++++---- .../unibo/tuprolog/dsl/solve/TestNQueens.kt | 9 ++++----- .../dsl/solve/TestPrologWithResolution.kt | 5 +++-- 6 files changed, 15 insertions(+), 34 deletions(-) diff --git a/dsl-solve/build.gradle.kts b/dsl-solve/build.gradle.kts index f78e3046e..a04f74e20 100644 --- a/dsl-solve/build.gradle.kts +++ b/dsl-solve/build.gradle.kts @@ -1,30 +1,10 @@ -// Project specific kotlin multiplatform configuration kotlin { - sourceSets { val commonMain by getting { dependencies { -// api("com.github.gciatto:kt-math-metadata:0.+") api(project(":dsl-theory")) api(project(":solve-classic")) } } - - // Default source set for JVM-specific sources and dependencies: - jvm { - compilations["main"].defaultSourceSet { - dependencies { -// api(project(":core")) - } - } - } - - js { - compilations["main"].defaultSourceSet { - dependencies { -// api(project(":core")) - } - } - } } } diff --git a/dsl-solve/src/commonMain/kotlin/it/unibo/tuprolog/dsl/solve/PrologExtensions.kt b/dsl-solve/src/commonMain/kotlin/it/unibo/tuprolog/dsl/solve/PrologExtensions.kt index 5013ce9b4..4297fc418 100644 --- a/dsl-solve/src/commonMain/kotlin/it/unibo/tuprolog/dsl/solve/PrologExtensions.kt +++ b/dsl-solve/src/commonMain/kotlin/it/unibo/tuprolog/dsl/solve/PrologExtensions.kt @@ -1,4 +1,5 @@ @file:JvmName("PrologExtensions") + package it.unibo.tuprolog.dsl.solve import it.unibo.tuprolog.solve.SolverFactory @@ -13,4 +14,4 @@ fun prolog(solverFactory: SolverFactory, function: PrologScopeWithResolution @JsName("prolog") fun prolog(function: PrologScopeWithResolution.() -> R): R { return PrologScopeWithResolution.empty().function() -} \ No newline at end of file +} diff --git a/dsl-solve/src/commonMain/kotlin/it/unibo/tuprolog/dsl/solve/PrologScopeWithResolution.kt b/dsl-solve/src/commonMain/kotlin/it/unibo/tuprolog/dsl/solve/PrologScopeWithResolution.kt index ab3b89315..8e1f4db02 100644 --- a/dsl-solve/src/commonMain/kotlin/it/unibo/tuprolog/dsl/solve/PrologScopeWithResolution.kt +++ b/dsl-solve/src/commonMain/kotlin/it/unibo/tuprolog/dsl/solve/PrologScopeWithResolution.kt @@ -3,8 +3,8 @@ package it.unibo.tuprolog.dsl.solve import it.unibo.tuprolog.core.Clause import it.unibo.tuprolog.dsl.theory.PrologScopeWithTheories import it.unibo.tuprolog.solve.ClassicSolverFactory -import it.unibo.tuprolog.solve.MutableSolver import it.unibo.tuprolog.solve.FlagStore +import it.unibo.tuprolog.solve.MutableSolver import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.channel.InputChannel import it.unibo.tuprolog.solve.channel.OutputChannel @@ -72,4 +72,4 @@ interface PrologScopeWithResolution : PrologScopeWithTheories, MutableSolver { @JsName("empty") fun empty(): PrologScopeWithResolution = of(ClassicSolverFactory) } -} \ No newline at end of file +} diff --git a/dsl-solve/src/commonMain/kotlin/it/unibo/tuprolog/dsl/solve/PrologScopeWithResolutionImpl.kt b/dsl-solve/src/commonMain/kotlin/it/unibo/tuprolog/dsl/solve/PrologScopeWithResolutionImpl.kt index 711b31648..304d7e2aa 100644 --- a/dsl-solve/src/commonMain/kotlin/it/unibo/tuprolog/dsl/solve/PrologScopeWithResolutionImpl.kt +++ b/dsl-solve/src/commonMain/kotlin/it/unibo/tuprolog/dsl/solve/PrologScopeWithResolutionImpl.kt @@ -5,7 +5,7 @@ import it.unibo.tuprolog.solve.MutableSolver import it.unibo.tuprolog.solve.SolverFactory class PrologScopeWithResolutionImpl - constructor( - override val solverFactory: SolverFactory, - override val defaultSolver: MutableSolver = solverFactory.mutableSolverWithDefaultBuiltins() - ) : PrologScopeWithResolution, PrologScopeWithTheories by PrologScopeWithTheories.empty(), MutableSolver by defaultSolver \ No newline at end of file +constructor( + override val solverFactory: SolverFactory, + override val defaultSolver: MutableSolver = solverFactory.mutableSolverWithDefaultBuiltins() +) : PrologScopeWithResolution, PrologScopeWithTheories by PrologScopeWithTheories.empty(), MutableSolver by defaultSolver diff --git a/dsl-solve/src/commonTest/kotlin/it/unibo/tuprolog/dsl/solve/TestNQueens.kt b/dsl-solve/src/commonTest/kotlin/it/unibo/tuprolog/dsl/solve/TestNQueens.kt index fd4018266..0f7aa8b5b 100644 --- a/dsl-solve/src/commonTest/kotlin/it/unibo/tuprolog/dsl/solve/TestNQueens.kt +++ b/dsl-solve/src/commonTest/kotlin/it/unibo/tuprolog/dsl/solve/TestNQueens.kt @@ -18,7 +18,7 @@ class TestNQueens { staticKb( rule { "no_attack"(("X1" and "Y1"), ("X2" and "Y2")) `if` ( - ("X1" `=!=` "X2") and + ("X1" `=!=` "X2") and ("Y1" `=!=` "Y2") and (("Y2" - "Y1") `=!=` ("X2" - "X1")) and (("Y2" - "Y1") `=!=` ("X1" - "X2")) @@ -27,21 +27,21 @@ class TestNQueens { fact { "no_attack_all"(`_`, emptyList) }, rule { "no_attack_all"("C", consOf("H", "Hs")) `if` ( - "no_attack"("C", "H") and + "no_attack"("C", "H") and "no_attack_all"("C", "Hs") ) }, fact { "solution"(`_`, emptyList) }, rule { "solution"("N", consOf(("X" and "Y"), "Cs")) `if` ( - "solution"("N", "Cs") and + "solution"("N", "Cs") and between(1, "N", "Y") and "no_attack_all"(("X" and "Y"), "Cs") ) } ) - solve("solution"(n, (1 .. n).map { it and "Y$it" })) + solve("solution"(n, (1..n).map { it and "Y$it" })) .filterIsInstance() .map { it.solvedQuery[1] as Collection } .map { it.toList() } @@ -59,5 +59,4 @@ class TestNQueens { assertEquals(solutions[i], actual) } } - } diff --git a/dsl-solve/src/commonTest/kotlin/it/unibo/tuprolog/dsl/solve/TestPrologWithResolution.kt b/dsl-solve/src/commonTest/kotlin/it/unibo/tuprolog/dsl/solve/TestPrologWithResolution.kt index 34938f2bb..c04d72d93 100644 --- a/dsl-solve/src/commonTest/kotlin/it/unibo/tuprolog/dsl/solve/TestPrologWithResolution.kt +++ b/dsl-solve/src/commonTest/kotlin/it/unibo/tuprolog/dsl/solve/TestPrologWithResolution.kt @@ -25,8 +25,9 @@ class TestPrologWithResolution { val actual = mutableListOf() for (sol in solve("ancestor"("abraham", "X"))) - if (sol is Solution.Yes) + if (sol is Solution.Yes) { actual.add(sol.substitution["X"].toString()) + } assertEquals( mutableListOf("isaac", "jacob", "joseph"), @@ -34,4 +35,4 @@ class TestPrologWithResolution { ) } } -} \ No newline at end of file +} From 7c0f62ea5599bb72c1d6d942ed446dd3de540bde Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 14 Sep 2020 15:37:23 +0200 Subject: [PATCH 16/34] fix sleep/1 --- .../kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Sleep.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Sleep.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Sleep.kt index e89f18f6b..fcf0c977a 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Sleep.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/Sleep.kt @@ -21,8 +21,9 @@ object Sleep : UnaryPredicate("sleep") { val initialTime = currentTimeInstant() val threshold = arguments[0].castTo().intValue.toLongExact() while (currentTimeInstant() - initialTime < threshold) { - yield(replySuccess()) + // busy waiting } + yield(replySuccess()) } } } From 63d9abd0311eee4db6e7f3eaa9c04bb30a4a2eaa Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 14 Sep 2020 15:41:50 +0200 Subject: [PATCH 17/34] format code in :dsl-theory --- dsl-theory/build.gradle.kts | 20 ------------------- .../tuprolog/dsl/theory/PrologExtensions.kt | 3 ++- .../dsl/theory/PrologScopeWithTheories.kt | 2 +- .../dsl/theory/PrologScopeWithTheoriesImpl.kt | 2 +- .../it/unibo/tuprolog/dsl/theory/Prova.kt | 12 ++++++----- 5 files changed, 11 insertions(+), 28 deletions(-) diff --git a/dsl-theory/build.gradle.kts b/dsl-theory/build.gradle.kts index 2b5e2b123..d635671f1 100644 --- a/dsl-theory/build.gradle.kts +++ b/dsl-theory/build.gradle.kts @@ -1,30 +1,10 @@ -// Project specific kotlin multiplatform configuration kotlin { - sourceSets { val commonMain by getting { dependencies { -// api("com.github.gciatto:kt-math-metadata:0.+") api(project(":dsl-unify")) api(project(":theory")) } } - - // Default source set for JVM-specific sources and dependencies: - jvm { - compilations["main"].defaultSourceSet { - dependencies { -// api(project(":core")) - } - } - } - - js { - compilations["main"].defaultSourceSet { - dependencies { -// api(project(":core")) - } - } - } } } diff --git a/dsl-theory/src/commonMain/kotlin/it/unibo/tuprolog/dsl/theory/PrologExtensions.kt b/dsl-theory/src/commonMain/kotlin/it/unibo/tuprolog/dsl/theory/PrologExtensions.kt index d1ed2dfb9..25589a233 100644 --- a/dsl-theory/src/commonMain/kotlin/it/unibo/tuprolog/dsl/theory/PrologExtensions.kt +++ b/dsl-theory/src/commonMain/kotlin/it/unibo/tuprolog/dsl/theory/PrologExtensions.kt @@ -1,4 +1,5 @@ @file:JvmName("PrologExtensions") + package it.unibo.tuprolog.dsl.theory import kotlin.js.JsName @@ -7,4 +8,4 @@ import kotlin.jvm.JvmName @JsName("prolog") fun prolog(function: PrologScopeWithTheories.() -> R): R { return PrologScopeWithTheories.empty().function() -} \ No newline at end of file +} diff --git a/dsl-theory/src/commonMain/kotlin/it/unibo/tuprolog/dsl/theory/PrologScopeWithTheories.kt b/dsl-theory/src/commonMain/kotlin/it/unibo/tuprolog/dsl/theory/PrologScopeWithTheories.kt index b5e769501..d6c6257ba 100644 --- a/dsl-theory/src/commonMain/kotlin/it/unibo/tuprolog/dsl/theory/PrologScopeWithTheories.kt +++ b/dsl-theory/src/commonMain/kotlin/it/unibo/tuprolog/dsl/theory/PrologScopeWithTheories.kt @@ -23,4 +23,4 @@ interface PrologScopeWithTheories : PrologScopeWithUnification { @JsName("empty") fun empty(): PrologScopeWithTheories = PrologScopeWithTheoriesImpl() } -} \ No newline at end of file +} diff --git a/dsl-theory/src/commonMain/kotlin/it/unibo/tuprolog/dsl/theory/PrologScopeWithTheoriesImpl.kt b/dsl-theory/src/commonMain/kotlin/it/unibo/tuprolog/dsl/theory/PrologScopeWithTheoriesImpl.kt index 4472d0458..38a919d7a 100644 --- a/dsl-theory/src/commonMain/kotlin/it/unibo/tuprolog/dsl/theory/PrologScopeWithTheoriesImpl.kt +++ b/dsl-theory/src/commonMain/kotlin/it/unibo/tuprolog/dsl/theory/PrologScopeWithTheoriesImpl.kt @@ -7,4 +7,4 @@ class PrologScopeWithTheoriesImpl(unificator: Unificator) : PrologScopeWithTheories, PrologScope by PrologScope.empty(), Unificator by unificator { constructor() : this(Unificator.default) -} \ No newline at end of file +} diff --git a/dsl-theory/src/commonTest/kotlin/it/unibo/tuprolog/dsl/theory/Prova.kt b/dsl-theory/src/commonTest/kotlin/it/unibo/tuprolog/dsl/theory/Prova.kt index 88db2b63f..94d4ec5e3 100644 --- a/dsl-theory/src/commonTest/kotlin/it/unibo/tuprolog/dsl/theory/Prova.kt +++ b/dsl-theory/src/commonTest/kotlin/it/unibo/tuprolog/dsl/theory/Prova.kt @@ -7,10 +7,12 @@ class Prova { @Test fun testProlog() { prolog { - println(theoryOf( - fact { "member"("X", consOf("X", `_`)) }, - rule { "member"("X", consOf(`_`, "T")) impliedBy "member"("X", "T") } - )) + println( + theoryOf( + fact { "member"("X", consOf("X", `_`)) }, + rule { "member"("X", consOf(`_`, "T")) impliedBy "member"("X", "T") } + ) + ) } } -} \ No newline at end of file +} From f0fead75c212fef21189ae261d19cfdfed4465f0 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 14 Sep 2020 15:53:16 +0200 Subject: [PATCH 18/34] format code in :parser-core --- .../core/parsing/InvalidTermTypeException.kt | 2 +- .../tuprolog/core/parsing/ParseException.kt | 11 +- .../unibo/tuprolog/core/parsing/TermParser.kt | 23 ++-- .../core/parsing/TermParserExtensions.kt | 18 ++- .../core/parsing/test/AssertionUtils.kt | 7 +- .../parsing/test/DoubleChecksOnEqualities.kt | 106 ++++++++++----- .../core/parsing/test/ParsingExamples.kt | 121 ++++++++++-------- .../core/parsing/test/TermParserTest.kt | 3 +- .../tuprolog/core/parsing/Conversions.kt | 2 +- .../core/parsing/DynamicOpListener.kt | 3 +- .../core/parsing/PrologParserFactory.kt | 21 ++- .../tuprolog/core/parsing/PrologVisitor.kt | 60 ++++++--- .../core/parsing/TermParserExtensions.kt | 2 +- .../tuprolog/core/parsing/TermParserImpl.kt | 2 +- .../tuprolog/core/parsing/Conversions.kt | 2 +- .../core/parsing/DynamicOpListener.kt | 3 +- .../it/unibo/tuprolog/core/parsing/Echo.kt | 3 +- .../core/parsing/PrologExpressionVisitor.kt | 43 ++++--- .../core/parsing/PrologParserFactory.kt | 15 ++- .../core/parsing/TermParserExtensions.kt | 2 +- .../tuprolog/core/parsing/TermParserImpl.kt | 2 +- 21 files changed, 280 insertions(+), 171 deletions(-) diff --git a/parser-core/src/commonMain/kotlin/it/unibo/tuprolog/core/parsing/InvalidTermTypeException.kt b/parser-core/src/commonMain/kotlin/it/unibo/tuprolog/core/parsing/InvalidTermTypeException.kt index 0537bcbfa..2382ee89a 100644 --- a/parser-core/src/commonMain/kotlin/it/unibo/tuprolog/core/parsing/InvalidTermTypeException.kt +++ b/parser-core/src/commonMain/kotlin/it/unibo/tuprolog/core/parsing/InvalidTermTypeException.kt @@ -15,6 +15,6 @@ class InvalidTermTypeException( offendingSymbol, line, column, - "Expecting ${expected.simpleName}, got `$offendingSymbol` instead" , + "Expecting ${expected.simpleName}, got `$offendingSymbol` instead", cause ) diff --git a/parser-core/src/commonMain/kotlin/it/unibo/tuprolog/core/parsing/ParseException.kt b/parser-core/src/commonMain/kotlin/it/unibo/tuprolog/core/parsing/ParseException.kt index f89b603c0..edcb15d1a 100644 --- a/parser-core/src/commonMain/kotlin/it/unibo/tuprolog/core/parsing/ParseException.kt +++ b/parser-core/src/commonMain/kotlin/it/unibo/tuprolog/core/parsing/ParseException.kt @@ -17,11 +17,10 @@ open class ParseException( override fun toString(): String { return "ParseException{" + - "message='" + message!!.replace("\\n", "\\\\n") + '\'' + - ", line=" + line + - ", column=" + column + - ", offendingSymbol='" + offendingSymbol + '\'' + - '}' + "message='" + message!!.replace("\\n", "\\\\n") + '\'' + + ", line=" + line + + ", column=" + column + + ", offendingSymbol='" + offendingSymbol + '\'' + + '}' } - } diff --git a/parser-core/src/commonMain/kotlin/it/unibo/tuprolog/core/parsing/TermParser.kt b/parser-core/src/commonMain/kotlin/it/unibo/tuprolog/core/parsing/TermParser.kt index 5e4f37cf6..25d454b16 100644 --- a/parser-core/src/commonMain/kotlin/it/unibo/tuprolog/core/parsing/TermParser.kt +++ b/parser-core/src/commonMain/kotlin/it/unibo/tuprolog/core/parsing/TermParser.kt @@ -1,6 +1,14 @@ package it.unibo.tuprolog.core.parsing -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Clause +import it.unibo.tuprolog.core.Constant +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Numeric +import it.unibo.tuprolog.core.Real +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.core.operators.Operator import it.unibo.tuprolog.core.operators.OperatorSet import kotlin.js.JsName @@ -18,7 +26,6 @@ interface TermParser { fun parseTerm(input: String): Term = parseTerm(input, defaultOperatorSet) - @JsName("parseStructWithOperators") fun parseStruct(input: String, operators: OperatorSet): Struct = parseTerm(input, operators) as Struct @@ -27,7 +34,6 @@ interface TermParser { fun parseStruct(input: String): Struct = parseStruct(input, defaultOperatorSet) - @JsName("parseConstantWithOperators") fun parseConstant(input: String, operators: OperatorSet): Constant = parseTerm(input, operators) as Constant @@ -36,7 +42,6 @@ interface TermParser { fun parseConstant(input: String): Constant = parseConstant(input, defaultOperatorSet) - @JsName("parseVarWithOperators") fun parseVar(input: String, operators: OperatorSet): Var = parseTerm(input, operators) as Var @@ -45,7 +50,6 @@ interface TermParser { fun parseVar(input: String): Var = parseVar(input, defaultOperatorSet) - @JsName("parseAtomWithOperators") fun parseAtom(input: String, operators: OperatorSet): Atom = parseTerm(input, operators) as Atom @@ -54,7 +58,6 @@ interface TermParser { fun parseAtom(input: String): Atom = parseAtom(input, defaultOperatorSet) - @JsName("parseNumericWithOperators") fun parseNumeric(input: String, operators: OperatorSet): Numeric = parseTerm(input, operators) as Numeric @@ -63,7 +66,6 @@ interface TermParser { fun parseNumeric(input: String): Numeric = parseNumeric(input, defaultOperatorSet) - @JsName("parseIntegerWithOperators") fun parseInteger(input: String, operators: OperatorSet): Integer = parseTerm(input, operators) as Integer @@ -72,7 +74,6 @@ interface TermParser { fun parseInteger(input: String): Integer = parseInteger(input, defaultOperatorSet) - @JsName("parseRealWithOperators") fun parseReal(input: String, operators: OperatorSet): Real = parseTerm(input, operators) as Real @@ -81,12 +82,11 @@ interface TermParser { fun parseReal(input: String): Real = parseReal(input, defaultOperatorSet) - @JsName("parseClauseWithOperators") fun parseClause(input: String, operators: OperatorSet): Clause { require(operators.any { it.functor == Clause.FUNCTOR }) { "Error while parsing string as Clause: the provided operator set has no " + - "operator for '${Clause.FUNCTOR}'/1 or '${Clause.FUNCTOR}'/1" + "operator for '${Clause.FUNCTOR}'/1 or '${Clause.FUNCTOR}'/1" } return parseTerm(input, operators).toClause() } @@ -116,5 +116,4 @@ interface TermParser { @JsName("withOperators") fun withOperators(vararg operators: Operator) = withOperators(OperatorSet(*operators)) } - -} \ No newline at end of file +} diff --git a/parser-core/src/commonMain/kotlin/it/unibo/tuprolog/core/parsing/TermParserExtensions.kt b/parser-core/src/commonMain/kotlin/it/unibo/tuprolog/core/parsing/TermParserExtensions.kt index cfea64e4f..521c79f33 100644 --- a/parser-core/src/commonMain/kotlin/it/unibo/tuprolog/core/parsing/TermParserExtensions.kt +++ b/parser-core/src/commonMain/kotlin/it/unibo/tuprolog/core/parsing/TermParserExtensions.kt @@ -2,7 +2,16 @@ package it.unibo.tuprolog.core.parsing -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Clause +import it.unibo.tuprolog.core.Constant +import it.unibo.tuprolog.core.Fact +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Numeric +import it.unibo.tuprolog.core.Real +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.core.operators.OperatorSet import kotlin.js.JsName import kotlin.jvm.JvmName @@ -13,7 +22,7 @@ private val defaultParser = TermParser.withDefaultOperators @JsName("termToClause") fun Term.toClause(source: Any? = null, line: Int = 0, column: Int = 0): Clause = - when(this) { + when (this) { is Clause -> this is Struct -> Fact.of(this) else -> throw InvalidTermTypeException(source, toString(), Clause::class, line, column) @@ -99,7 +108,6 @@ fun String.parseAsAtom(operators: OperatorSet): Atom = fun String.parseAsAtom(): Atom = defaultParser.parseAtom(this) - @JsName("parseNumericWithOperators") fun Numeric.Companion.parse(input: String, operators: OperatorSet): Numeric = defaultParser.parseNumeric(input, operators) @@ -116,7 +124,6 @@ fun String.parseAsNumeric(operators: OperatorSet): Numeric = fun String.parseAsNumeric(): Numeric = defaultParser.parseNumeric(this) - @JsName("parseIntegerWithOperators") fun Integer.Companion.parse(input: String, operators: OperatorSet): Integer = defaultParser.parseInteger(input, operators) @@ -133,7 +140,6 @@ fun String.parseAsInteger(operators: OperatorSet): Integer = fun String.parseAsInteger(): Integer = defaultParser.parseInteger(this) - @JsName("parseRealWithOperators") fun Real.Companion.parse(input: String, operators: OperatorSet): Real = defaultParser.parseReal(input, operators) @@ -164,4 +170,4 @@ fun String.parseAsClause(operators: OperatorSet): Clause = @JsName("parseStringAsClause") fun String.parseAsClause(): Clause = - defaultParser.parseClause(this) \ No newline at end of file + defaultParser.parseClause(this) diff --git a/parser-core/src/commonTest/kotlin/it/unibo/tuprolog/core/parsing/test/AssertionUtils.kt b/parser-core/src/commonTest/kotlin/it/unibo/tuprolog/core/parsing/test/AssertionUtils.kt index 6c5aef7a3..c246f7a62 100644 --- a/parser-core/src/commonTest/kotlin/it/unibo/tuprolog/core/parsing/test/AssertionUtils.kt +++ b/parser-core/src/commonTest/kotlin/it/unibo/tuprolog/core/parsing/test/AssertionUtils.kt @@ -13,7 +13,10 @@ fun assertTermsAreEqual(expected: Term, actual: Term) { assertEquals(expected.isGround, actual.isGround) if (expected.isGround) { assertEquals( - expected, actual, message = """Comparing: + expected, + actual, + message = + """Comparing: | actual: $actual | type: ${actual::class} | expected: $expected @@ -61,4 +64,4 @@ fun TermParser.assertTermIsCorrectlyParsed(stringToBeParsed: String, expected: T assertTermsAreEqual(actual, expected) if (loggingOn) println("".padEnd(80, '-')) -} \ No newline at end of file +} diff --git a/parser-core/src/commonTest/kotlin/it/unibo/tuprolog/core/parsing/test/DoubleChecksOnEqualities.kt b/parser-core/src/commonTest/kotlin/it/unibo/tuprolog/core/parsing/test/DoubleChecksOnEqualities.kt index 337dd6bff..3e4a3444a 100644 --- a/parser-core/src/commonTest/kotlin/it/unibo/tuprolog/core/parsing/test/DoubleChecksOnEqualities.kt +++ b/parser-core/src/commonTest/kotlin/it/unibo/tuprolog/core/parsing/test/DoubleChecksOnEqualities.kt @@ -13,83 +13,119 @@ class DoubleChecksOnEqualities { @Test fun testNumsAreEquals1() { - assertEquals(Integer.of(1), prolog { - 1.toTerm() - }) + assertEquals( + Integer.of(1), + prolog { + 1.toTerm() + } + ) } @Test fun testRealsInitialization() { - assertEquals(Real.of(3.1), Real.of("3.1")) + assertEquals( + Real.of(3.1), + Real.of("3" + ".1") + ) } @Test fun testNumsAreEquals2() { - assertEquals(Integer.of(1), prolog { - numOf(1) - }) + assertEquals( + Integer.of(1), + prolog { + numOf(1) + } + ) } @Test fun testNumsAreEquals3() { - assertEquals(Integer.of(1), prolog { - numOf(1L) - }) + assertEquals( + Integer.of(1), + prolog { + numOf(1L) + } + ) } @Test fun testNumsAreEquals4() { - assertEquals(Integer.of(1), prolog { - numOf(BigInteger.ONE) - }) + assertEquals( + Integer.of(1), + prolog { + numOf(BigInteger.ONE) + } + ) } @Test fun testNumsAreEquals5() { - assertEquals(Integer.of(1), prolog { - numOf(BigInteger.TEN / BigInteger.TEN) - }) + assertEquals( + Integer.of(1), + prolog { + numOf(BigInteger.TEN / BigInteger.TEN) + } + ) } @Test fun testListsAreEquals1() { - assertEquals(Cons.singleton(Integer.of(1)), prolog { - listOf(1) - }) + assertEquals( + Cons.singleton(Integer.of(1)), + prolog { + listOf(1) + } + ) } @Test fun testListsAreEquals2() { - assertEquals(Cons.singleton(Integer.of(1)), prolog { - listOf(numOf(1)) - }) + assertEquals( + Cons.singleton(Integer.of(1)), + prolog { + listOf(numOf(1)) + } + ) } @Test fun testListsAreEquals3() { - assertEquals(Cons.singleton(Integer.of(1)), prolog { - consOf(1, emptyList) - }) + assertEquals( + Cons.singleton(Integer.of(1)), + prolog { + consOf(1, emptyList) + } + ) } @Test fun testListsAreEquals4() { - assertEquals(Cons.singleton(Integer.of(1)), prolog { - consOf(numOf(1), emptyList) - }) + assertEquals( + Cons.singleton(Integer.of(1)), + prolog { + consOf(numOf(1), emptyList) + } + ) } @Test fun testListsAreEquals5() { - assertEquals(Cons.singleton(Integer.of(1)), prolog { - consOf(Integer.of(1), emptyList) - }) + assertEquals( + Cons.singleton(Integer.of(1)), + prolog { + consOf(Integer.of(1), emptyList) + } + ) } @Test fun testStructsAreEquals() { - assertEquals(Struct.of("+", Integer.of(1), Integer.of(2)), prolog { - 1.toTerm() + 2 - }) + assertEquals( + Struct.of("+", Integer.of(1), Integer.of(2)), + prolog { + 1.toTerm() + 2 + } + ) } -} \ No newline at end of file +} diff --git a/parser-core/src/commonTest/kotlin/it/unibo/tuprolog/core/parsing/test/ParsingExamples.kt b/parser-core/src/commonTest/kotlin/it/unibo/tuprolog/core/parsing/test/ParsingExamples.kt index 66dacb53d..f417da4c2 100644 --- a/parser-core/src/commonTest/kotlin/it/unibo/tuprolog/core/parsing/test/ParsingExamples.kt +++ b/parser-core/src/commonTest/kotlin/it/unibo/tuprolog/core/parsing/test/ParsingExamples.kt @@ -79,135 +79,148 @@ object ParsingExamples { 1.toTerm() + 2 }, "3 + 4 * 5 - 1" to prolog { - (3.toTerm() + ( 4.toTerm() * 5)).toTerm() - 1 + (3.toTerm() + (4.toTerm() * 5)).toTerm() - 1 }, "A; _" to prolog { "A" or `_` }, - "a; B :- 1" to prolog{ + "a; B :- 1" to prolog { "a" or "B" impliedBy 1 }, - "a :- 1; '2'" to prolog{ + "a :- 1; '2'" to prolog { "a" impliedBy (1 or "2") }, "a; B :- 1, 3.1; '2'" to prolog { "a" or "B" impliedBy - (1 and 3.1 or "2") + (1 and 3.1 or "2") }, "a, c(D); B :- 1, 3.1; '2'" to prolog { "a" and "c"("D") or "B" impliedBy - (1 and 3.1 or "2") + (1 and 3.1 or "2") }, "a; B, c(D) :- 1, \"4\"; '2', 3.1" to prolog { "a" or ("B" and "c"("D")) impliedBy - (1 and "4" or ("2" and 3.1)) + (1 and "4" or ("2" and 3.1)) }, "a, c(D); B, e(_f, [g]) :- 1; '2', 3.1" to prolog { - ("a" and "c"("D") or ("B" and "e"( "_f", listOf("g")))) impliedBy - (1 or ("2" and 3.1)) + ("a" and "c"("D") or ("B" and "e"("_f", listOf("g")))) impliedBy + (1 or ("2" and 3.1)) }, "a, 3 -> 5; 5.3, 1 -> 6 :- a; b, c" to prolog { - (("a" and 3) then 5 ) or (( 5.3 and 1) then 6) impliedBy - ("a" or ( "b" and "c" )) + (("a" and 3) then 5) or ((5.3 and 1) then 6) impliedBy + ("a" or ("b" and "c")) }, "first_step(X, [X])" to prolog { "first_step"("X", listOf("X")) }, - "sec_step(X,[_|L]) :- first_step(X,L)" to prolog{ + "sec_step(X,[_|L]) :- first_step(X,L)" to prolog { "sec_step"("X", consOf(`_`, "L")) impliedBy - ("first_step"("X", "L")) + ("first_step"("X", "L")) }, "last_but_one(X,[X,_])" to prolog { - "last_but_one"("X",listOf("X",`_`)) + "last_but_one"("X", listOf("X", `_`)) }, "last_but_one(X,[_,Y|Ys]) :- last_but_one(X,[Y|Ys])" to prolog { - "last_but_one"("X",consOf( `_`, consOf("Y","Ys"))) impliedBy - "last_but_one"("X",consOf("Y","Ys")) + "last_but_one"("X", consOf(`_`, consOf("Y", "Ys"))) impliedBy + "last_but_one"("X", consOf("Y", "Ys")) }, "element_at(X,[_|L],K) :- K > 1, K1 is K - 1, element_at(X,L,K1)" to prolog { - "element_at"("X",consOf(`_`,"L"),"K") impliedBy - (("K" greaterThan 1) and (("K1" `is` ("K" - 1)) and ("element_at"("X","L","K1")))) + "element_at"("X", consOf(`_`, "L"), "K") impliedBy + (("K" greaterThan 1) and (("K1" `is` ("K" - 1)) and ("element_at"("X", "L", "K1")))) }, "my_length([],0)" to prolog { - "my_length"(emptyList,0) + "my_length"(emptyList, 0) }, "my_length([_|L],N) :- my_length(L,N1), N is N1 + 1" to prolog { - "my_length"(consOf(`_`,"L"),"N") impliedBy - ( "my_length"("L", "N1") and (( "N" `is` ("N1".toTerm() + 1)))) + "my_length"(consOf(`_`, "L"), "N") impliedBy + ("my_length"("L", "N1") and (("N" `is` ("N1".toTerm() + 1)))) }, "my_reverse(L1,L2) :- my_rev(L1,L2,[])" to prolog { - "my_reverse"("L1","L2") impliedBy - "my_rev"("L1", "L2", emptyList) + "my_reverse"("L1", "L2") impliedBy + "my_rev"("L1", "L2", emptyList) }, "my_rev([],L2,L2) :- !" to prolog { - "my_rev"(emptyList,"L2","L2") impliedBy "!" + "my_rev"(emptyList, "L2", "L2") impliedBy "!" }, "my_rev([X|Xs],L2,Acc) :- my_rev(Xs,L2,[X|Acc])" to prolog { - "my_rev"(consOf("X","Xs"), "L2","Acc") impliedBy - "my_rev"("Xs","L2",consOf("X","Acc")) + "my_rev"(consOf("X", "Xs"), "L2", "Acc") impliedBy + "my_rev"("Xs", "L2", consOf("X", "Acc")) }, "is_palindrome(L) :- reverse(L,L)" to prolog { "is_palindrome"("L") impliedBy - "reverse"("L","L") + "reverse"("L", "L") }, "my_flatten(X,[X]) :- \\+ is_list(X)" to prolog { - "my_flatten"("X",listOf("X")) impliedBy - "\\+"("is_list"("X")) + "my_flatten"("X", listOf("X")) impliedBy + "\\+"("is_list"("X")) }, "my_flatten([],[])" to prolog { "my_flatten"(emptyList, emptyList) }, "my_flatten([X|Xs],Zs) :- my_flatten(X,Y), my_flatten(Xs,Ys), append(Y,Ys,Zs)" to prolog { - "my_flatten"(consOf("X","Xs"),"Zs") impliedBy - ( "my_flatten"("X","Y") and ( "my_flatten"("Xs","Ys") and "append"("Y","Ys","Zs"))) + "my_flatten"(consOf("X", "Xs"), "Zs") impliedBy + ("my_flatten"("X", "Y") and ("my_flatten"("Xs", "Ys") and "append"("Y", "Ys", "Zs"))) }, "compress([X,Y|Ys],[X|Zs]) :- X \\= Y, compress([Y|Ys],Zs)" to prolog { - "compress"(consOf("X",consOf("Y","Ys")),consOf("X","Zs")) impliedBy - ("\\="("X","Y") and "compress"(consOf("Y","Ys"),"Zs")) + "compress"(consOf("X", consOf("Y", "Ys")), consOf("X", "Zs")) impliedBy + ("\\="("X", "Y") and "compress"(consOf("Y", "Ys"), "Zs")) }, "count(X,[],[],N,[N,X]) :- N > 1" to prolog { - "count"("X", emptyList, emptyList,"N",consOf("N","X")) impliedBy - ("N" greaterThan 1) + "count"("X", emptyList, emptyList, "N", consOf("N", "X")) impliedBy + ("N" greaterThan 1) }, "count(X,[Y|Ys],[Y|Ys],1,X) :- X \\= Y" to prolog { - "count"("X",consOf("Y","Ys"),consOf("Y","Ys"),1,"X") impliedBy - ( "\\="("X","Y")) + "count"("X", consOf("Y", "Ys"), consOf("Y", "Ys"), 1, "X") impliedBy + ("\\="("X", "Y")) }, "count(X,[Y|Ys],[Y|Ys],N,[N,X]) :- N > 1, X \\= Y" to prolog { - "count"("X", consOf("Y","Ys"),consOf("Y","Ys"),"N",consOf("N","X")) impliedBy - (("N" greaterThan 1) and ( "\\="("X","Y"))) + "count"("X", consOf("Y", "Ys"), consOf("Y", "Ys"), "N", consOf("N", "X")) impliedBy + (("N" greaterThan 1) and ("\\="("X", "Y"))) }, "count(X,[X|Xs],Ys,K,T) :- K1 is K + 1, count(X,Xs,Ys,K1,T)" to prolog { - "count"("X",consOf("X","Xs"),"Ys","K","T") impliedBy - (("K1" `is` ("K".toTerm() + 1)) and ( "count"("X","Xs","Ys","K1","T"))) + "count"("X", consOf("X", "Xs"), "Ys", "K", "T") impliedBy + (("K1" `is` ("K".toTerm() + 1)) and ("count"("X", "Xs", "Ys", "K1", "T"))) }, "map_upper_bound(XMax, YMax) :- map_size(XSize, YSize), XMax is XSize - 1, YMax is YSize - 1" to prolog { - "map_upper_bound"("XMax","YMax") impliedBy - ( "map_size"("XSize","YSize") and (("XMax" `is` ("XSize" - 1)) and ("YMax" `is` ("YSize" - 1)))) + "map_upper_bound"("XMax", "YMax") impliedBy + ("map_size"("XSize", "YSize") and (("XMax" `is` ("XSize" - 1)) and ("YMax" `is` ("YSize" - 1)))) }, "in_map(X, Y) :- X >= 0, Y >= 0, map_size(XSize, YSize), X < XSize, Y < YSize" to prolog { - "in_map"("X","Y") impliedBy - (("X" greaterThanOrEqualsTo 0) and (("Y" greaterThanOrEqualsTo 0) and ( "map_size"("XSize","YSize") and (("X" lowerThan ("XSize")) and ("Y" lowerThan "YSize"))))) + "in_map"("X", "Y") impliedBy + (("X" greaterThanOrEqualsTo 0) and (("Y" greaterThanOrEqualsTo 0) and ("map_size"("XSize", "YSize") and (("X" lowerThan ("XSize")) and ("Y" lowerThan "YSize"))))) }, "tile(wall, X, Y) :- \\+ in_map(X, Y)" to prolog { - "tile"("wall","X","Y") impliedBy - ( "\\+"("in_map"("X","Y"))) + "tile"("wall", "X", "Y") impliedBy + ("\\+"("in_map"("X", "Y"))) }, "draw_char(X, Y) :- tty_size(_, XSize), X >= XSize, NY is Y + 1, draw_char(0, NY)" to prolog { - "draw_char"("X","Y") impliedBy - ( "tty_size"(`_`,"XSize") and (("X" greaterThanOrEqualsTo "XSize") and (("NY" `is` ("Y".toTerm() + 1)) and ("draw_char"(0,"NY"))))) + "draw_char"("X", "Y") impliedBy + ("tty_size"(`_`, "XSize") and (("X" greaterThanOrEqualsTo "XSize") and (("NY" `is` ("Y".toTerm() + 1)) and ("draw_char"(0, "NY"))))) }, "Y < YMsgs -> write(' ') ; display_offset(XOff, YOff), XMap is X + XOff, YMap is Y + YOff, get_character(XMap, YMap, C), format('~s', [C])" to prolog { (("Y" lowerThan "YMsgs") then "write"(" ")) or - ( "display_offset"("XOff","YOff") and (("XMap" `is` ("X".toTerm() + "XOff")) and (("YMap" `is` ("Y".toTerm() + "YOff")) and - ( "get_character"("XMap","YMap","C") and ( "format"("~s",listOf("C"))))))) + ( + "display_offset"("XOff", "YOff") and ( + ("XMap" `is` ("X".toTerm() + "XOff")) and ( + ("YMap" `is` ("Y".toTerm() + "YOff")) and + ("get_character"("XMap", "YMap", "C") and ("format"("~s", listOf("C")))) + ) + ) + ) }, "display_offset(X, Y) :- player(XPos, YPos), tty_size(YSize, XSize), message_lines(YMsgs), X is XPos - floor(XSize / 2), Y is YPos - floor((YSize - YMsgs) / 2)" to prolog { - "display_offset"("X","Y") impliedBy - ( "player"("XPos","YPos") and ( "tty_size"("YSize","XSize")and ( "message_lines"("YMsgs") and ( - ( "X" `is` ("XPos" - "floor"("XSize" / 2))) and (("Y" `is` ("YPos" - "floor"(("YSize" - "YMsgs") / 2)))))))) + "display_offset"("X", "Y") impliedBy + ( + "player"("XPos", "YPos") and ( + "tty_size"("YSize", "XSize")and ( + "message_lines"("YMsgs") and ( + ("X" `is` ("XPos" - "floor"("XSize" / 2))) and (("Y" `is` ("YPos" - "floor"(("YSize" - "YMsgs") / 2)))) + ) + ) + ) + ) } ) val all = canonicalTerms + expressions -} \ No newline at end of file +} diff --git a/parser-core/src/commonTest/kotlin/it/unibo/tuprolog/core/parsing/test/TermParserTest.kt b/parser-core/src/commonTest/kotlin/it/unibo/tuprolog/core/parsing/test/TermParserTest.kt index c11019e69..9f726b539 100644 --- a/parser-core/src/commonTest/kotlin/it/unibo/tuprolog/core/parsing/test/TermParserTest.kt +++ b/parser-core/src/commonTest/kotlin/it/unibo/tuprolog/core/parsing/test/TermParserTest.kt @@ -22,5 +22,4 @@ class TermParserTest { parser.assertTermIsCorrectlyParsed(it.first, it.second) } } - -} \ No newline at end of file +} diff --git a/parser-core/src/jsMain/kotlin/it/unibo/tuprolog/core/parsing/Conversions.kt b/parser-core/src/jsMain/kotlin/it/unibo/tuprolog/core/parsing/Conversions.kt index f2bbee745..eddfccee9 100644 --- a/parser-core/src/jsMain/kotlin/it/unibo/tuprolog/core/parsing/Conversions.kt +++ b/parser-core/src/jsMain/kotlin/it/unibo/tuprolog/core/parsing/Conversions.kt @@ -6,4 +6,4 @@ fun String.toSpecifier(): Specifier = Specifier.valueOf(toUpperCase()) fun Specifier.toAssociativity(): String = - toString() \ No newline at end of file + toString() diff --git a/parser-core/src/jsMain/kotlin/it/unibo/tuprolog/core/parsing/DynamicOpListener.kt b/parser-core/src/jsMain/kotlin/it/unibo/tuprolog/core/parsing/DynamicOpListener.kt index cb127674c..3dab80a74 100644 --- a/parser-core/src/jsMain/kotlin/it/unibo/tuprolog/core/parsing/DynamicOpListener.kt +++ b/parser-core/src/jsMain/kotlin/it/unibo/tuprolog/core/parsing/DynamicOpListener.kt @@ -60,5 +60,4 @@ class DynamicOpListener private constructor( return DynamicOpListener(parser, operatorDefinedCallback) } } - -} \ No newline at end of file +} diff --git a/parser-core/src/jsMain/kotlin/it/unibo/tuprolog/core/parsing/PrologParserFactory.kt b/parser-core/src/jsMain/kotlin/it/unibo/tuprolog/core/parsing/PrologParserFactory.kt index 98b07b58a..bc1282fb2 100644 --- a/parser-core/src/jsMain/kotlin/it/unibo/tuprolog/core/parsing/PrologParserFactory.kt +++ b/parser-core/src/jsMain/kotlin/it/unibo/tuprolog/core/parsing/PrologParserFactory.kt @@ -1,7 +1,21 @@ package it.unibo.tuprolog.core.parsing import it.unibo.tuprolog.core.operators.OperatorSet -import it.unibo.tuprolog.parser.* +import it.unibo.tuprolog.parser.BailErrorStrategy +import it.unibo.tuprolog.parser.ClauseContext +import it.unibo.tuprolog.parser.CommonTokenStream +import it.unibo.tuprolog.parser.ErrorListener +import it.unibo.tuprolog.parser.ErrorStrategy +import it.unibo.tuprolog.parser.InputStream +import it.unibo.tuprolog.parser.OptClauseContext +import it.unibo.tuprolog.parser.PredictionMode +import it.unibo.tuprolog.parser.PrologLexer +import it.unibo.tuprolog.parser.PrologParser +import it.unibo.tuprolog.parser.RecognitionException +import it.unibo.tuprolog.parser.SingletonExpressionContext +import it.unibo.tuprolog.parser.Token +import it.unibo.tuprolog.parser.isParseCancellationException +import it.unibo.tuprolog.parser.isRecognitionException object PrologParserFactory { @@ -75,7 +89,6 @@ object PrologParserFactory { } } - fun parseExpressionWithStandardOperators(string: String): SingletonExpressionContext = parseExpression(string, OperatorSet.DEFAULT) @@ -84,7 +97,6 @@ object PrologParserFactory { return parseClauses(parser, source) } - fun parseClauses(source: String): Sequence = parseClauses(source, OperatorSet.EMPTY) @@ -156,5 +168,4 @@ object PrologParserFactory { }.takeWhile { !it.isOver } .map { it.clause() } } - -} \ No newline at end of file +} diff --git a/parser-core/src/jsMain/kotlin/it/unibo/tuprolog/core/parsing/PrologVisitor.kt b/parser-core/src/jsMain/kotlin/it/unibo/tuprolog/core/parsing/PrologVisitor.kt index c85559678..f7fa13ed3 100644 --- a/parser-core/src/jsMain/kotlin/it/unibo/tuprolog/core/parsing/PrologVisitor.kt +++ b/parser-core/src/jsMain/kotlin/it/unibo/tuprolog/core/parsing/PrologVisitor.kt @@ -1,7 +1,9 @@ package it.unibo.tuprolog.core.parsing -import it.unibo.tuprolog.core.* -import it.unibo.tuprolog.parser.* +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Real +import it.unibo.tuprolog.core.Scope +import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.parser.Associativity.FX import it.unibo.tuprolog.parser.Associativity.FY import it.unibo.tuprolog.parser.Associativity.INFIX @@ -12,8 +14,21 @@ import it.unibo.tuprolog.parser.Associativity.XFX import it.unibo.tuprolog.parser.Associativity.XFY import it.unibo.tuprolog.parser.Associativity.YF import it.unibo.tuprolog.parser.Associativity.YFX +import it.unibo.tuprolog.parser.ClauseContext +import it.unibo.tuprolog.parser.ExpressionContext +import it.unibo.tuprolog.parser.IntegerContext +import it.unibo.tuprolog.parser.ListContext +import it.unibo.tuprolog.parser.NumberContext +import it.unibo.tuprolog.parser.OuterContext +import it.unibo.tuprolog.parser.PrologParserVisitor +import it.unibo.tuprolog.parser.RealContext +import it.unibo.tuprolog.parser.SetContext +import it.unibo.tuprolog.parser.SingletonExpressionContext +import it.unibo.tuprolog.parser.SingletonTermContext +import it.unibo.tuprolog.parser.StructureContext +import it.unibo.tuprolog.parser.TermContext +import it.unibo.tuprolog.parser.VariableContext import org.gciatto.kt.math.BigInteger -import kotlin.collections.List class PrologVisitor : PrologParserVisitor() { private val scope: Scope = Scope.empty() @@ -34,8 +49,9 @@ class PrologVisitor : PrologParserVisitor() { INFIX.contains(ctx.associativity) -> visitInfixExpression(ctx) POSTFIX.contains(ctx.associativity) -> visitPostfixExpression(ctx) PREFIX.contains(ctx.associativity) -> visitPrefixExpression(ctx) - else -> throw IllegalArgumentException("Associativity unknown: ${ctx.associativity} INFIX=${INFIX} PREFIX=${PREFIX} POSTFIX=${POSTFIX}") - }, flatten(ctx.outers.asList()) + else -> throw IllegalArgumentException("Associativity unknown: ${ctx.associativity} INFIX=$INFIX PREFIX=$PREFIX POSTFIX=$POSTFIX") + }, + flatten(ctx.outers.asList()) ) } @@ -46,7 +62,6 @@ class PrologVisitor : PrologParserVisitor() { ctx.children[0].accept(this) as Term } - override fun visitInteger(ctx: IntegerContext): Term { val value = parseInteger(ctx) return Integer.of(value) @@ -79,10 +94,11 @@ class PrologVisitor : PrologParserVisitor() { } override fun visitStructure(ctx: StructureContext): Term { - if (ctx.isList) + if (ctx.isList) { return scope.listOf() - else if (ctx.isSet) + } else if (ctx.isSet) { return scope.setOf() + } return if (ctx.arity == 0) { scope.atomOf(ctx.functor.text) } else { @@ -103,10 +119,11 @@ class PrologVisitor : PrologParserVisitor() { } override fun visitSet(ctx: SetContext): Term { - return if (ctx.length == 1) + return if (ctx.length == 1) { scope.setOf(ctx.items[0].accept(this)) - else + } else { scope.setOf(ctx.items.map(this::visitExpression)) + } } private fun parseInteger(ctx: IntegerContext): BigInteger { @@ -154,9 +171,12 @@ class PrologVisitor : PrologParserVisitor() { } private fun visitPostfixExpression(ctx: ExpressionContext): Term = - postfix(ctx.left?.accept(this)!!, ctx.operators.map { - it.symbol.text - }) + postfix( + ctx.left?.accept(this)!!, + ctx.operators.map { + it.symbol.text + } + ) private fun postfix(term: Term, ops: List): Term { val operator = ops.iterator() @@ -168,9 +188,12 @@ class PrologVisitor : PrologParserVisitor() { } private fun visitPrefixExpression(ctx: ExpressionContext): Term = - prefix(ctx.right[0].accept(this), ctx.operators.map { - it.symbol.text - }) + prefix( + ctx.right[0].accept(this), + ctx.operators.map { + it.symbol.text + } + ) private fun prefix(term: Term, ops: List): Term { var i = ops.size - 1 @@ -218,7 +241,7 @@ class PrologVisitor : PrologParserVisitor() { return result } - //Prova refactoring List Kotlin + // Prova refactoring List Kotlin private fun infixRight(terms: List, ops: List): Term { var i = terms.size - 1 var j = ops.size - 1 @@ -248,7 +271,6 @@ class PrologVisitor : PrologParserVisitor() { private fun listOfOperators(ctx: ExpressionContext): List = ctx.operators.map { it.symbol.text } - private fun visitInfixRightAssociativeExpression(ctx: ExpressionContext): Term = infixRight(listOfOperands(ctx), listOfOperators(ctx)) @@ -262,4 +284,4 @@ class PrologVisitor : PrologParserVisitor() { private fun flatten(outers: List): List = flatten(outers.asSequence()).toList() -} \ No newline at end of file +} diff --git a/parser-core/src/jsMain/kotlin/it/unibo/tuprolog/core/parsing/TermParserExtensions.kt b/parser-core/src/jsMain/kotlin/it/unibo/tuprolog/core/parsing/TermParserExtensions.kt index 7f5677585..2a9c9741d 100644 --- a/parser-core/src/jsMain/kotlin/it/unibo/tuprolog/core/parsing/TermParserExtensions.kt +++ b/parser-core/src/jsMain/kotlin/it/unibo/tuprolog/core/parsing/TermParserExtensions.kt @@ -3,4 +3,4 @@ package it.unibo.tuprolog.core.parsing import it.unibo.tuprolog.core.operators.OperatorSet actual fun termParserWithOperators(operators: OperatorSet): TermParser = - TermParserImpl(operators) \ No newline at end of file + TermParserImpl(operators) diff --git a/parser-core/src/jsMain/kotlin/it/unibo/tuprolog/core/parsing/TermParserImpl.kt b/parser-core/src/jsMain/kotlin/it/unibo/tuprolog/core/parsing/TermParserImpl.kt index f226d6af6..eab2e517a 100644 --- a/parser-core/src/jsMain/kotlin/it/unibo/tuprolog/core/parsing/TermParserImpl.kt +++ b/parser-core/src/jsMain/kotlin/it/unibo/tuprolog/core/parsing/TermParserImpl.kt @@ -7,4 +7,4 @@ class TermParserImpl(override val defaultOperatorSet: OperatorSet) : TermParser override fun parseTerm(input: String, operators: OperatorSet): Term { return PrologParserFactory.parseExpression(input, operators).accept(PrologVisitor()) } -} \ No newline at end of file +} diff --git a/parser-core/src/jvmMain/kotlin/it/unibo/tuprolog/core/parsing/Conversions.kt b/parser-core/src/jvmMain/kotlin/it/unibo/tuprolog/core/parsing/Conversions.kt index 0b1262e76..7a38a2200 100644 --- a/parser-core/src/jvmMain/kotlin/it/unibo/tuprolog/core/parsing/Conversions.kt +++ b/parser-core/src/jvmMain/kotlin/it/unibo/tuprolog/core/parsing/Conversions.kt @@ -23,4 +23,4 @@ fun Specifier.toAssociativity(): Associativity = Specifier.XFX -> Associativity.XFX Specifier.YFX -> Associativity.YFX Specifier.XFY -> Associativity.XFY - } \ No newline at end of file + } diff --git a/parser-core/src/jvmMain/kotlin/it/unibo/tuprolog/core/parsing/DynamicOpListener.kt b/parser-core/src/jvmMain/kotlin/it/unibo/tuprolog/core/parsing/DynamicOpListener.kt index 16ae9c384..b6bc15870 100644 --- a/parser-core/src/jvmMain/kotlin/it/unibo/tuprolog/core/parsing/DynamicOpListener.kt +++ b/parser-core/src/jvmMain/kotlin/it/unibo/tuprolog/core/parsing/DynamicOpListener.kt @@ -68,5 +68,4 @@ class DynamicOpListener private constructor( return DynamicOpListener(parser, operatorDefinedCallback) } } - -} \ No newline at end of file +} diff --git a/parser-core/src/jvmMain/kotlin/it/unibo/tuprolog/core/parsing/Echo.kt b/parser-core/src/jvmMain/kotlin/it/unibo/tuprolog/core/parsing/Echo.kt index e651f6eff..9f983030e 100644 --- a/parser-core/src/jvmMain/kotlin/it/unibo/tuprolog/core/parsing/Echo.kt +++ b/parser-core/src/jvmMain/kotlin/it/unibo/tuprolog/core/parsing/Echo.kt @@ -1,4 +1,5 @@ @file:JvmName("Echo") + package it.unibo.tuprolog.core.parsing import it.unibo.tuprolog.core.TermFormatter @@ -13,4 +14,4 @@ fun main() { val term = parser.parseTerm(line!!) println(term.format(TermFormatter.prettyExpressions())) } -} \ No newline at end of file +} diff --git a/parser-core/src/jvmMain/kotlin/it/unibo/tuprolog/core/parsing/PrologExpressionVisitor.kt b/parser-core/src/jvmMain/kotlin/it/unibo/tuprolog/core/parsing/PrologExpressionVisitor.kt index 8c27aafce..c61c3fa95 100644 --- a/parser-core/src/jvmMain/kotlin/it/unibo/tuprolog/core/parsing/PrologExpressionVisitor.kt +++ b/parser-core/src/jvmMain/kotlin/it/unibo/tuprolog/core/parsing/PrologExpressionVisitor.kt @@ -5,10 +5,16 @@ import it.unibo.tuprolog.core.Scope import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.parser.PrologParser import it.unibo.tuprolog.parser.PrologParserBaseVisitor -import it.unibo.tuprolog.parser.dynamic.Associativity.* import it.unibo.tuprolog.parser.dynamic.Associativity.Companion.INFIX import it.unibo.tuprolog.parser.dynamic.Associativity.Companion.POSTFIX import it.unibo.tuprolog.parser.dynamic.Associativity.Companion.PREFIX +import it.unibo.tuprolog.parser.dynamic.Associativity.FX +import it.unibo.tuprolog.parser.dynamic.Associativity.FY +import it.unibo.tuprolog.parser.dynamic.Associativity.XF +import it.unibo.tuprolog.parser.dynamic.Associativity.XFX +import it.unibo.tuprolog.parser.dynamic.Associativity.XFY +import it.unibo.tuprolog.parser.dynamic.Associativity.YF +import it.unibo.tuprolog.parser.dynamic.Associativity.YFX import org.gciatto.kt.math.BigInteger class PrologExpressionVisitor : PrologParserBaseVisitor() { @@ -33,14 +39,14 @@ class PrologExpressionVisitor : PrologParserBaseVisitor() { PREFIX.contains(ctx.associativity) -> visitPrefixExpression(ctx) ctx.exception != null -> throw ctx.exception else -> throw IllegalArgumentException() // use kotlin's IllegalArgumentException - }, flatten(ctx.outers) + }, + flatten(ctx.outers) ) } override fun visitTerm(ctx: PrologParser.TermContext): Term = if (ctx.isExpr) visitExpression(ctx.expression()) else ctx.children[0].accept(this) - override fun visitInteger(ctx: PrologParser.IntegerContext): Term { val value = parseInteger(ctx) return scope.numOf(value) @@ -66,10 +72,11 @@ class PrologExpressionVisitor : PrologParserBaseVisitor() { } override fun visitStructure(ctx: PrologParser.StructureContext): Term { - if (ctx.isList) + if (ctx.isList) { return scope.listOf() - else if (ctx.isSet) + } else if (ctx.isSet) { return scope.setOf() + } return if (ctx.arity == 0) { scope.atomOf(ctx.functor.text) } else { @@ -90,10 +97,11 @@ class PrologExpressionVisitor : PrologParserBaseVisitor() { } override fun visitSet(ctx: PrologParser.SetContext): Term { - return if (ctx.length == 1) + return if (ctx.length == 1) { scope.setOf(ctx.items[0].accept(this)) - else + } else { scope.setOf(ctx.items.map(this::visitExpression)) + } } @Suppress("NullableBooleanElvis", "UNNECESSARY_SAFE_CALL") @@ -146,9 +154,12 @@ class PrologExpressionVisitor : PrologParserBaseVisitor() { } private fun visitPostfixExpression(ctx: PrologParser.ExpressionContext): Term = - postfix(ctx.left.accept(this), ctx.operators.map { - it.symbol.text - }) + postfix( + ctx.left.accept(this), + ctx.operators.map { + it.symbol.text + } + ) private fun postfix(term: Term, ops: List): Term { val operator = ops.iterator() @@ -160,9 +171,12 @@ class PrologExpressionVisitor : PrologParserBaseVisitor() { } private fun visitPrefixExpression(ctx: PrologParser.ExpressionContext): Term = - prefix(ctx.right[0].accept(this), ctx.operators.map { - it.symbol.text - }) + prefix( + ctx.right[0].accept(this), + ctx.operators.map { + it.symbol.text + } + ) private fun prefix(term: Term, ops: List): Term { var i = ops.size - 1 @@ -238,7 +252,6 @@ class PrologExpressionVisitor : PrologParserBaseVisitor() { private fun listOfOperators(ctx: PrologParser.ExpressionContext): List = ctx.operators.map { it.symbol.text } - private fun visitInfixRightAssociativeExpression(ctx: PrologParser.ExpressionContext): Term = infixRight(listOfOperands(ctx), listOfOperators(ctx)) @@ -252,4 +265,4 @@ class PrologExpressionVisitor : PrologParserBaseVisitor() { private fun flatten(outers: List): List = flatten(outers.asSequence()).toList() -} \ No newline at end of file +} diff --git a/parser-core/src/jvmMain/kotlin/it/unibo/tuprolog/core/parsing/PrologParserFactory.kt b/parser-core/src/jvmMain/kotlin/it/unibo/tuprolog/core/parsing/PrologParserFactory.kt index 11b4b43ff..842fa9fe1 100644 --- a/parser-core/src/jvmMain/kotlin/it/unibo/tuprolog/core/parsing/PrologParserFactory.kt +++ b/parser-core/src/jvmMain/kotlin/it/unibo/tuprolog/core/parsing/PrologParserFactory.kt @@ -3,7 +3,17 @@ package it.unibo.tuprolog.core.parsing import it.unibo.tuprolog.core.operators.OperatorSet import it.unibo.tuprolog.parser.PrologLexer import it.unibo.tuprolog.parser.PrologParser -import org.antlr.v4.runtime.* +import org.antlr.v4.runtime.ANTLRErrorListener +import org.antlr.v4.runtime.BailErrorStrategy +import org.antlr.v4.runtime.BaseErrorListener +import org.antlr.v4.runtime.BufferedTokenStream +import org.antlr.v4.runtime.CharStream +import org.antlr.v4.runtime.CharStreams +import org.antlr.v4.runtime.DefaultErrorStrategy +import org.antlr.v4.runtime.RecognitionException +import org.antlr.v4.runtime.Recognizer +import org.antlr.v4.runtime.Token +import org.antlr.v4.runtime.TokenStream import org.antlr.v4.runtime.atn.PredictionMode import org.antlr.v4.runtime.misc.ParseCancellationException import java.io.InputStream @@ -268,5 +278,4 @@ object PrologParserFactory { }.takeWhile { !it.isOver } .map { it.clause() } } - -} \ No newline at end of file +} diff --git a/parser-core/src/jvmMain/kotlin/it/unibo/tuprolog/core/parsing/TermParserExtensions.kt b/parser-core/src/jvmMain/kotlin/it/unibo/tuprolog/core/parsing/TermParserExtensions.kt index 7f5677585..2a9c9741d 100644 --- a/parser-core/src/jvmMain/kotlin/it/unibo/tuprolog/core/parsing/TermParserExtensions.kt +++ b/parser-core/src/jvmMain/kotlin/it/unibo/tuprolog/core/parsing/TermParserExtensions.kt @@ -3,4 +3,4 @@ package it.unibo.tuprolog.core.parsing import it.unibo.tuprolog.core.operators.OperatorSet actual fun termParserWithOperators(operators: OperatorSet): TermParser = - TermParserImpl(operators) \ No newline at end of file + TermParserImpl(operators) diff --git a/parser-core/src/jvmMain/kotlin/it/unibo/tuprolog/core/parsing/TermParserImpl.kt b/parser-core/src/jvmMain/kotlin/it/unibo/tuprolog/core/parsing/TermParserImpl.kt index 6b38829d6..200219845 100644 --- a/parser-core/src/jvmMain/kotlin/it/unibo/tuprolog/core/parsing/TermParserImpl.kt +++ b/parser-core/src/jvmMain/kotlin/it/unibo/tuprolog/core/parsing/TermParserImpl.kt @@ -8,4 +8,4 @@ class TermParserImpl(override val defaultOperatorSet: OperatorSet) : TermParser override fun parseTerm(input: String, operators: OperatorSet): Term { return PrologParserFactory.parseExpression(input, operators).accept(PrologExpressionVisitor()) } -} \ No newline at end of file +} From 9a434214354bbb1cc1844235ca4bc7790af593d2 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 14 Sep 2020 16:03:12 +0200 Subject: [PATCH 19/34] format code in :parser-js (+ enable test for hex numbers lexing) --- parser-js/build.gradle.kts | 13 +- .../kotlin/it/unibo/tuprolog/parser/Antlr4.kt | 12 +- .../it/unibo/tuprolog/parser/Antlr4Error.kt | 10 +- .../unibo/tuprolog/parser/Antlr4Extensions.kt | 2 +- .../it/unibo/tuprolog/parser/Associativity.kt | 12 -- .../{Antlr4Atn.kt => PredictionMode.kt} | 2 +- .../it/unibo/tuprolog/parser/PrologLexer.kt | 56 +++--- .../it/unibo/tuprolog/parser/PrologParser.kt | 12 -- .../tuprolog/parser/PrologParserListener.kt | 2 +- .../tuprolog/parser/PrologParserVisitor.kt | 2 +- .../it/unibo/tuprolog/parser/StringType.kt | 2 +- .../it/unibo/tuprolog/parser/TestLexerKt.kt | 190 +++++++++--------- .../unibo/tuprolog/parser/TestPrologLexer.kt | 43 ++-- .../unibo/tuprolog/parser/TestPrologParser.kt | 80 ++++---- 14 files changed, 207 insertions(+), 231 deletions(-) rename parser-js/src/main/kotlin/it/unibo/tuprolog/parser/{Antlr4Atn.kt => PredictionMode.kt} (99%) diff --git a/parser-js/build.gradle.kts b/parser-js/build.gradle.kts index 82b0b9b33..bca6b4050 100644 --- a/parser-js/build.gradle.kts +++ b/parser-js/build.gradle.kts @@ -1,8 +1,11 @@ +import node.Bugs +import node.NpmPublishExtension +import node.NpmPublishPlugin +import node.People import org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile -import java.io.File -import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinPackageJsonTask -import node.* import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsSetupTask +import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinPackageJsonTask +import java.io.File apply() @@ -115,7 +118,7 @@ configure { liftPackageJson { people = mutableListOf(People(gcName, gcEmail, gcUrl)) homepage = projectHomepage - bugs = Bugs(projectIssues,"gcEmail") + bugs = Bugs(projectIssues, "gcEmail") license = projectLicense name = "@tuprolog/$name" dependencies = dependencies?.mapKeys { @@ -160,4 +163,4 @@ tasks.getByName("sourcesJar") { from(it) } } -} \ No newline at end of file +} diff --git a/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/Antlr4.kt b/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/Antlr4.kt index 55a42f17c..daa634f47 100644 --- a/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/Antlr4.kt +++ b/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/Antlr4.kt @@ -1,12 +1,13 @@ @file:JsModule("antlr4") @file:JsNonModule + package it.unibo.tuprolog.parser /** * @see https://github.com/antlr/antlr4/blob/master/runtime/JavaScript/src/antlr4/Token.js */ open external class Token { - var source: dynamic; + var source: dynamic var type: Int; // token type of the token var channel: Int; // The parser ignores everything not on DEFAULT_CHANNEL var start: Int // optional; return -1 if not implemented. @@ -66,7 +67,6 @@ external class InputStream(input: dynamic, decodeToUnicodeCodePoints: Boolean) { */ open external class TokenStream - /** * https://github.com/antlr/antlr4/blob/master/runtime/JavaScript/src/antlr4/BufferedTokenStream.js */ @@ -91,7 +91,6 @@ open external class BufferedTokenStream(tokenSource: dynamic) : TokenStream { fun fill() } - /** * @see https://github.com/antlr/antlr4/blob/master/runtime/JavaScript/src/antlr4/CommonTokenStream.js */ @@ -108,16 +107,13 @@ external class CommonTokenStream(lexer: dynamic, channel: Int) : BufferedTokenSt /** * @see https://github.com/antlr/antlr4/blob/master/runtime/JavaScript/src/antlr4/RuleContext.js * */ - open external class RuleContext(parent: dynamic, invokingStateNumber: Int) { - fun accept(visitor: dynamic): T + fun accept(visitor: dynamic): T } - /** * @see https://github.com/antlr/antlr4/blob/master/runtime/JavaScript/src/antlr4/ParserRuleContext.js * */ - open external class ParserRuleContext(parent: dynamic, invokingStateNumber: Int) : RuleContext { val children: Array @@ -126,4 +122,4 @@ open external class ParserRuleContext(parent: dynamic, invokingStateNumber: Int) val stop: Token? val exception: dynamic -} \ No newline at end of file +} diff --git a/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/Antlr4Error.kt b/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/Antlr4Error.kt index d1d3c9bb7..847c4a9ae 100644 --- a/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/Antlr4Error.kt +++ b/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/Antlr4Error.kt @@ -5,15 +5,10 @@ package it.unibo.tuprolog.parser abstract external class ErrorStrategy { fun reset(recognizer: dynamic) - fun recoverInline(recognizer: dynamic) - fun recover(recognizer: dynamic) - fun sync(recognizer: dynamic) - fun inErrorRecoveryMode(recognizer: dynamic) - fun reportError(recognizer: dynamic) } @@ -40,16 +35,15 @@ external class DiagnosticErrorListener : ErrorListener { constructor() override fun syntaxError(recognizer: dynamic, offendingSymbol: dynamic, line: Int, column: Int, msg: String, e: dynamic) - } open external class RecognitionException(params: dynamic) : Throwable { val recognizer: dynamic val input: dynamic - val ctx: dynamic; + val ctx: dynamic val offendingToken: Token? fun getExpectedTokens(): dynamic } -open external class ParseCancellationException : Throwable \ No newline at end of file +open external class ParseCancellationException : Throwable diff --git a/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/Antlr4Extensions.kt b/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/Antlr4Extensions.kt index 76198e1a7..932a24e0f 100644 --- a/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/Antlr4Extensions.kt +++ b/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/Antlr4Extensions.kt @@ -11,4 +11,4 @@ fun isParseCancellationException(obj: dynamic): Boolean = jsClassName(obj) == "ParseCancellationException" fun isRecognitionException(obj: dynamic): Boolean = - jsClassName(obj) == "RecognitionException" \ No newline at end of file + jsClassName(obj) == "RecognitionException" diff --git a/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/Associativity.kt b/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/Associativity.kt index c68e575c2..45a68c9c9 100644 --- a/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/Associativity.kt +++ b/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/Associativity.kt @@ -3,17 +3,6 @@ package it.unibo.tuprolog.parser -//external enum class Associativity { -// XF, YF, XFX, XFY, YFX, FX, FY; -// -// companion object { -// val PREFIX: Array -// val NON_PREFIX: Array -// val INFIX: Array -// val POSTFIX: Array -// } -//} - external object Associativity { val XF: String val YF: String @@ -28,4 +17,3 @@ external object Associativity { val INFIX: Array val POSTFIX: Array } - diff --git a/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/Antlr4Atn.kt b/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/PredictionMode.kt similarity index 99% rename from parser-js/src/main/kotlin/it/unibo/tuprolog/parser/Antlr4Atn.kt rename to parser-js/src/main/kotlin/it/unibo/tuprolog/parser/PredictionMode.kt index 5356441b5..ee7d53a44 100644 --- a/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/Antlr4Atn.kt +++ b/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/PredictionMode.kt @@ -9,4 +9,4 @@ external object PredictionMode { val SLL: Int val LL: Int val LL_EXACT_AMBIG_DETECTION: Int -} \ No newline at end of file +} diff --git a/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/PrologLexer.kt b/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/PrologLexer.kt index aff74c75c..d92facfba 100644 --- a/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/PrologLexer.kt +++ b/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/PrologLexer.kt @@ -22,33 +22,33 @@ external class PrologLexer(input: dynamic) { companion object { val EOF: Int - val VARIABLE: Int - val INTEGER: Int - val HEX: Int - val OCT: Int - val BINARY: Int - val SIGN: Int - val FLOAT: Int - val CHAR: Int - val BOOL: Int - val LPAR: Int - val RPAR: Int - val LSQUARE: Int - val RSQUARE: Int - val EMPTY_LIST: Int - val LBRACE: Int - val RBRACE: Int - val EMPTY_SET: Int - val SQ_STRING: Int - val DQ_STRING: Int - val COMMA: Int - val PIPE: Int - val CUT: Int - val FULL_STOP: Int - val WHITE_SPACES: Int - val COMMENT: Int - val LINE_COMMENT: Int - val OPERATOR: Int - val ATOM: Int + val VARIABLE: Int + val INTEGER: Int + val HEX: Int + val OCT: Int + val BINARY: Int + val SIGN: Int + val FLOAT: Int + val CHAR: Int + val BOOL: Int + val LPAR: Int + val RPAR: Int + val LSQUARE: Int + val RSQUARE: Int + val EMPTY_LIST: Int + val LBRACE: Int + val RBRACE: Int + val EMPTY_SET: Int + val SQ_STRING: Int + val DQ_STRING: Int + val COMMA: Int + val PIPE: Int + val CUT: Int + val FULL_STOP: Int + val WHITE_SPACES: Int + val COMMENT: Int + val LINE_COMMENT: Int + val OPERATOR: Int + val ATOM: Int } } diff --git a/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/PrologParser.kt b/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/PrologParser.kt index e6eee74d1..3571e7a69 100644 --- a/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/PrologParser.kt +++ b/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/PrologParser.kt @@ -3,7 +3,6 @@ package it.unibo.tuprolog.parser - external class PrologParser(input: TokenStream) { companion object { val EOF: Int @@ -148,7 +147,6 @@ external class OpContext : ParserRuleContext { val priority: Int val associativity: String val symbol: Token - } external class TermContext : ParserRuleContext { @@ -172,7 +170,6 @@ external class NumberContext : ParserRuleContext { val isReal: Boolean fun integer(): IntegerContext fun real(): RealContext - } external class IntegerContext : ParserRuleContext { @@ -182,22 +179,16 @@ external class IntegerContext : ParserRuleContext { val isChar: Boolean val value: Token val sign: Token? - - } external class RealContext : ParserRuleContext { val value: Token val sign: Token? - - } external class VariableContext : ParserRuleContext { val isAnonymous: Boolean val value: Token - - } external class StructureContext : ParserRuleContext { @@ -221,7 +212,6 @@ external class ListContext : ParserRuleContext { val items: Array val tail: ExpressionContext? - fun expression(): ExpressionContext } @@ -230,7 +220,5 @@ external class SetContext : ParserRuleContext { val _expression: ExpressionContext val items: Array - fun expression(): ExpressionContext } - diff --git a/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/PrologParserListener.kt b/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/PrologParserListener.kt index 36d1dcb09..95fb218cd 100644 --- a/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/PrologParserListener.kt +++ b/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/PrologParserListener.kt @@ -37,4 +37,4 @@ open external class PrologParserListener { open fun exitList(ctx: ListContext) open fun enterSet(ctx: SetContext) open fun exitSet(ctx: SetContext) -} \ No newline at end of file +} diff --git a/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/PrologParserVisitor.kt b/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/PrologParserVisitor.kt index 125ddfcf6..7f0b7f575 100644 --- a/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/PrologParserVisitor.kt +++ b/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/PrologParserVisitor.kt @@ -21,4 +21,4 @@ open external class PrologParserVisitor { open fun visitStructure(ctx: StructureContext): T open fun visitList(ctx: ListContext): T open fun visitSet(ctx: SetContext): T -} \ No newline at end of file +} diff --git a/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/StringType.kt b/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/StringType.kt index 2fe221e93..c93f2a2c0 100644 --- a/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/StringType.kt +++ b/parser-js/src/main/kotlin/it/unibo/tuprolog/parser/StringType.kt @@ -6,4 +6,4 @@ package it.unibo.tuprolog.parser external enum class StringType { SINGLE_QUOTED, DOUBLE_QUOTED -} \ No newline at end of file +} diff --git a/parser-js/src/test/kotlin/it/unibo/tuprolog/parser/TestLexerKt.kt b/parser-js/src/test/kotlin/it/unibo/tuprolog/parser/TestLexerKt.kt index 7f7030dcd..0bdc0d636 100644 --- a/parser-js/src/test/kotlin/it/unibo/tuprolog/parser/TestLexerKt.kt +++ b/parser-js/src/test/kotlin/it/unibo/tuprolog/parser/TestLexerKt.kt @@ -60,181 +60,177 @@ class TestLexerKt { val lexer = PrologLexer(inputStream) val tokens = lexer.getAllTokens() - assertEquals(9,tokens.size) + assertEquals(9, tokens.size) tokens[0].let { - assertEquals("1",it.text) - assertEquals(PrologLexer.INTEGER,it.type) + assertEquals("1", it.text) + assertEquals(PrologLexer.INTEGER, it.type) } tokens[1].let { - assertEquals("+",it.text) - assertEquals(PrologLexer.SIGN,it.type) + assertEquals("+", it.text) + assertEquals(PrologLexer.SIGN, it.type) } tokens[2].let { - assertEquals("a",it.text) - assertEquals(PrologLexer.ATOM,it.type) + assertEquals("a", it.text) + assertEquals(PrologLexer.ATOM, it.type) } tokens[3].let { - assertEquals("+",it.text) - assertEquals(PrologLexer.SIGN,it.type) + assertEquals("+", it.text) + assertEquals(PrologLexer.SIGN, it.type) } tokens[4].let { - assertEquals("b",it.text) - assertEquals(PrologLexer.DQ_STRING,it.type) + assertEquals("b", it.text) + assertEquals(PrologLexer.DQ_STRING, it.type) } tokens[5].let { - assertEquals("+",it.text) - assertEquals(PrologLexer.SIGN,it.type) + assertEquals("+", it.text) + assertEquals(PrologLexer.SIGN, it.type) } tokens[6].let { - assertEquals("c",it.text) - assertEquals(PrologLexer.SQ_STRING,it.type) + assertEquals("c", it.text) + assertEquals(PrologLexer.SQ_STRING, it.type) } tokens[7].let { - assertEquals("-",it.text) - assertEquals(PrologLexer.SIGN,it.type) + assertEquals("-", it.text) + assertEquals(PrologLexer.SIGN, it.type) } tokens[8].let { - assertEquals("d",it.text) - assertEquals(PrologLexer.DQ_STRING,it.type) + assertEquals("d", it.text) + assertEquals(PrologLexer.DQ_STRING, it.type) } - } @Test - fun testVariables(){ + fun testVariables() { val input = "_ + A + _B is _1 + _a + _+" val inputStream = InputStream(input) val lexer = PrologLexer(inputStream) - lexer.addOperators("+","is") + lexer.addOperators("+", "is") val tokens = lexer.getAllTokens() - assertEquals(12,tokens.size) + assertEquals(12, tokens.size) tokens[0].let { - assertEquals("_",it.text) - assertEquals(PrologLexer.VARIABLE,it.type) + assertEquals("_", it.text) + assertEquals(PrologLexer.VARIABLE, it.type) } tokens[1].let { - assertEquals("+",it.text) - assertEquals(PrologLexer.SIGN,it.type) + assertEquals("+", it.text) + assertEquals(PrologLexer.SIGN, it.type) } tokens[2].let { - assertEquals("A",it.text) - assertEquals(PrologLexer.VARIABLE,it.type) + assertEquals("A", it.text) + assertEquals(PrologLexer.VARIABLE, it.type) } tokens[3].let { - assertEquals("+",it.text) - assertEquals(PrologLexer.SIGN,it.type) + assertEquals("+", it.text) + assertEquals(PrologLexer.SIGN, it.type) } tokens[4].let { - assertEquals("_B",it.text) - assertEquals(PrologLexer.VARIABLE,it.type) + assertEquals("_B", it.text) + assertEquals(PrologLexer.VARIABLE, it.type) } tokens[5].let { - assertEquals("is",it.text) - assertEquals(PrologLexer.OPERATOR,it.type) + assertEquals("is", it.text) + assertEquals(PrologLexer.OPERATOR, it.type) } tokens[6].let { - assertEquals("_1",it.text) - assertEquals(PrologLexer.VARIABLE,it.type) + assertEquals("_1", it.text) + assertEquals(PrologLexer.VARIABLE, it.type) } tokens[7].let { - assertEquals("+",it.text) - assertEquals(PrologLexer.SIGN,it.type) + assertEquals("+", it.text) + assertEquals(PrologLexer.SIGN, it.type) } tokens[8].let { - assertEquals("_a",it.text) - assertEquals(PrologLexer.VARIABLE,it.type) + assertEquals("_a", it.text) + assertEquals(PrologLexer.VARIABLE, it.type) } tokens[9].let { - assertEquals("+",it.text) - assertEquals(PrologLexer.SIGN,it.type) + assertEquals("+", it.text) + assertEquals(PrologLexer.SIGN, it.type) } tokens[10].let { - assertEquals("_",it.text) - assertEquals(PrologLexer.VARIABLE,it.type) + assertEquals("_", it.text) + assertEquals(PrologLexer.VARIABLE, it.type) } tokens[11].let { - assertEquals("+",it.text) - assertEquals(PrologLexer.SIGN,it.type) + assertEquals("+", it.text) + assertEquals(PrologLexer.SIGN, it.type) } } @Test - fun testOperators(){ + fun testOperators() { val input = "1 ? a is c :- d" val inputStream = InputStream(input) val lexer = PrologLexer(inputStream) - lexer.addOperators("?","is", ":-") + lexer.addOperators("?", "is", ":-") val tokens = lexer.getAllTokens() - assertEquals(7,tokens.size) + assertEquals(7, tokens.size) tokens[0].let { - assertEquals("1",it.text) - assertEquals(PrologLexer.INTEGER,it.type) + assertEquals("1", it.text) + assertEquals(PrologLexer.INTEGER, it.type) } tokens[1].let { - assertEquals("?",it.text) - assertEquals(PrologLexer.OPERATOR,it.type) + assertEquals("?", it.text) + assertEquals(PrologLexer.OPERATOR, it.type) } tokens[2].let { - assertEquals("a",it.text) - assertEquals(PrologLexer.ATOM,it.type) + assertEquals("a", it.text) + assertEquals(PrologLexer.ATOM, it.type) } tokens[3].let { - assertEquals("is",it.text) - assertEquals(PrologLexer.OPERATOR,it.type) + assertEquals("is", it.text) + assertEquals(PrologLexer.OPERATOR, it.type) } tokens[4].let { - assertEquals("c",it.text) - assertEquals(PrologLexer.ATOM,it.type) + assertEquals("c", it.text) + assertEquals(PrologLexer.ATOM, it.type) } tokens[5].let { - assertEquals(":-",it.text) - assertEquals(PrologLexer.OPERATOR,it.type) + assertEquals(":-", it.text) + assertEquals(PrologLexer.OPERATOR, it.type) } tokens[6].let { - assertEquals("d",it.text) - assertEquals(PrologLexer.ATOM,it.type) + assertEquals("d", it.text) + assertEquals(PrologLexer.ATOM, it.type) } } + @Test + fun testHex() { + val input = "0x29 + 3 + 0xAF" + val inputStream = InputStream(input) + val lexer = PrologLexer(inputStream) + val tokens = lexer.getAllTokens() + + assertEquals(5, tokens.size) -// @Test -// fun testHex(){ -// val input = "x29 + 3 + x58" -// val inputStream = InputStream(input) -// val lexer = PrologLexer(inputStream) -// val tokens = lexer.getAllTokens() -// -// assertEquals(5,tokens.size) -// -// tokens[0].let{ -// assertEquals("x29",it.text) -// assertEquals(PrologLexer.HEX,it.type) -// } -// tokens[1].let{ -// assertEquals("+",it.text) -// assertEquals(PrologLexer.SIGN,it.type) -// } -// tokens[2].let{ -// assertEquals("3",it.text) -// assertEquals(PrologLexer.INTEGER,it.type) -// } -// tokens[3].let{ -// assertEquals("+",it.text) -// assertEquals(PrologLexer.SIGN,it.type) -// } -// tokens[4].let{ -// assertEquals("x58",it.text) -// assertEquals(PrologLexer.HEX,it.type) -// } -// -// } - -} \ No newline at end of file + tokens[0].let { + assertEquals("0x29", it.text) + assertEquals(PrologLexer.HEX, it.type) + } + tokens[1].let { + assertEquals("+", it.text) + assertEquals(PrologLexer.SIGN, it.type) + } + tokens[2].let { + assertEquals("3", it.text) + assertEquals(PrologLexer.INTEGER, it.type) + } + tokens[3].let { + assertEquals("+", it.text) + assertEquals(PrologLexer.SIGN, it.type) + } + tokens[4].let { + assertEquals("0xAF", it.text) + assertEquals(PrologLexer.HEX, it.type) + } + } +} diff --git a/parser-js/src/test/kotlin/it/unibo/tuprolog/parser/TestPrologLexer.kt b/parser-js/src/test/kotlin/it/unibo/tuprolog/parser/TestPrologLexer.kt index 5831d3274..1a223cf37 100644 --- a/parser-js/src/test/kotlin/it/unibo/tuprolog/parser/TestPrologLexer.kt +++ b/parser-js/src/test/kotlin/it/unibo/tuprolog/parser/TestPrologLexer.kt @@ -5,21 +5,21 @@ import kotlin.test.assertEquals import kotlin.test.assertFalse import kotlin.test.assertTrue - class TestPrologLexer { @Test fun testInitialisation() { val lexer = PrologLexer(null) assertEquals("PrologLexer.g4", lexer.grammarFileName) val modeNames = arrayOf("DEFAULT_MODE") - lexer.modeNames.forEachIndexed{ - index,mode -> assertEquals(modeNames[index],mode) + lexer.modeNames.forEachIndexed { index, mode -> + assertEquals(modeNames[index], mode) } val channelNames = arrayOf("DEFAULT_TOKEN_CHANNEL", "HIDDEN") - lexer.channelNames.forEachIndexed{ - index,channel -> assertEquals(channelNames[index],channel) + lexer.channelNames.forEachIndexed { index, channel -> + assertEquals(channelNames[index], channel) } - val ruleNames = arrayOf("INTEGER", "HEX", "OCT", "BINARY", "SIGN", + val ruleNames = arrayOf( + "INTEGER", "HEX", "OCT", "BINARY", "SIGN", "FLOAT", "CHAR", "BOOL", "LPAR", "RPAR", "LSQUARE", "RSQUARE", "EMPTY_LIST", "LBRACE", "RBRACE", "EMPTY_SET", "VARIABLE", @@ -29,19 +29,20 @@ class TestPrologLexer { "OPERATOR", "ATOM", "Symbols", "Escapable", "DoubleSQ", "DoubleDQ", "OpSymbol", "Atom", "Ws", "OctDigit", "BinDigit", - "HexDigit", "Digit", "Zero") - lexer.ruleNames.forEachIndexed{ - index, rule -> assertEquals(ruleNames[index],rule) + "HexDigit", "Digit", "Zero" + ) + lexer.ruleNames.forEachIndexed { index, rule -> + assertEquals(ruleNames[index], rule) } } @Test - fun testLexerRecognizeOperators(){ + fun testLexerRecognizeOperators() { val lexer = PrologLexer("a ; b :- c") - val ops = listOf(";",":-","+") - lexer.addOperators(";",":-","+") - lexer.getOperators().forEachIndexed{ - index,op -> assertEquals(ops[index],op) + val ops = listOf(";", ":-", "+") + lexer.addOperators(";", ":-", "+") + lexer.getOperators().forEachIndexed { index, op -> + assertEquals(ops[index], op) } assertTrue(lexer.isOperator(";")) assertFalse(lexer.isOperator("jj")) @@ -49,19 +50,17 @@ class TestPrologLexer { assertFalse(lexer.isOperator("+a")) } - @Test - fun testLexerUnquote(){ + fun testLexerUnquote() { val lexer = PrologLexer(null) - assertEquals("String",lexer.unquote("'String'")) - assertEquals("sec''sds",lexer.unquote("'sec''sds'")) + assertEquals("String", lexer.unquote("'String'")) + assertEquals("sec''sds", lexer.unquote("'sec''sds'")) } @Test - fun testLexerEscape(){ + fun testLexerEscape() { val lexer = PrologLexer(null) lexer.escape("first\\nsec\\rthird", StringType.SINGLE_QUOTED) - assertEquals("first\nsec\rthird",lexer.escape("first\\nsec\\rthird", StringType.SINGLE_QUOTED)) + assertEquals("first\nsec\rthird", lexer.escape("first\\nsec\\rthird", StringType.SINGLE_QUOTED)) } - -} \ No newline at end of file +} diff --git a/parser-js/src/test/kotlin/it/unibo/tuprolog/parser/TestPrologParser.kt b/parser-js/src/test/kotlin/it/unibo/tuprolog/parser/TestPrologParser.kt index 6d0dadb57..42db86692 100644 --- a/parser-js/src/test/kotlin/it/unibo/tuprolog/parser/TestPrologParser.kt +++ b/parser-js/src/test/kotlin/it/unibo/tuprolog/parser/TestPrologParser.kt @@ -8,7 +8,7 @@ class TestPrologParser { private fun sequenceOfInputStreamFromStrings(vararg strings: String): Sequence { val res = mutableListOf() - strings.forEach{ + strings.forEach { res.add(InputStream(it)) } return res.asSequence() @@ -19,11 +19,11 @@ class TestPrologParser { val lexer = PrologLexer(InputStream("1")) PrologParser(CommonTokenStream(lexer)) assertEquals(PrologParser.VARIABLE, 1) - assertEquals(PrologParser.RULE_singletonTerm,0) + assertEquals(PrologParser.RULE_singletonTerm, 0) } @Test - fun testInteger(){ + fun testInteger() { val parser = PrologParser(CommonTokenStream(PrologLexer(InputStream("1")))) val tc = parser.singletonTerm().term() assertTrue(tc.isNum && !tc.isExpr && !tc.isList && !tc.isStruct && !tc.isVar) @@ -34,40 +34,43 @@ class TestPrologParser { } @Test - fun testReal(){ + fun testReal() { val parser = PrologParser(CommonTokenStream(PrologLexer(InputStream("1.1")))) val tc = parser.singletonTerm().term() assertTrue(tc.isNum && !tc.isExpr && !tc.isList && !tc.isStruct && !tc.isVar) val nc = tc.number() assertTrue(nc.isReal && !nc.isInt) val rc = nc.real() - assertEquals(rc.value.text.toDouble(),1.1) + assertEquals(rc.value.text.toDouble(), 1.1) } @Test - fun testAtom(){ + fun testAtom() { val parser = PrologParser(CommonTokenStream(PrologLexer(InputStream("a")))) val tc = parser.singletonTerm().term() assertTrue(tc.isStruct && !tc.isExpr && !tc.isList && !tc.isNum && !tc.isVar) val sc = tc.structure() - assertTrue(sc.arity == sc.args.count() && + assertTrue( + sc.arity == sc.args.count() && sc.arity == 0 && !sc.isList && !sc.isSet && !sc.isTruth && sc.functor.text == "a" && - sc.functor.type == PrologLexer.ATOM) + sc.functor.type == PrologLexer.ATOM + ) } @Test - fun testString(){ - sequenceOfInputStreamFromStrings("'a'","\"a\"").forEach{ + fun testString() { + sequenceOfInputStreamFromStrings("'a'", "\"a\"").forEach { val parser = PrologParser(CommonTokenStream(PrologLexer(it))) val tc = parser.singletonTerm().term() assertTrue(tc.isStruct && !tc.isExpr && !tc.isList && !tc.isNum && !tc.isVar) val s = tc.structure() - assertTrue(s.arity == s.args.count() && - s.arity == 0 && s.isString && !s.isList && !s.isTruth && + assertTrue( + s.arity == s.args.count() && + s.arity == 0 && s.isString && !s.isList && !s.isTruth && s.functor.text == "a" && (s.functor.type == PrologLexer.DQ_STRING || s.functor.type == PrologLexer.SQ_STRING) ) @@ -75,66 +78,76 @@ class TestPrologParser { } @Test - fun testTrue(){ + fun testTrue() { val parser = PrologParser(CommonTokenStream(PrologLexer(InputStream("true")))) val tc = parser.singletonTerm().term() assertTrue(tc.isStruct && !tc.isExpr && !tc.isList && !tc.isNum && !tc.isVar) val s = tc.structure() - assertTrue(s.arity == s.args.count() && + assertTrue( + s.arity == s.args.count() && s.isTruth && !s.isList && !s.isString && s.functor.text == "true" && - s.functor.type == PrologLexer.BOOL) + s.functor.type == PrologLexer.BOOL + ) } @Test - fun testFalse(){ + fun testFalse() { val parser = PrologParser(CommonTokenStream(PrologLexer(InputStream("fail")))) val tc = parser.singletonTerm().term() assertTrue(tc.isStruct && !tc.isExpr && !tc.isList && !tc.isNum && !tc.isVar) val s = tc.structure() - assertTrue(s.arity == s.args.count() && + assertTrue( + s.arity == s.args.count() && s.isTruth && !s.isList && !s.isString && s.functor.text == "fail" && - s.functor.type == PrologLexer.BOOL) + s.functor.type == PrologLexer.BOOL + ) } @Test - fun testEmptyList(){ - sequenceOfInputStreamFromStrings("[]","[ ]","[ ]").forEach{ + fun testEmptyList() { + sequenceOfInputStreamFromStrings("[]", "[ ]", "[ ]").forEach { val parser = PrologParser(CommonTokenStream(PrologLexer(it))) val tc = parser.singletonTerm().term() assertTrue(tc.isStruct && !tc.isExpr && !tc.isList && !tc.isNum && !tc.isVar) val s = tc.structure() - assertTrue(s.arity == s.args.count() && + assertTrue( + s.arity == s.args.count() && s.arity == 0 && - s.isList && !s.isTruth && !s.isString && - s.functor.type == PrologLexer.EMPTY_LIST ) + s.isList && !s.isTruth && !s.isString && + s.functor.type == PrologLexer.EMPTY_LIST + ) } } @Test - fun testVar(){ - sequenceOfInputStreamFromStrings("A","_A","_1A","A_").forEach{ + fun testVar() { + sequenceOfInputStreamFromStrings("A", "_A", "_1A", "A_").forEach { val parser = PrologParser(CommonTokenStream(PrologLexer(it))) val tc = parser.singletonTerm().term() assertTrue(tc.isVar && !tc.isExpr && !tc.isList && !tc.isNum && !tc.isStruct) val v = tc.variable() - assertTrue(!v.isAnonymous && + assertTrue( + !v.isAnonymous && v.value.text.contains("A") && - v.value.type == PrologLexer.VARIABLE) + v.value.type == PrologLexer.VARIABLE + ) } } @Test - fun testSingletonList(){ - sequenceOfInputStreamFromStrings("[1]", "[1 ]","[ 1]", "[ 1 ]").forEach{ + fun testSingletonList() { + sequenceOfInputStreamFromStrings("[1]", "[1 ]", "[ 1]", "[ 1 ]").forEach { val parser = PrologParser(CommonTokenStream(PrologLexer(it))) val tc = parser.singletonTerm().term() assertTrue(tc.isList && !tc.isExpr && !tc.isVar && !tc.isNum && !tc.isStruct) val l = tc.list() - assertTrue(l.length == l.items.count() && + assertTrue( + l.length == l.items.count() && l.length == 1 && - !l.hasTail && l.tail==null) + !l.hasTail && l.tail == null + ) val expr = l.items[0] assertTrue(expr.isTerm && expr.left != null && expr.operators.count() == 0 && expr.right.count() == 0) val t = expr.left!! @@ -142,8 +155,7 @@ class TestPrologParser { val n = t.number() assertTrue(n.isInt && !n.isReal) val i = n.integer() - assertEquals(i.value.text.toInt(),1) + assertEquals(i.value.text.toInt(), 1) } } - -} \ No newline at end of file +} From 66f94ba8fed9db34e6ee669fc13c4832a48964da Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 14 Sep 2020 16:07:05 +0200 Subject: [PATCH 20/34] format code in :parser-core --- parser-jvm/build.gradle.kts | 15 --------------- .../it/unibo/tuprolog/parser/ParsingException.kt | 11 +++++------ .../tuprolog/parser/dynamic/Associativity.kt | 2 +- 3 files changed, 6 insertions(+), 22 deletions(-) diff --git a/parser-jvm/build.gradle.kts b/parser-jvm/build.gradle.kts index c985badde..70304ab97 100644 --- a/parser-jvm/build.gradle.kts +++ b/parser-jvm/build.gradle.kts @@ -15,27 +15,12 @@ val ktFreeCompilerArgsJvm: String by project dependencies { antlr("org.antlr", "antlr4", Versions.org_antlr) - api("org.antlr", "antlr4-runtime", Versions.org_antlr) implementation(kotlin("stdlib-jdk8")) - -// testImplementation("pl.pragmatists:JUnitParams:1.1.1") -// testImplementation("junit", "junit", "4.13") testImplementation(kotlin("test-junit")) } -// -//publishing { -// publications.forEach { -// println("${project.name} publication: ${it.name}") -// } -//} -// -//components.forEach { -// println("${project.name} component: ${it.name}") -//} - configure { targetCompatibility = JavaVersion.valueOf("VERSION_1_$javaVersion") sourceCompatibility = JavaVersion.valueOf("VERSION_1_$javaVersion") diff --git a/parser-jvm/src/main/kotlin/it/unibo/tuprolog/parser/ParsingException.kt b/parser-jvm/src/main/kotlin/it/unibo/tuprolog/parser/ParsingException.kt index 3d2154c16..02b31c1f6 100644 --- a/parser-jvm/src/main/kotlin/it/unibo/tuprolog/parser/ParsingException.kt +++ b/parser-jvm/src/main/kotlin/it/unibo/tuprolog/parser/ParsingException.kt @@ -11,11 +11,10 @@ class ParsingException( override fun toString(): String { return "ParsingException{" + - "message='" + message!!.replace("\\n", "\\\\n") + '\'' + - ", line=" + line + - ", column=" + column + - ", offendingSymbol='" + offendingSymbol + '\'' + - '}' + "message='" + message!!.replace("\\n", "\\\\n") + '\'' + + ", line=" + line + + ", column=" + column + + ", offendingSymbol='" + offendingSymbol + '\'' + + '}' } - } \ No newline at end of file diff --git a/parser-jvm/src/main/kotlin/it/unibo/tuprolog/parser/dynamic/Associativity.kt b/parser-jvm/src/main/kotlin/it/unibo/tuprolog/parser/dynamic/Associativity.kt index df2c18018..f55919edc 100644 --- a/parser-jvm/src/main/kotlin/it/unibo/tuprolog/parser/dynamic/Associativity.kt +++ b/parser-jvm/src/main/kotlin/it/unibo/tuprolog/parser/dynamic/Associativity.kt @@ -1,6 +1,6 @@ package it.unibo.tuprolog.parser.dynamic -import java.util.* +import java.util.EnumSet import java.util.stream.Stream enum class Associativity { From b153124c72b4d446716a1cd621635fe2453ee3e5 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 14 Sep 2020 16:07:17 +0200 Subject: [PATCH 21/34] kotlin.mpp.stability.nowarn=true --- gradle.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/gradle.properties b/gradle.properties index 4e7a87bae..ffd96a231 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,6 @@ org.gradle.console=plain kotlin.code.style=official +kotlin.mpp.stability.nowarn=true systemProp.org.gradle.internal.http.connectionTimeout=180000 systemProp.org.gradle.internal.http.socketTimeout=180000 From 00b4b7d699d0c1b360f82bd56de918ac0a1d93f4 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 14 Sep 2020 16:18:57 +0200 Subject: [PATCH 22/34] revert formatting of solve-streams/src/commonMain --- .../tuprolog/solve/SolverStrategiesTest.kt | 1 + .../unibo/tuprolog/solve/StreamsSolverTest.kt | 1 + .../tuprolog/solve/solver/SolverUtilsTest.kt | 39 ++++--------------- .../solver/fsm/AlreadyExecutedStateTest.kt | 1 + .../solver/fsm/StateMachineExecutorTest.kt | 7 +--- .../solver/fsm/impl/AbstractTimedStateTest.kt | 5 +-- .../fsm/impl/StateGoalEvaluationTest.kt | 1 + .../solve/solver/fsm/impl/StateInitTest.kt | 2 +- .../solver/fsm/impl/StateRuleSelectionTest.kt | 20 ++++------ .../StateIntegrationTesting.kt | 5 +-- .../testutils/StateGoalEvaluationUtils.kt | 14 +++---- .../fsm/impl/testutils/StateInitUtils.kt | 2 +- .../solver/fsm/impl/testutils/StateUtils.kt | 6 +-- .../solve/stdlib/primitive/CallTest.kt | 1 + .../solve/stdlib/primitive/ConjunctionTest.kt | 10 +---- .../solve/stdlib/primitive/NotTest.kt | 13 ++----- .../CutAndConjunctionIntegrationTest.kt | 6 +-- .../stdlib/primitive/testutils/CallUtils.kt | 10 ++--- .../stdlib/primitive/testutils/CatchUtils.kt | 9 +++-- .../primitive/testutils/ConjunctionUtils.kt | 1 + .../primitive/testutils/PrimitiveUtils.kt | 2 +- .../solve/systemtest/TestStreamsAbolish.kt | 4 +- .../solve/systemtest/TestStreamsAnd.kt | 13 +++++-- .../solve/systemtest/TestStreamsArg.kt | 13 +++++-- .../solve/systemtest/TestStreamsArith.kt | 12 ++++-- .../solve/systemtest/TestStreamsAssertA.kt | 5 ++- .../solve/systemtest/TestStreamsAssertZ.kt | 15 ++++--- .../solve/systemtest/TestStreamsAtom.kt | 13 +++++-- .../solve/systemtest/TestStreamsAtomic.kt | 13 +++++-- .../solve/systemtest/TestStreamsCall.kt | 8 ++-- .../systemtest/TestStreamsCatchAndThrow.kt | 6 +-- .../solve/systemtest/TestStreamsClause.kt | 4 +- .../solve/systemtest/TestStreamsCompound.kt | 4 +- .../solve/systemtest/TestStreamsCopyTerm.kt | 6 +-- .../solve/systemtest/TestStreamsCut.kt | 4 +- .../solve/systemtest/TestStreamsFail.kt | 6 +-- .../solve/systemtest/TestStreamsFindAll.kt | 13 +++++-- .../solve/systemtest/TestStreamsFloat.kt | 6 +-- .../solve/systemtest/TestStreamsFunctor.kt | 15 ++++--- .../solve/systemtest/TestStreamsIfThen.kt | 4 +- .../solve/systemtest/TestStreamsIfThenElse.kt | 4 +- .../solve/systemtest/TestStreamsInteger.kt | 13 +++++-- .../solve/systemtest/TestStreamsIs.kt | 8 ++-- .../solve/systemtest/TestStreamsNonVar.kt | 13 +++++-- .../systemtest/TestStreamsNotProvable.kt | 8 ++-- .../solve/systemtest/TestStreamsNotUnify.kt | 14 +++++-- .../solve/systemtest/TestStreamsNumber.kt | 3 +- .../solve/systemtest/TestStreamsOnce.kt | 6 +-- .../solve/systemtest/TestStreamsOr.kt | 15 +++++-- .../solve/systemtest/TestStreamsRepeat.kt | 6 +-- .../solve/systemtest/TestStreamsRetract.kt | 4 +- .../solve/systemtest/TestStreamsSolver.kt | 8 +--- .../solve/systemtest/TestStreamsTerm.kt | 5 ++- .../solve/systemtest/TestStreamsTrue.kt | 6 +-- .../solve/systemtest/TestStreamsUnify.kt | 14 +++++-- .../solve/testutils/SolverTestUtils.kt | 2 +- 56 files changed, 236 insertions(+), 213 deletions(-) diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/SolverStrategiesTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/SolverStrategiesTest.kt index 3a34a6666..b136f2a80 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/SolverStrategiesTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/SolverStrategiesTest.kt @@ -42,4 +42,5 @@ internal class SolverStrategiesTest { assertTrue { prologStandard.successCheckStrategy(Truth.TRUE, aContext) } assertFalse { prologStandard.successCheckStrategy(Atom.of("ciao"), aContext) } } + } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/StreamsSolverTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/StreamsSolverTest.kt index 9a808b721..c9659157f 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/StreamsSolverTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/StreamsSolverTest.kt @@ -21,4 +21,5 @@ internal class StreamsSolverTest { assertEquals(Theory.empty(), toBeTested.staticKb) assertEquals(Theory.empty(), toBeTested.dynamicKb) } + } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/SolverUtilsTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/SolverUtilsTest.kt index fb5071205..9316518bb 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/SolverUtilsTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/SolverUtilsTest.kt @@ -1,33 +1,12 @@ package it.unibo.tuprolog.solve.solver -import it.unibo.tuprolog.core.Atom -import it.unibo.tuprolog.core.Clause -import it.unibo.tuprolog.core.Integer -import it.unibo.tuprolog.core.Scope -import it.unibo.tuprolog.core.Struct -import it.unibo.tuprolog.core.Substitution -import it.unibo.tuprolog.core.Truth -import it.unibo.tuprolog.core.Tuple -import it.unibo.tuprolog.core.Var -import it.unibo.tuprolog.solve.DummyInstances -import it.unibo.tuprolog.solve.FlagStore -import it.unibo.tuprolog.solve.Signature -import it.unibo.tuprolog.solve.currentTimeInstant +import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.solve.* import it.unibo.tuprolog.solve.exception.HaltException -import it.unibo.tuprolog.solve.extractSignature -import it.unibo.tuprolog.solve.halt import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.no import it.unibo.tuprolog.solve.primitive.Solve -import it.unibo.tuprolog.solve.yes import it.unibo.tuprolog.theory.Theory -import kotlin.test.Test -import kotlin.test.assertEquals -import kotlin.test.assertFailsWith -import kotlin.test.assertFalse -import kotlin.test.assertSame -import kotlin.test.assertTrue -import kotlin.test.fail +import kotlin.test.* /** * Test class for SolverUtils.kt @@ -125,13 +104,11 @@ internal class SolverUtilsTest { @Test fun moreThanOneWorksLazily() { assertTrue { - moreThanOne( - sequence { - yield(1) - yield(1) - fail("Should not evaluate entire sequence") - } - ) + moreThanOne(sequence { + yield(1) + yield(1) + fail("Should not evaluate entire sequence") + }) } } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/AlreadyExecutedStateTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/AlreadyExecutedStateTest.kt index 4d7dc3801..970aa01d8 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/AlreadyExecutedStateTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/AlreadyExecutedStateTest.kt @@ -47,4 +47,5 @@ internal class AlreadyExecutedStateTest { assertSame(correct.wrappedState, toBeTested.wrappedState) } + } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/StateMachineExecutorTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/StateMachineExecutorTest.kt index 091319f6e..473f12e72 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/StateMachineExecutorTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/StateMachineExecutorTest.kt @@ -12,12 +12,7 @@ import it.unibo.tuprolog.solve.solver.fsm.testutils.StateMachineExecutorUtils.th import it.unibo.tuprolog.solve.solver.fsm.testutils.StateMachineExecutorUtils.threeShotStateAlreadyExecuted import it.unibo.tuprolog.solve.solver.fsm.testutils.StateMachineExecutorUtils.toBehavedState import it.unibo.tuprolog.solve.solver.fsm.testutils.StateMachineExecutorUtils.twoAlternativeState -import kotlin.test.Test -import kotlin.test.assertEquals -import kotlin.test.assertFalse -import kotlin.test.assertSame -import kotlin.test.assertTrue -import kotlin.test.fail +import kotlin.test.* /** * Test class for [StateMachineExecutor] diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/AbstractTimedStateTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/AbstractTimedStateTest.kt index 096c01c0d..e90b015e9 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/AbstractTimedStateTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/AbstractTimedStateTest.kt @@ -1,10 +1,7 @@ package it.unibo.tuprolog.solve.solver.fsm.impl import it.unibo.tuprolog.core.Truth -import it.unibo.tuprolog.solve.ExecutionContext -import it.unibo.tuprolog.solve.TimeDuration -import it.unibo.tuprolog.solve.TimeInstant -import it.unibo.tuprolog.solve.currentTimeInstant +import it.unibo.tuprolog.solve.* import it.unibo.tuprolog.solve.exception.TimeOutException import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.solver.fsm.State diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateGoalEvaluationTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateGoalEvaluationTest.kt index b93faea4a..66ca8977e 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateGoalEvaluationTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateGoalEvaluationTest.kt @@ -62,4 +62,5 @@ internal class StateGoalEvaluationTest { assertOnlyOneNextState(nextStates) } } + } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateInitTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateInitTest.kt index c99126169..662e34a3a 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateInitTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateInitTest.kt @@ -5,8 +5,8 @@ import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.core.Truth import it.unibo.tuprolog.core.prepareForExecution import it.unibo.tuprolog.solve.DummyInstances -import it.unibo.tuprolog.solve.SolverStrategies import it.unibo.tuprolog.solve.primitive.Solve +import it.unibo.tuprolog.solve.SolverStrategies import it.unibo.tuprolog.solve.solver.fsm.impl.testutils.StateInitUtils.allRequests import it.unibo.tuprolog.solve.solver.fsm.impl.testutils.StateInitUtils.allWellFormedGoalRequests import it.unibo.tuprolog.solve.solver.fsm.impl.testutils.StateInitUtils.nonWellFormedGoalRequest diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateRuleSelectionTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateRuleSelectionTest.kt index 38df49d8b..357a9128c 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateRuleSelectionTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateRuleSelectionTest.kt @@ -2,10 +2,10 @@ package it.unibo.tuprolog.solve.solver.fsm.impl import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.dsl.theory.prolog +import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.extractSignature import it.unibo.tuprolog.solve.library.Libraries import it.unibo.tuprolog.solve.library.Library -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.solver.StreamsExecutionContext import it.unibo.tuprolog.solve.solver.fsm.FinalState import it.unibo.tuprolog.solve.solver.fsm.impl.testutils.StateRuleSelectionUtils.createRequest @@ -33,20 +33,15 @@ internal class StateRuleSelectionTest { private val theQuery = prolog { "f"(theQueryVariable) } /** A Solve.Request with three databases and three different facts, to test how they should be used/combined in searching */ - private val threeDBSolveRequest = Solve.Request( - theQuery.extractSignature(), - theQuery.argsList, + private val threeDBSolveRequest = Solve.Request(theQuery.extractSignature(), theQuery.argsList, StreamsExecutionContext( - libraries = Libraries( - Library.aliased( - alias = "testLib", - theory = prolog { theory({ "f"("a") }) } - ) - ), + libraries = Libraries(Library.aliased( + alias = "testLib", + theory = prolog { theory({ "f"("a") }) } + )), staticKb = prolog { theory({ "f"("b") }) }, dynamicKb = prolog { theory({ "f"("c") }) } - ) - ) + )) @Test fun noMatchingRulesFoundMakeItGoIntoFalseState() { @@ -120,4 +115,5 @@ internal class StateRuleSelectionTest { } } } + } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/integrationtest/StateIntegrationTesting.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/integrationtest/StateIntegrationTesting.kt index d1ae7a313..807fb5f59 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/integrationtest/StateIntegrationTesting.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/integrationtest/StateIntegrationTesting.kt @@ -8,6 +8,7 @@ import it.unibo.tuprolog.solve.PrologStandardExampleTheories.prologStandardExamp import it.unibo.tuprolog.solve.PrologStandardExampleTheories.prologStandardExampleWithCutTheory import it.unibo.tuprolog.solve.PrologStandardExampleTheories.prologStandardExampleWithCutTheoryNotableGoalToSolution import it.unibo.tuprolog.solve.Solution +import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.TestingClauseTheories.customReverseListTheory import it.unibo.tuprolog.solve.TestingClauseTheories.customReverseListTheoryNotableGoalToSolution import it.unibo.tuprolog.solve.TestingClauseTheories.cutConjunctionAndBacktrackingTheory @@ -22,7 +23,6 @@ import it.unibo.tuprolog.solve.TestingClauseTheories.simpleFactTheory import it.unibo.tuprolog.solve.TestingClauseTheories.simpleFactTheoryNotableGoalToSolutions import it.unibo.tuprolog.solve.assertSolutionEquals import it.unibo.tuprolog.solve.extractSignature -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.solver.StreamsExecutionContext import it.unibo.tuprolog.solve.solver.fsm.FinalState import it.unibo.tuprolog.solve.solver.fsm.State @@ -67,8 +67,7 @@ internal class StateIntegrationTesting { finalState.solve.solution.let { // cleanUp as in StreamsSolver (it as? Solution.Yes)?.copy(substitution = it.substitution.filter { _, t -> t !is Var }) ?: it - } - ) + }) } } } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateGoalEvaluationUtils.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateGoalEvaluationUtils.kt index c92a5e7f9..e8b305a4f 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateGoalEvaluationUtils.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateGoalEvaluationUtils.kt @@ -1,6 +1,7 @@ package it.unibo.tuprolog.solve.solver.fsm.impl.testutils import it.unibo.tuprolog.core.Var +import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.StreamsSolver import it.unibo.tuprolog.solve.exception.HaltException import it.unibo.tuprolog.solve.exception.PrologError @@ -9,7 +10,6 @@ import it.unibo.tuprolog.solve.exception.error.SystemError import it.unibo.tuprolog.solve.exception.error.TypeError import it.unibo.tuprolog.solve.primitive.Primitive import it.unibo.tuprolog.solve.primitive.PrimitiveWrapper -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.solver.SideEffectManagerImpl import it.unibo.tuprolog.solve.solver.StreamsExecutionContext import it.unibo.tuprolog.solve.solver.fsm.impl.StateEnd @@ -45,15 +45,15 @@ internal object StateGoalEvaluationUtils { internal val primitiveRequestToNextStateList by lazy { mapOf( createRequestForPrimitiveResponding { sequenceOf(it.replySuccess(it.context.substitution)) } - to listOf(StateEnd.True::class), + to listOf(StateEnd.True::class), createRequestForPrimitiveResponding { sequenceOf(it.replyFail()) } - to listOf(StateEnd.False::class), + to listOf(StateEnd.False::class), createRequestForPrimitiveResponding { sequenceOf(it.replyWith(true), it.replyWith(false)) } - to listOf(StateEnd.True::class, StateEnd.False::class), + to listOf(StateEnd.True::class, StateEnd.False::class), createRequestForPrimitiveResponding { sequenceOf(it.replyException(HaltException(context = it.context))) } - to listOf(StateEnd.Halt::class), + to listOf(StateEnd.Halt::class), createRequestForPrimitiveResponding { throw HaltException(context = it.context) } - to listOf(StateEnd.Halt::class), + to listOf(StateEnd.Halt::class), createRequestForPrimitiveResponding { sequence { yieldAll(StreamsSolver.solveToResponses(createRequestForPrimitiveResponding { throw HaltException(context = it.context) })) @@ -85,4 +85,4 @@ internal object StateGoalEvaluationUtils { /** All requests that should make [StateGoalEvaluation] transit in [StateRuleSelection] */ internal val nonPrimitiveRequests by lazy { StateInitUtils.allWellFormedGoalRequests } -} +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateInitUtils.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateInitUtils.kt index d9a4ea462..5c9583f95 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateInitUtils.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateInitUtils.kt @@ -62,7 +62,7 @@ internal object StateInitUtils { /** Collection of [Solve.Request] that should pass [StateInit] going into [StateGoalEvaluation] */ internal val allWellFormedGoalRequests by lazy { wellFormedGoalRequestsNeedingPreparationForExecution + - wellFormedGoalRequestsNotNeedingPreparationForExecution + wellFormedGoalRequestsNotNeedingPreparationForExecution } /** Solve request with non well-formed goal */ diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateUtils.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateUtils.kt index 615f85971..b63394add 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateUtils.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateUtils.kt @@ -21,8 +21,7 @@ internal object StateUtils { /** Utility function to assert that there's only one next state of given type */ internal inline fun assertOnlyOneNextState(actualNextStateSequence: Sequence) { assertEquals( - 1, - actualNextStateSequence.count(), + 1, actualNextStateSequence.count(), "Expected only one state, but ${actualNextStateSequence.toList()}" ) assertTrue { actualNextStateSequence.single() is S } @@ -51,5 +50,6 @@ internal object StateUtils { internal fun Solve.getSideEffectsManager(): SideEffectManager = when (this) { is Solve.Response -> sideEffectManager is Solve.Request<*> -> context.getSideEffectManager() - } ?: fail("SideEffectManager is not present in $this") + } ?: fail("SideEffectManager is not present in ${this}") + } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/CallTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/CallTest.kt index 326660878..f0a31cac4 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/CallTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/CallTest.kt @@ -7,6 +7,7 @@ import it.unibo.tuprolog.solve.stdlib.primitive.testutils.CallUtils.assertErrorC import it.unibo.tuprolog.solve.stdlib.primitive.testutils.CallUtils.requestSolutionMap import it.unibo.tuprolog.solve.stdlib.primitive.testutils.CallUtils.requestToErrorSolutionMap import it.unibo.tuprolog.solve.stdlib.primitive.testutils.CallUtils.requestToSolutionOfCallWithCut +import it.unibo.tuprolog.solve.stdlib.primitive.testutils.PrimitiveUtils.deepCause import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ConjunctionTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ConjunctionTest.kt index b3add8c5e..f819ef14a 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ConjunctionTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ConjunctionTest.kt @@ -1,12 +1,9 @@ package it.unibo.tuprolog.solve.stdlib.primitive import it.unibo.tuprolog.dsl.theory.prolog -import it.unibo.tuprolog.solve.ExecutionContext -import it.unibo.tuprolog.solve.assertSolutionEquals -import it.unibo.tuprolog.solve.extractSignature +import it.unibo.tuprolog.solve.* import it.unibo.tuprolog.solve.library.Libraries import it.unibo.tuprolog.solve.library.Library -import it.unibo.tuprolog.solve.no import it.unibo.tuprolog.solve.primitive.PrimitiveWrapper import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.solver.StreamsExecutionContext @@ -16,7 +13,6 @@ import it.unibo.tuprolog.solve.stdlib.primitive.testutils.ConjunctionUtils.trueA import it.unibo.tuprolog.solve.stdlib.primitive.testutils.ConjunctionUtils.twoMatchesDB import it.unibo.tuprolog.solve.stdlib.primitive.testutils.PrimitiveUtils.assertOnlyOneSolution import it.unibo.tuprolog.solve.testutils.SolverTestUtils.createSolveRequest -import it.unibo.tuprolog.solve.yes import kotlin.test.Test import kotlin.collections.listOf as ktListOf @@ -68,9 +64,7 @@ internal class ConjunctionTest { val goal = "left" and "right" val request = Solve.Request( - goal.extractSignature(), - goal.argsList, - StreamsExecutionContext( + goal.extractSignature(), goal.argsList, StreamsExecutionContext( substitution = preRequestSubstitution, libraries = Libraries( Library.aliased( diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/NotTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/NotTest.kt index dfa5058e8..d51b9494b 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/NotTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/NotTest.kt @@ -2,13 +2,9 @@ package it.unibo.tuprolog.solve.stdlib.primitive import it.unibo.tuprolog.dsl.prolog import it.unibo.tuprolog.dsl.theory.PrologScopeWithTheories -import it.unibo.tuprolog.solve.DummyInstances -import it.unibo.tuprolog.solve.assertSolutionEquals +import it.unibo.tuprolog.solve.* import it.unibo.tuprolog.solve.exception.error.TypeError -import it.unibo.tuprolog.solve.halt -import it.unibo.tuprolog.solve.no import it.unibo.tuprolog.solve.testutils.SolverTestUtils.createSolveRequest -import it.unibo.tuprolog.solve.yes import kotlin.test.Ignore import kotlin.test.Test @@ -71,11 +67,10 @@ internal class NotTest { DummyInstances.executionContext, Not.signature, TypeError.Expected.CALLABLE, - prolog { numOf(1) } - ) + prolog { numOf(1) }) ) - ), - solutions + ), solutions ) } + } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/integrationtest/CutAndConjunctionIntegrationTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/integrationtest/CutAndConjunctionIntegrationTest.kt index 4cdf04259..eff16eb3d 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/integrationtest/CutAndConjunctionIntegrationTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/integrationtest/CutAndConjunctionIntegrationTest.kt @@ -31,8 +31,7 @@ internal class CutAndConjunctionIntegrationTest { modifiedSimpleFactDatabaseGoals.forEach { (goal, solutionList) -> val request = createSolveRequest( - goal, - simpleFactTheory, + goal, simpleFactTheory, mapOf(Conjunction.descriptionPair, Cut.descriptionPair) ) val solutions = Conjunction.wrappedImplementation(request).map { it.solution }.asIterable() @@ -52,8 +51,7 @@ internal class CutAndConjunctionIntegrationTest { modifiedSimpleFactDatabaseGoals.forEach { (goal, solutionList) -> val request = createSolveRequest( - goal, - simpleFactTheory, + goal, simpleFactTheory, mapOf(Conjunction.descriptionPair, Cut.descriptionPair) ) val solutions = Conjunction.wrappedImplementation(request).map { it.solution }.asIterable() diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/CallUtils.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/CallUtils.kt index 73168e62c..deddd4ee6 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/CallUtils.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/CallUtils.kt @@ -1,11 +1,9 @@ package it.unibo.tuprolog.solve.stdlib.primitive.testutils import it.unibo.tuprolog.dsl.theory.prolog -import it.unibo.tuprolog.solve.DummyInstances -import it.unibo.tuprolog.solve.Solution +import it.unibo.tuprolog.solve.* import it.unibo.tuprolog.solve.TestingClauseTheories.simpleFactTheory import it.unibo.tuprolog.solve.TestingClauseTheories.simpleFactTheoryNotableGoalToSolutions -import it.unibo.tuprolog.solve.changeQueriesTo import it.unibo.tuprolog.solve.exception.PrologError import it.unibo.tuprolog.solve.exception.error.InstantiationError import it.unibo.tuprolog.solve.exception.error.TypeError @@ -63,8 +61,7 @@ internal object CallUtils { }.toTypedArray() ).mapKeys { (query, _) -> createSolveRequest( - query, - database = simpleFactTheory, + query, database = simpleFactTheory, primitives = mapOf(*ktListOf(Call, Cut, Conjunction).map { it.descriptionPair }.toTypedArray()) ) } @@ -121,8 +118,7 @@ internal object CallUtils { }.toTypedArray() ).mapKeys { (query, _) -> createSolveRequest( - query, - database = simpleFactTheory, + query, database = simpleFactTheory, primitives = mapOf(*ktListOf(Call, Cut, Conjunction).map { it.descriptionPair }.toTypedArray()) ) } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/CatchUtils.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/CatchUtils.kt index 55cff3573..083159cff 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/CatchUtils.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/CatchUtils.kt @@ -11,6 +11,8 @@ import it.unibo.tuprolog.solve.stdlib.primitive.Catch import it.unibo.tuprolog.solve.stdlib.primitive.Conjunction import it.unibo.tuprolog.solve.stdlib.primitive.Throw import it.unibo.tuprolog.solve.testutils.SolverTestUtils.createSolveRequest +import it.unibo.tuprolog.solve.changeQueriesTo +import it.unibo.tuprolog.solve.yes import kotlin.collections.listOf as ktListOf /** @@ -58,9 +60,9 @@ internal object CatchUtils { prolog { Catch.functor(callRequest.arguments.single(), "X", true).run { createSolveRequest(this, callRequest.context.libraries.theory, updatedPrimitives) to - solutions.map { - yes("X" to (it.exception as PrologError).errorStruct) - } + solutions.map { + yes("X" to (it.exception as PrologError).errorStruct) + } } } }.toTypedArray() @@ -91,4 +93,5 @@ internal object CatchUtils { ) to solutionList } } + } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/ConjunctionUtils.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/ConjunctionUtils.kt index 379d2932f..fa3a87756 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/ConjunctionUtils.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/ConjunctionUtils.kt @@ -36,4 +36,5 @@ internal object ConjunctionUtils { "true" and "true" and "fail" ).map { createSolveRequest(it) } } + } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/PrimitiveUtils.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/PrimitiveUtils.kt index 7d2a7c25f..78d68d5f2 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/PrimitiveUtils.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/PrimitiveUtils.kt @@ -1,8 +1,8 @@ package it.unibo.tuprolog.solve.stdlib.primitive.testutils import it.unibo.tuprolog.solve.Solution -import it.unibo.tuprolog.solve.exception.PrologError import it.unibo.tuprolog.solve.primitive.Solve +import it.unibo.tuprolog.solve.exception.PrologError import kotlin.reflect.KClass import kotlin.test.assertEquals diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAbolish.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAbolish.kt index 943da46e6..472159f08 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAbolish.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAbolish.kt @@ -6,7 +6,7 @@ import it.unibo.tuprolog.solve.TestAbolish import kotlin.test.Ignore import kotlin.test.Test -class TestStreamsAbolish : TestAbolish, SolverFactory by StreamsSolverFactory { +class TestStreamsAbolish : TestAbolish, SolverFactory by StreamsSolverFactory { private val prototype = TestAbolish.prototype(this) @Test @@ -38,4 +38,4 @@ class TestStreamsAbolish : TestAbolish, SolverFactory by StreamsSolverFactory { override fun testAbolish() { prototype.testAbolish() } -} +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAnd.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAnd.kt index 9e54bd7b7..eaf2788ff 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAnd.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAnd.kt @@ -1,8 +1,13 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.SolverFactory -import it.unibo.tuprolog.solve.StreamsSolverFactory -import it.unibo.tuprolog.solve.TestAnd +import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.channel.InputChannel +import it.unibo.tuprolog.solve.channel.OutputChannel +import it.unibo.tuprolog.solve.exception.PrologWarning +import it.unibo.tuprolog.solve.library.AliasedLibrary +import it.unibo.tuprolog.solve.library.Libraries +import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins +import it.unibo.tuprolog.theory.Theory import kotlin.test.Ignore import kotlin.test.Test @@ -35,4 +40,4 @@ class TestStreamsAnd : TestAnd, SolverFactory by StreamsSolverFactory { override fun testTrueVarCallable() { prototype.testTrueVarCallable() } -} +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArg.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArg.kt index 21b897a5e..244a6d6af 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArg.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArg.kt @@ -1,8 +1,13 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.SolverFactory -import it.unibo.tuprolog.solve.StreamsSolverFactory -import it.unibo.tuprolog.solve.TestArg +import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.channel.InputChannel +import it.unibo.tuprolog.solve.channel.OutputChannel +import it.unibo.tuprolog.solve.exception.PrologWarning +import it.unibo.tuprolog.solve.library.AliasedLibrary +import it.unibo.tuprolog.solve.library.Libraries +import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins +import it.unibo.tuprolog.theory.Theory import kotlin.test.Ignore import kotlin.test.Test @@ -85,4 +90,4 @@ class TestStreamsArg : TestArg, SolverFactory by StreamsSolverFactory { override fun testArgAFromFoo() { prototype.testArgAFromFoo() } -} +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArith.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArith.kt index 24f123100..3677f50d1 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArith.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArith.kt @@ -1,8 +1,13 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.SolverFactory -import it.unibo.tuprolog.solve.StreamsSolverFactory -import it.unibo.tuprolog.solve.TestArith +import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.channel.InputChannel +import it.unibo.tuprolog.solve.channel.OutputChannel +import it.unibo.tuprolog.solve.exception.PrologWarning +import it.unibo.tuprolog.solve.library.AliasedLibrary +import it.unibo.tuprolog.solve.library.Libraries +import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins +import it.unibo.tuprolog.theory.Theory import kotlin.test.Ignore import kotlin.test.Test @@ -40,3 +45,4 @@ class TestStreamsArith : TestArith, SolverFactory by StreamsSolverFactory { prototype.testArithLessThanEq() } } + diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAssertA.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAssertA.kt index 2506bf07d..56ae7fb67 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAssertA.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAssertA.kt @@ -6,7 +6,8 @@ import it.unibo.tuprolog.solve.TestAssertA import kotlin.test.Ignore import kotlin.test.Test -class TestStreamsAssertA : TestAssertA, SolverFactory by StreamsSolverFactory { + +class TestStreamsAssertA : TestAssertA, SolverFactory by StreamsSolverFactory{ private val prototype = TestAssertA.prototype(this) @@ -38,4 +39,4 @@ class TestStreamsAssertA : TestAssertA, SolverFactory by StreamsSolverFactory { override fun testAssertAAtomTrue() { prototype.testAssertAAtomTrue() } -} +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAssertZ.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAssertZ.kt index 44791f03f..70c05c4c1 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAssertZ.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAssertZ.kt @@ -1,12 +1,17 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.SolverFactory -import it.unibo.tuprolog.solve.StreamsSolverFactory -import it.unibo.tuprolog.solve.TestAssertZ +import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.channel.InputChannel +import it.unibo.tuprolog.solve.channel.OutputChannel +import it.unibo.tuprolog.solve.exception.PrologWarning +import it.unibo.tuprolog.solve.library.AliasedLibrary +import it.unibo.tuprolog.solve.library.Libraries +import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins +import it.unibo.tuprolog.theory.Theory import kotlin.test.Ignore import kotlin.test.Test -class TestStreamsAssertZ : TestAssertZ, SolverFactory by StreamsSolverFactory { +class TestStreamsAssertZ : TestAssertZ, SolverFactory by StreamsSolverFactory{ private val prototype = TestAssertZ.prototype(this) @@ -38,4 +43,4 @@ class TestStreamsAssertZ : TestAssertZ, SolverFactory by StreamsSolverFactory { override fun testAssertZAtomTrue() { prototype.testAssertZAtomTrue() } -} +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtom.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtom.kt index 97f598d47..f2e48dd17 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtom.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtom.kt @@ -1,8 +1,13 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.SolverFactory -import it.unibo.tuprolog.solve.StreamsSolverFactory -import it.unibo.tuprolog.solve.TestAtom +import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.channel.InputChannel +import it.unibo.tuprolog.solve.channel.OutputChannel +import it.unibo.tuprolog.solve.exception.PrologWarning +import it.unibo.tuprolog.solve.library.AliasedLibrary +import it.unibo.tuprolog.solve.library.Libraries +import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins +import it.unibo.tuprolog.theory.Theory import kotlin.test.Test class TestStreamsAtom : TestAtom, SolverFactory by StreamsSolverFactory { @@ -43,4 +48,4 @@ class TestStreamsAtom : TestAtom, SolverFactory by StreamsSolverFactory { override fun testAtomNumDec() { prototype.testAtomNumDec() } -} +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtomic.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtomic.kt index f3d684ee9..55fe3ef7b 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtomic.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtomic.kt @@ -1,8 +1,13 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.SolverFactory -import it.unibo.tuprolog.solve.StreamsSolverFactory -import it.unibo.tuprolog.solve.TestAtomic +import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.channel.InputChannel +import it.unibo.tuprolog.solve.channel.OutputChannel +import it.unibo.tuprolog.solve.exception.PrologWarning +import it.unibo.tuprolog.solve.library.AliasedLibrary +import it.unibo.tuprolog.solve.library.Libraries +import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins +import it.unibo.tuprolog.theory.Theory import kotlin.test.Test class TestStreamsAtomic : TestAtomic, SolverFactory by StreamsSolverFactory { @@ -38,4 +43,4 @@ class TestStreamsAtomic : TestAtomic, SolverFactory by StreamsSolverFactory { override fun testAtomicNumDec() { prototype.testAtomicNumDec() } -} +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCall.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCall.kt index e29ef494d..37071d0ac 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCall.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCall.kt @@ -1,16 +1,16 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.TestCall import kotlin.test.Ignore import kotlin.test.Test -class TestStreamsCall : TestCall, SolverFactory by StreamsSolverFactory { +class TestClassicCall : TestCall, SolverFactory by StreamsSolverFactory { private val prototype = TestCall.prototype(this) @Test - override fun testCallCut() { + override fun testCallCut(){ prototype.testCallCut() } @@ -70,4 +70,4 @@ class TestStreamsCall : TestCall, SolverFactory by StreamsSolverFactory { override fun testCallTrue() { prototype.testCallTrue() } -} +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCatchAndThrow.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCatchAndThrow.kt index 9273d2e63..e20d8ff3a 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCatchAndThrow.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCatchAndThrow.kt @@ -1,11 +1,11 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.TestCatchAndThrow import kotlin.test.Test -class TestStreamsCatchAndThrow : TestCatchAndThrow, SolverFactory by StreamsSolverFactory { +class TestStreamsCatchAndThrow : TestCatchAndThrow, SolverFactory by StreamsSolverFactory { private val prototype = TestCatchAndThrow.prototype(this) @Test @@ -17,4 +17,4 @@ class TestStreamsCatchAndThrow : TestCatchAndThrow, SolverFactory by StreamsSolv override fun testCatchFail() { prototype.testCatchFail() } -} +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsClause.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsClause.kt index e628ea92c..96ae9b30c 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsClause.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsClause.kt @@ -7,7 +7,7 @@ import kotlin.test.Ignore import kotlin.test.Test @Ignore -class TestStreamsClause : TestClause, SolverFactory by StreamsSolverFactory { +class TestStreamsClause : TestClause, SolverFactory by StreamsSolverFactory { private val prototype = TestClause.prototype(this) @Test @@ -34,4 +34,4 @@ class TestStreamsClause : TestClause, SolverFactory by StreamsSolverFactory { override fun testClauseAtomBody() { prototype.testClauseAtomBody() } -} +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCompound.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCompound.kt index 4c596fd4f..e5228b05b 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCompound.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCompound.kt @@ -5,7 +5,7 @@ import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.TestCompound import kotlin.test.Test -class TestStreamsCompound : TestCompound, SolverFactory by StreamsSolverFactory { +class TestStreamsCompound : TestCompound, SolverFactory by StreamsSolverFactory { private val prototype = TestCompound.prototype(this) @Test @@ -42,4 +42,4 @@ class TestStreamsCompound : TestCompound, SolverFactory by StreamsSolverFactory override fun testCompoundListA() { prototype.testCompoundListA() } -} +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCopyTerm.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCopyTerm.kt index 6208d6ac2..8dd69b8c6 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCopyTerm.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCopyTerm.kt @@ -1,12 +1,12 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.TestCopyTerm import kotlin.test.Ignore import kotlin.test.Test -class TestStreamsCopyTerm : TestCopyTerm, SolverFactory by StreamsSolverFactory { +class TestStreamsCopyTerm : TestCopyTerm, SolverFactory by StreamsSolverFactory { private val prototype = TestCopyTerm.prototype(this) @Test @@ -57,4 +57,4 @@ class TestStreamsCopyTerm : TestCopyTerm, SolverFactory by StreamsSolverFactory override fun testDoubleCopy() { prototype.testDoubleCopy() } -} +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCut.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCut.kt index 42f297cdd..cdb2fc10b 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCut.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCut.kt @@ -6,7 +6,7 @@ import it.unibo.tuprolog.solve.TestCut import kotlin.test.Ignore import kotlin.test.Test -class TestStreamsCut : TestCut, SolverFactory by StreamsSolverFactory { +class TestStreamsCut: TestCut, SolverFactory by StreamsSolverFactory { private val prototype = TestCut.prototype(this) @@ -25,4 +25,4 @@ class TestStreamsCut : TestCut, SolverFactory by StreamsSolverFactory { override fun testCallCutFailTrue() { prototype.testCallCutFailTrue() } -} +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFail.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFail.kt index 502a8d9f1..f4534557e 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFail.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFail.kt @@ -1,12 +1,12 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.TestFail import kotlin.test.Ignore import kotlin.test.Test -class TestStreamsFail : TestFail, SolverFactory by StreamsSolverFactory { +class TestStreamsFail : TestFail, SolverFactory by StreamsSolverFactory { private val prototype = TestFail.prototype(this) @Test @@ -29,4 +29,4 @@ class TestStreamsFail : TestFail, SolverFactory by StreamsSolverFactory { override fun testSetFlagWarning() { prototype.testSetFlagWarning() } -} +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFindAll.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFindAll.kt index 0676be60c..f8ebbebfc 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFindAll.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFindAll.kt @@ -1,8 +1,13 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.SolverFactory -import it.unibo.tuprolog.solve.StreamsSolverFactory -import it.unibo.tuprolog.solve.TestFindAll +import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.channel.InputChannel +import it.unibo.tuprolog.solve.channel.OutputChannel +import it.unibo.tuprolog.solve.exception.PrologWarning +import it.unibo.tuprolog.solve.library.AliasedLibrary +import it.unibo.tuprolog.solve.library.Libraries +import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins +import it.unibo.tuprolog.theory.Theory import kotlin.test.Ignore import kotlin.test.Test @@ -57,4 +62,4 @@ class TestStreamsFindAll : TestFindAll, SolverFactory by StreamsSolverFactory { override fun testFindXinCall() { prototype.testFindXinCall() } -} +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFloat.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFloat.kt index 9627b205c..a70aa5540 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFloat.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFloat.kt @@ -1,11 +1,11 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.TestFloat import kotlin.test.Test -class TestStreamsFloat : TestFloat, SolverFactory by StreamsSolverFactory { +class TestStreamsFloat : TestFloat, SolverFactory by StreamsSolverFactory { private val prototype = TestFloat.prototype(this) @Test @@ -32,4 +32,4 @@ class TestStreamsFloat : TestFloat, SolverFactory by StreamsSolverFactory { override fun testFloatX() { prototype.testFloatX() } -} +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFunctor.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFunctor.kt index 9c8a6e568..d56bd946d 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFunctor.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFunctor.kt @@ -1,16 +1,19 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.SolverFactory -import it.unibo.tuprolog.solve.StreamsSolverFactory -import it.unibo.tuprolog.solve.TestFunctor +import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.channel.InputChannel +import it.unibo.tuprolog.solve.channel.OutputChannel +import it.unibo.tuprolog.solve.exception.PrologWarning +import it.unibo.tuprolog.solve.library.Libraries +import it.unibo.tuprolog.theory.Theory import kotlin.test.Ignore import kotlin.test.Test -class TestStreamsFunctor : TestFunctor, SolverFactory by StreamsSolverFactory { +class TestStreamsFunctor : TestFunctor, SolverFactory by StreamsSolverFactory { private val prototype = TestFunctor.prototype(this) @Test - override fun testFunArity() { + override fun testFunArity(){ prototype.testFunArity() } @@ -102,4 +105,4 @@ class TestStreamsFunctor : TestFunctor, SolverFactory by StreamsSolverFactory { override fun testFunNegativeArity() { prototype.testFunNegativeArity() } -} +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIfThen.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIfThen.kt index 9ee13b920..6261e097d 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIfThen.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIfThen.kt @@ -5,7 +5,7 @@ import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.TestIfThen import kotlin.test.Test -class TestStreamsIfThen : TestIfThen, SolverFactory by StreamsSolverFactory { +class TestStreamsIfThen : TestIfThen, SolverFactory by StreamsSolverFactory { private val prototype = TestIfThen.prototype(this) @Test @@ -37,4 +37,4 @@ class TestStreamsIfThen : TestIfThen, SolverFactory by StreamsSolverFactory { override fun testIfThenXtoOne() { prototype.testIfThenXtoOne() } -} +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIfThenElse.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIfThenElse.kt index 9a803bd47..896c475c9 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIfThenElse.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIfThenElse.kt @@ -1,7 +1,7 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.TestIfThenElse import kotlin.test.Test @@ -47,4 +47,4 @@ class TestStreamsIfThenElse : TestIfThenElse, SolverFactory by StreamsSolverFact override fun testIfOrElseTrue() { prototype.testIfOrElseTrue() } -} +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsInteger.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsInteger.kt index 20a0aa53d..d6b2f3d6b 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsInteger.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsInteger.kt @@ -1,8 +1,13 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.SolverFactory -import it.unibo.tuprolog.solve.StreamsSolverFactory -import it.unibo.tuprolog.solve.TestInteger +import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.channel.InputChannel +import it.unibo.tuprolog.solve.channel.OutputChannel +import it.unibo.tuprolog.solve.exception.PrologWarning +import it.unibo.tuprolog.solve.library.AliasedLibrary +import it.unibo.tuprolog.solve.library.Libraries +import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins +import it.unibo.tuprolog.theory.Theory import kotlin.test.Test class TestStreamsInteger : TestInteger, SolverFactory by StreamsSolverFactory { @@ -33,4 +38,4 @@ class TestStreamsInteger : TestInteger, SolverFactory by StreamsSolverFactory { override fun testIntAtom() { prototype.testIntAtom() } -} +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIs.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIs.kt index c87dcb402..9e7923578 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIs.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIs.kt @@ -1,12 +1,12 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.TestIs import kotlin.test.Ignore import kotlin.test.Test -class TestStreamsIs : TestIs, SolverFactory by StreamsSolverFactory { +class TestStreamsIs : TestIs, SolverFactory by StreamsSolverFactory { private val prototype = TestIs.prototype(this) @Test @@ -16,7 +16,7 @@ class TestStreamsIs : TestIs, SolverFactory by StreamsSolverFactory { @Test @Ignore - override fun testIsXY() { + override fun testIsXY(){ prototype.testIsXY() } @@ -41,4 +41,4 @@ class TestStreamsIs : TestIs, SolverFactory by StreamsSolverFactory { override fun testIsXFloat() { prototype.testIsXFloat() } -} +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNonVar.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNonVar.kt index b898b4596..3aae18e19 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNonVar.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNonVar.kt @@ -1,8 +1,13 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.SolverFactory -import it.unibo.tuprolog.solve.StreamsSolverFactory -import it.unibo.tuprolog.solve.TestNonVar +import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.channel.InputChannel +import it.unibo.tuprolog.solve.channel.OutputChannel +import it.unibo.tuprolog.solve.exception.PrologWarning +import it.unibo.tuprolog.solve.library.AliasedLibrary +import it.unibo.tuprolog.solve.library.Libraries +import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins +import it.unibo.tuprolog.theory.Theory import kotlin.test.Test class TestStreamsNonVar : TestNonVar, SolverFactory by StreamsSolverFactory { @@ -38,4 +43,4 @@ class TestStreamsNonVar : TestNonVar, SolverFactory by StreamsSolverFactory { override fun testNonVar() { prototype.testNonVar() } -} +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNotProvable.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNotProvable.kt index 648b53dfa..8b17b6458 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNotProvable.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNotProvable.kt @@ -6,7 +6,7 @@ import it.unibo.tuprolog.solve.TestNotProvable import kotlin.test.Ignore import kotlin.test.Test -class TestStreamsNotProvable : TestNotProvable, SolverFactory by StreamsSolverFactory { +class TestStreamsNotProvable : TestNotProvable, SolverFactory by StreamsSolverFactory { private val prototype = TestNotProvable.prototype(this) @Test @@ -20,7 +20,7 @@ class TestStreamsNotProvable : TestNotProvable, SolverFactory by StreamsSolverFa } @Test - @Ignore // solver returns no + @Ignore //solver returns no override fun testNPCutFail() { prototype.testNPCutFail() } @@ -43,8 +43,8 @@ class TestStreamsNotProvable : TestNotProvable, SolverFactory by StreamsSolverFa } @Test - @Ignore // solver returns no + @Ignore //solver returns no override fun testOrNotCutFail() { prototype.testOrNotCutFail() } -} +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNotUnify.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNotUnify.kt index 78a283ba0..afd276f8d 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNotUnify.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNotUnify.kt @@ -1,8 +1,13 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.SolverFactory -import it.unibo.tuprolog.solve.StreamsSolverFactory -import it.unibo.tuprolog.solve.TestNotUnify +import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.channel.InputChannel +import it.unibo.tuprolog.solve.channel.OutputChannel +import it.unibo.tuprolog.solve.exception.PrologWarning +import it.unibo.tuprolog.solve.library.AliasedLibrary +import it.unibo.tuprolog.solve.library.Libraries +import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins +import it.unibo.tuprolog.theory.Theory import kotlin.test.Test class TestStreamsNotUnify : TestNotUnify, SolverFactory by StreamsSolverFactory { @@ -58,4 +63,5 @@ class TestStreamsNotUnify : TestNotUnify, SolverFactory by StreamsSolverFactory override fun testFMultipleTermNotUnify() { prototype.testFMultipleTermNotUnify() } -} + +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNumber.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNumber.kt index e0940eade..0abe430c4 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNumber.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNumber.kt @@ -33,4 +33,5 @@ class TestStreamsNumber : TestNumber, SolverFactory by StreamsSolverFactory { override fun testXNum() { prototype.testXNum() } -} + +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsOnce.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsOnce.kt index fbaf66994..8172053ca 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsOnce.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsOnce.kt @@ -1,12 +1,12 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.TestOnce import kotlin.test.Ignore import kotlin.test.Test -class TestStreamsOnce : TestOnce, SolverFactory by StreamsSolverFactory { +class TestStreamsOnce : TestOnce, SolverFactory by StreamsSolverFactory { private val prototype = TestOnce.prototype(this) @Test @@ -40,4 +40,4 @@ class TestStreamsOnce : TestOnce, SolverFactory by StreamsSolverFactory { override fun testOnceX() { prototype.testOnceX() } -} +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsOr.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsOr.kt index 806b2c236..0c42e92c0 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsOr.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsOr.kt @@ -1,8 +1,13 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.SolverFactory -import it.unibo.tuprolog.solve.StreamsSolverFactory -import it.unibo.tuprolog.solve.TestOr +import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.channel.InputChannel +import it.unibo.tuprolog.solve.channel.OutputChannel +import it.unibo.tuprolog.solve.exception.PrologWarning +import it.unibo.tuprolog.solve.library.AliasedLibrary +import it.unibo.tuprolog.solve.library.Libraries +import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins +import it.unibo.tuprolog.theory.Theory import kotlin.test.Ignore import kotlin.test.Test @@ -37,4 +42,6 @@ class TestStreamsOr : TestOr, SolverFactory by StreamsSolverFactory { override fun testOrDoubleAssignment() { prototype.testOrDoubleAssignment() } -} + + +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsRepeat.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsRepeat.kt index 6bb16e26b..6a66144fd 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsRepeat.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsRepeat.kt @@ -1,15 +1,15 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.TestRepeat import kotlin.test.Test -class TestStreamsRepeat : TestRepeat, SolverFactory by StreamsSolverFactory { +class TestStreamsRepeat : TestRepeat, SolverFactory by StreamsSolverFactory { private val prototype = TestRepeat.prototype(this) @Test override fun testRepeat() { prototype.testRepeat() } -} +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsRetract.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsRetract.kt index 38953a338..19d957989 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsRetract.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsRetract.kt @@ -7,7 +7,7 @@ import kotlin.test.Ignore import kotlin.test.Test @Ignore -class TestStreamsRetract : TestRetract, SolverFactory by StreamsSolverFactory { +class TestStreamsRetract : TestRetract, SolverFactory by StreamsSolverFactory { private val prototype = TestRetract.prototype(this) @Test @@ -19,4 +19,4 @@ class TestStreamsRetract : TestRetract, SolverFactory by StreamsSolverFactory { override fun testRetractAtomEmptyList() { prototype.testRetractAtomEmptyList() } -} +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsSolver.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsSolver.kt index 06e7dcab6..3d653dde4 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsSolver.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsSolver.kt @@ -1,17 +1,12 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.FlagStore -import it.unibo.tuprolog.solve.MutableSolver -import it.unibo.tuprolog.solve.Solver -import it.unibo.tuprolog.solve.SolverFactory -import it.unibo.tuprolog.solve.TestSolver +import it.unibo.tuprolog.solve.* import it.unibo.tuprolog.solve.channel.InputChannel import it.unibo.tuprolog.solve.channel.OutputChannel import it.unibo.tuprolog.solve.exception.PrologWarning import it.unibo.tuprolog.solve.library.AliasedLibrary import it.unibo.tuprolog.solve.library.Libraries import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.solve.streams import it.unibo.tuprolog.theory.Theory import kotlin.test.Ignore import kotlin.test.Test @@ -122,6 +117,7 @@ class TestStreamsSolver : SolverFactory, TestSolver { prototype.testIfThenElse2() } + @Test override fun testTimeout1() { prototype.testTimeout1() diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsTerm.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsTerm.kt index b94e0ef13..2a2f278d8 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsTerm.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsTerm.kt @@ -1,7 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.TestInteger import it.unibo.tuprolog.solve.TestTerm import kotlin.test.Test @@ -38,4 +39,4 @@ class TestStreamsTerm : TestTerm, SolverFactory by StreamsSolverFactory { override fun testTermLessThanEq() { prototype.testTermLessThanEq() } -} +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsTrue.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsTrue.kt index ba0b4b7c4..1e50b7ea0 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsTrue.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsTrue.kt @@ -1,15 +1,15 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.SolverFactory import it.unibo.tuprolog.solve.TestTrue import kotlin.test.Test -class TestStreamsTrue : TestTrue, SolverFactory by StreamsSolverFactory { +class TestStreamsTrue : TestTrue, SolverFactory by StreamsSolverFactory { private val prototype = TestTrue.prototype(this) @Test override fun testTrue() { prototype.testTrue() } -} +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsUnify.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsUnify.kt index d23c88716..29da05422 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsUnify.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsUnify.kt @@ -1,8 +1,13 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.SolverFactory -import it.unibo.tuprolog.solve.StreamsSolverFactory -import it.unibo.tuprolog.solve.TestUnify +import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.channel.InputChannel +import it.unibo.tuprolog.solve.channel.OutputChannel +import it.unibo.tuprolog.solve.exception.PrologWarning +import it.unibo.tuprolog.solve.library.AliasedLibrary +import it.unibo.tuprolog.solve.library.Libraries +import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins +import it.unibo.tuprolog.theory.Theory import kotlin.test.Ignore import kotlin.test.Test @@ -66,4 +71,5 @@ class TestStreamsUnify : TestUnify, SolverFactory by StreamsSolverFactory { override fun testMultipleTermUnify() { prototype.testMultipleTermUnify() } -} + +} \ No newline at end of file diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/testutils/SolverTestUtils.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/testutils/SolverTestUtils.kt index 0da336798..62f275f08 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/testutils/SolverTestUtils.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/testutils/SolverTestUtils.kt @@ -2,12 +2,12 @@ package it.unibo.tuprolog.solve.testutils import it.unibo.tuprolog.core.Struct import it.unibo.tuprolog.solve.Signature +import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.Solver import it.unibo.tuprolog.solve.extractSignature import it.unibo.tuprolog.solve.library.Libraries import it.unibo.tuprolog.solve.library.Library import it.unibo.tuprolog.solve.primitive.Primitive -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.solver.StreamsExecutionContext import it.unibo.tuprolog.theory.Theory From ef02c06998b81bdc36f7a7755c2fafb710a45d1c Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 14 Sep 2020 16:24:36 +0200 Subject: [PATCH 23/34] basic formatting in :solve-streams/src/commonTest --- .../tuprolog/solve/SolverStrategiesTest.kt | 1 - .../unibo/tuprolog/solve/StreamsSolverTest.kt | 1 - .../tuprolog/solve/solver/SolverUtilsTest.kt | 12 ++++++----- .../solver/fsm/AlreadyExecutedStateTest.kt | 1 - .../fsm/impl/StateGoalEvaluationTest.kt | 1 - .../solve/solver/fsm/impl/StateInitTest.kt | 2 +- .../solver/fsm/impl/StateRuleSelectionTest.kt | 20 +++++++++++-------- .../StateIntegrationTesting.kt | 5 +++-- .../testutils/StateGoalEvaluationUtils.kt | 14 ++++++------- .../fsm/impl/testutils/StateInitUtils.kt | 2 +- .../solver/fsm/impl/testutils/StateUtils.kt | 6 +++--- .../solve/stdlib/primitive/ConjunctionTest.kt | 4 +++- .../solve/stdlib/primitive/NotTest.kt | 7 ++++--- .../CutAndConjunctionIntegrationTest.kt | 6 ++++-- .../stdlib/primitive/testutils/CallUtils.kt | 6 ++++-- .../stdlib/primitive/testutils/CatchUtils.kt | 9 ++++----- .../primitive/testutils/ConjunctionUtils.kt | 1 - .../primitive/testutils/PrimitiveUtils.kt | 2 +- .../solve/systemtest/TestStreamsAbolish.kt | 4 ++-- .../solve/systemtest/TestStreamsAnd.kt | 9 +-------- .../solve/systemtest/TestStreamsArg.kt | 9 +-------- .../solve/systemtest/TestStreamsArith.kt | 8 -------- .../solve/systemtest/TestStreamsAssertA.kt | 5 ++--- .../solve/systemtest/TestStreamsAssertZ.kt | 11 ++-------- .../solve/systemtest/TestStreamsAtom.kt | 9 +-------- .../solve/systemtest/TestStreamsAtomic.kt | 9 +-------- .../solve/systemtest/TestStreamsCall.kt | 8 ++++---- .../systemtest/TestStreamsCatchAndThrow.kt | 6 +++--- .../solve/systemtest/TestStreamsClause.kt | 4 ++-- .../solve/systemtest/TestStreamsCompound.kt | 4 ++-- .../solve/systemtest/TestStreamsCopyTerm.kt | 6 +++--- .../solve/systemtest/TestStreamsCut.kt | 4 ++-- .../solve/systemtest/TestStreamsFail.kt | 6 +++--- .../solve/systemtest/TestStreamsFindAll.kt | 9 +-------- .../solve/systemtest/TestStreamsFloat.kt | 6 +++--- .../solve/systemtest/TestStreamsFunctor.kt | 11 +++------- .../solve/systemtest/TestStreamsIfThen.kt | 4 ++-- .../solve/systemtest/TestStreamsIfThenElse.kt | 4 ++-- .../solve/systemtest/TestStreamsInteger.kt | 9 +-------- .../solve/systemtest/TestStreamsIs.kt | 8 ++++---- .../solve/systemtest/TestStreamsNonVar.kt | 9 +-------- .../systemtest/TestStreamsNotProvable.kt | 8 ++++---- .../solve/systemtest/TestStreamsNotUnify.kt | 10 +--------- .../solve/systemtest/TestStreamsNumber.kt | 3 +-- .../solve/systemtest/TestStreamsOnce.kt | 6 +++--- .../solve/systemtest/TestStreamsOr.kt | 11 +--------- .../solve/systemtest/TestStreamsRepeat.kt | 6 +++--- .../solve/systemtest/TestStreamsRetract.kt | 4 ++-- .../solve/systemtest/TestStreamsSolver.kt | 1 - .../solve/systemtest/TestStreamsTerm.kt | 5 ++--- .../solve/systemtest/TestStreamsTrue.kt | 6 +++--- .../solve/systemtest/TestStreamsUnify.kt | 10 +--------- .../solve/testutils/SolverTestUtils.kt | 2 +- 53 files changed, 122 insertions(+), 212 deletions(-) diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/SolverStrategiesTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/SolverStrategiesTest.kt index b136f2a80..3a34a6666 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/SolverStrategiesTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/SolverStrategiesTest.kt @@ -42,5 +42,4 @@ internal class SolverStrategiesTest { assertTrue { prologStandard.successCheckStrategy(Truth.TRUE, aContext) } assertFalse { prologStandard.successCheckStrategy(Atom.of("ciao"), aContext) } } - } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/StreamsSolverTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/StreamsSolverTest.kt index c9659157f..9a808b721 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/StreamsSolverTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/StreamsSolverTest.kt @@ -21,5 +21,4 @@ internal class StreamsSolverTest { assertEquals(Theory.empty(), toBeTested.staticKb) assertEquals(Theory.empty(), toBeTested.dynamicKb) } - } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/SolverUtilsTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/SolverUtilsTest.kt index 9316518bb..f0d1fa9e1 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/SolverUtilsTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/SolverUtilsTest.kt @@ -104,11 +104,13 @@ internal class SolverUtilsTest { @Test fun moreThanOneWorksLazily() { assertTrue { - moreThanOne(sequence { - yield(1) - yield(1) - fail("Should not evaluate entire sequence") - }) + moreThanOne( + sequence { + yield(1) + yield(1) + fail("Should not evaluate entire sequence") + } + ) } } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/AlreadyExecutedStateTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/AlreadyExecutedStateTest.kt index 970aa01d8..4d7dc3801 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/AlreadyExecutedStateTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/AlreadyExecutedStateTest.kt @@ -47,5 +47,4 @@ internal class AlreadyExecutedStateTest { assertSame(correct.wrappedState, toBeTested.wrappedState) } - } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateGoalEvaluationTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateGoalEvaluationTest.kt index 66ca8977e..b93faea4a 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateGoalEvaluationTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateGoalEvaluationTest.kt @@ -62,5 +62,4 @@ internal class StateGoalEvaluationTest { assertOnlyOneNextState(nextStates) } } - } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateInitTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateInitTest.kt index 662e34a3a..c99126169 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateInitTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateInitTest.kt @@ -5,8 +5,8 @@ import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.core.Truth import it.unibo.tuprolog.core.prepareForExecution import it.unibo.tuprolog.solve.DummyInstances -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.SolverStrategies +import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.solver.fsm.impl.testutils.StateInitUtils.allRequests import it.unibo.tuprolog.solve.solver.fsm.impl.testutils.StateInitUtils.allWellFormedGoalRequests import it.unibo.tuprolog.solve.solver.fsm.impl.testutils.StateInitUtils.nonWellFormedGoalRequest diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateRuleSelectionTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateRuleSelectionTest.kt index 357a9128c..38df49d8b 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateRuleSelectionTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/StateRuleSelectionTest.kt @@ -2,10 +2,10 @@ package it.unibo.tuprolog.solve.solver.fsm.impl import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.dsl.theory.prolog -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.extractSignature import it.unibo.tuprolog.solve.library.Libraries import it.unibo.tuprolog.solve.library.Library +import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.solver.StreamsExecutionContext import it.unibo.tuprolog.solve.solver.fsm.FinalState import it.unibo.tuprolog.solve.solver.fsm.impl.testutils.StateRuleSelectionUtils.createRequest @@ -33,15 +33,20 @@ internal class StateRuleSelectionTest { private val theQuery = prolog { "f"(theQueryVariable) } /** A Solve.Request with three databases and three different facts, to test how they should be used/combined in searching */ - private val threeDBSolveRequest = Solve.Request(theQuery.extractSignature(), theQuery.argsList, + private val threeDBSolveRequest = Solve.Request( + theQuery.extractSignature(), + theQuery.argsList, StreamsExecutionContext( - libraries = Libraries(Library.aliased( - alias = "testLib", - theory = prolog { theory({ "f"("a") }) } - )), + libraries = Libraries( + Library.aliased( + alias = "testLib", + theory = prolog { theory({ "f"("a") }) } + ) + ), staticKb = prolog { theory({ "f"("b") }) }, dynamicKb = prolog { theory({ "f"("c") }) } - )) + ) + ) @Test fun noMatchingRulesFoundMakeItGoIntoFalseState() { @@ -115,5 +120,4 @@ internal class StateRuleSelectionTest { } } } - } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/integrationtest/StateIntegrationTesting.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/integrationtest/StateIntegrationTesting.kt index 807fb5f59..d1ae7a313 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/integrationtest/StateIntegrationTesting.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/integrationtest/StateIntegrationTesting.kt @@ -8,7 +8,6 @@ import it.unibo.tuprolog.solve.PrologStandardExampleTheories.prologStandardExamp import it.unibo.tuprolog.solve.PrologStandardExampleTheories.prologStandardExampleWithCutTheory import it.unibo.tuprolog.solve.PrologStandardExampleTheories.prologStandardExampleWithCutTheoryNotableGoalToSolution import it.unibo.tuprolog.solve.Solution -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.TestingClauseTheories.customReverseListTheory import it.unibo.tuprolog.solve.TestingClauseTheories.customReverseListTheoryNotableGoalToSolution import it.unibo.tuprolog.solve.TestingClauseTheories.cutConjunctionAndBacktrackingTheory @@ -23,6 +22,7 @@ import it.unibo.tuprolog.solve.TestingClauseTheories.simpleFactTheory import it.unibo.tuprolog.solve.TestingClauseTheories.simpleFactTheoryNotableGoalToSolutions import it.unibo.tuprolog.solve.assertSolutionEquals import it.unibo.tuprolog.solve.extractSignature +import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.solver.StreamsExecutionContext import it.unibo.tuprolog.solve.solver.fsm.FinalState import it.unibo.tuprolog.solve.solver.fsm.State @@ -67,7 +67,8 @@ internal class StateIntegrationTesting { finalState.solve.solution.let { // cleanUp as in StreamsSolver (it as? Solution.Yes)?.copy(substitution = it.substitution.filter { _, t -> t !is Var }) ?: it - }) + } + ) } } } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateGoalEvaluationUtils.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateGoalEvaluationUtils.kt index e8b305a4f..c92a5e7f9 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateGoalEvaluationUtils.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateGoalEvaluationUtils.kt @@ -1,7 +1,6 @@ package it.unibo.tuprolog.solve.solver.fsm.impl.testutils import it.unibo.tuprolog.core.Var -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.StreamsSolver import it.unibo.tuprolog.solve.exception.HaltException import it.unibo.tuprolog.solve.exception.PrologError @@ -10,6 +9,7 @@ import it.unibo.tuprolog.solve.exception.error.SystemError import it.unibo.tuprolog.solve.exception.error.TypeError import it.unibo.tuprolog.solve.primitive.Primitive import it.unibo.tuprolog.solve.primitive.PrimitiveWrapper +import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.solver.SideEffectManagerImpl import it.unibo.tuprolog.solve.solver.StreamsExecutionContext import it.unibo.tuprolog.solve.solver.fsm.impl.StateEnd @@ -45,15 +45,15 @@ internal object StateGoalEvaluationUtils { internal val primitiveRequestToNextStateList by lazy { mapOf( createRequestForPrimitiveResponding { sequenceOf(it.replySuccess(it.context.substitution)) } - to listOf(StateEnd.True::class), + to listOf(StateEnd.True::class), createRequestForPrimitiveResponding { sequenceOf(it.replyFail()) } - to listOf(StateEnd.False::class), + to listOf(StateEnd.False::class), createRequestForPrimitiveResponding { sequenceOf(it.replyWith(true), it.replyWith(false)) } - to listOf(StateEnd.True::class, StateEnd.False::class), + to listOf(StateEnd.True::class, StateEnd.False::class), createRequestForPrimitiveResponding { sequenceOf(it.replyException(HaltException(context = it.context))) } - to listOf(StateEnd.Halt::class), + to listOf(StateEnd.Halt::class), createRequestForPrimitiveResponding { throw HaltException(context = it.context) } - to listOf(StateEnd.Halt::class), + to listOf(StateEnd.Halt::class), createRequestForPrimitiveResponding { sequence { yieldAll(StreamsSolver.solveToResponses(createRequestForPrimitiveResponding { throw HaltException(context = it.context) })) @@ -85,4 +85,4 @@ internal object StateGoalEvaluationUtils { /** All requests that should make [StateGoalEvaluation] transit in [StateRuleSelection] */ internal val nonPrimitiveRequests by lazy { StateInitUtils.allWellFormedGoalRequests } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateInitUtils.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateInitUtils.kt index 5c9583f95..d9a4ea462 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateInitUtils.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateInitUtils.kt @@ -62,7 +62,7 @@ internal object StateInitUtils { /** Collection of [Solve.Request] that should pass [StateInit] going into [StateGoalEvaluation] */ internal val allWellFormedGoalRequests by lazy { wellFormedGoalRequestsNeedingPreparationForExecution + - wellFormedGoalRequestsNotNeedingPreparationForExecution + wellFormedGoalRequestsNotNeedingPreparationForExecution } /** Solve request with non well-formed goal */ diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateUtils.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateUtils.kt index b63394add..615f85971 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateUtils.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/testutils/StateUtils.kt @@ -21,7 +21,8 @@ internal object StateUtils { /** Utility function to assert that there's only one next state of given type */ internal inline fun assertOnlyOneNextState(actualNextStateSequence: Sequence) { assertEquals( - 1, actualNextStateSequence.count(), + 1, + actualNextStateSequence.count(), "Expected only one state, but ${actualNextStateSequence.toList()}" ) assertTrue { actualNextStateSequence.single() is S } @@ -50,6 +51,5 @@ internal object StateUtils { internal fun Solve.getSideEffectsManager(): SideEffectManager = when (this) { is Solve.Response -> sideEffectManager is Solve.Request<*> -> context.getSideEffectManager() - } ?: fail("SideEffectManager is not present in ${this}") - + } ?: fail("SideEffectManager is not present in $this") } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ConjunctionTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ConjunctionTest.kt index f819ef14a..fbe15a5af 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ConjunctionTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ConjunctionTest.kt @@ -64,7 +64,9 @@ internal class ConjunctionTest { val goal = "left" and "right" val request = Solve.Request( - goal.extractSignature(), goal.argsList, StreamsExecutionContext( + goal.extractSignature(), + goal.argsList, + StreamsExecutionContext( substitution = preRequestSubstitution, libraries = Libraries( Library.aliased( diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/NotTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/NotTest.kt index d51b9494b..6c64808dd 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/NotTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/NotTest.kt @@ -67,10 +67,11 @@ internal class NotTest { DummyInstances.executionContext, Not.signature, TypeError.Expected.CALLABLE, - prolog { numOf(1) }) + prolog { numOf(1) } + ) ) - ), solutions + ), + solutions ) } - } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/integrationtest/CutAndConjunctionIntegrationTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/integrationtest/CutAndConjunctionIntegrationTest.kt index eff16eb3d..4cdf04259 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/integrationtest/CutAndConjunctionIntegrationTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/integrationtest/CutAndConjunctionIntegrationTest.kt @@ -31,7 +31,8 @@ internal class CutAndConjunctionIntegrationTest { modifiedSimpleFactDatabaseGoals.forEach { (goal, solutionList) -> val request = createSolveRequest( - goal, simpleFactTheory, + goal, + simpleFactTheory, mapOf(Conjunction.descriptionPair, Cut.descriptionPair) ) val solutions = Conjunction.wrappedImplementation(request).map { it.solution }.asIterable() @@ -51,7 +52,8 @@ internal class CutAndConjunctionIntegrationTest { modifiedSimpleFactDatabaseGoals.forEach { (goal, solutionList) -> val request = createSolveRequest( - goal, simpleFactTheory, + goal, + simpleFactTheory, mapOf(Conjunction.descriptionPair, Cut.descriptionPair) ) val solutions = Conjunction.wrappedImplementation(request).map { it.solution }.asIterable() diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/CallUtils.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/CallUtils.kt index deddd4ee6..416199b6e 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/CallUtils.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/CallUtils.kt @@ -61,7 +61,8 @@ internal object CallUtils { }.toTypedArray() ).mapKeys { (query, _) -> createSolveRequest( - query, database = simpleFactTheory, + query, + database = simpleFactTheory, primitives = mapOf(*ktListOf(Call, Cut, Conjunction).map { it.descriptionPair }.toTypedArray()) ) } @@ -118,7 +119,8 @@ internal object CallUtils { }.toTypedArray() ).mapKeys { (query, _) -> createSolveRequest( - query, database = simpleFactTheory, + query, + database = simpleFactTheory, primitives = mapOf(*ktListOf(Call, Cut, Conjunction).map { it.descriptionPair }.toTypedArray()) ) } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/CatchUtils.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/CatchUtils.kt index 083159cff..ba55e68ef 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/CatchUtils.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/CatchUtils.kt @@ -5,13 +5,13 @@ import it.unibo.tuprolog.solve.PrologStandardExampleTheories.catchAndThrowTheory import it.unibo.tuprolog.solve.PrologStandardExampleTheories.catchAndThrowTheoryExampleNotableGoalToSolution import it.unibo.tuprolog.solve.Solution import it.unibo.tuprolog.solve.TestingClauseTheories.catchTestingGoalsToSolutions +import it.unibo.tuprolog.solve.changeQueriesTo import it.unibo.tuprolog.solve.exception.PrologError import it.unibo.tuprolog.solve.stdlib.primitive.Call import it.unibo.tuprolog.solve.stdlib.primitive.Catch import it.unibo.tuprolog.solve.stdlib.primitive.Conjunction import it.unibo.tuprolog.solve.stdlib.primitive.Throw import it.unibo.tuprolog.solve.testutils.SolverTestUtils.createSolveRequest -import it.unibo.tuprolog.solve.changeQueriesTo import it.unibo.tuprolog.solve.yes import kotlin.collections.listOf as ktListOf @@ -60,9 +60,9 @@ internal object CatchUtils { prolog { Catch.functor(callRequest.arguments.single(), "X", true).run { createSolveRequest(this, callRequest.context.libraries.theory, updatedPrimitives) to - solutions.map { - yes("X" to (it.exception as PrologError).errorStruct) - } + solutions.map { + yes("X" to (it.exception as PrologError).errorStruct) + } } } }.toTypedArray() @@ -93,5 +93,4 @@ internal object CatchUtils { ) to solutionList } } - } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/ConjunctionUtils.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/ConjunctionUtils.kt index fa3a87756..379d2932f 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/ConjunctionUtils.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/ConjunctionUtils.kt @@ -36,5 +36,4 @@ internal object ConjunctionUtils { "true" and "true" and "fail" ).map { createSolveRequest(it) } } - } diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/PrimitiveUtils.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/PrimitiveUtils.kt index 78d68d5f2..7d2a7c25f 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/PrimitiveUtils.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/PrimitiveUtils.kt @@ -1,8 +1,8 @@ package it.unibo.tuprolog.solve.stdlib.primitive.testutils import it.unibo.tuprolog.solve.Solution -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.exception.PrologError +import it.unibo.tuprolog.solve.primitive.Solve import kotlin.reflect.KClass import kotlin.test.assertEquals diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAbolish.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAbolish.kt index 472159f08..943da46e6 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAbolish.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAbolish.kt @@ -6,7 +6,7 @@ import it.unibo.tuprolog.solve.TestAbolish import kotlin.test.Ignore import kotlin.test.Test -class TestStreamsAbolish : TestAbolish, SolverFactory by StreamsSolverFactory { +class TestStreamsAbolish : TestAbolish, SolverFactory by StreamsSolverFactory { private val prototype = TestAbolish.prototype(this) @Test @@ -38,4 +38,4 @@ class TestStreamsAbolish : TestAbolish, SolverFactory by StreamsSolverFactory { override fun testAbolish() { prototype.testAbolish() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAnd.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAnd.kt index eaf2788ff..161247414 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAnd.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAnd.kt @@ -1,13 +1,6 @@ package it.unibo.tuprolog.solve.systemtest import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory import kotlin.test.Ignore import kotlin.test.Test @@ -40,4 +33,4 @@ class TestStreamsAnd : TestAnd, SolverFactory by StreamsSolverFactory { override fun testTrueVarCallable() { prototype.testTrueVarCallable() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArg.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArg.kt index 244a6d6af..108cadb47 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArg.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArg.kt @@ -1,13 +1,6 @@ package it.unibo.tuprolog.solve.systemtest import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory import kotlin.test.Ignore import kotlin.test.Test @@ -90,4 +83,4 @@ class TestStreamsArg : TestArg, SolverFactory by StreamsSolverFactory { override fun testArgAFromFoo() { prototype.testArgAFromFoo() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArith.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArith.kt index 3677f50d1..1f79a5989 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArith.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArith.kt @@ -1,13 +1,6 @@ package it.unibo.tuprolog.solve.systemtest import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory import kotlin.test.Ignore import kotlin.test.Test @@ -45,4 +38,3 @@ class TestStreamsArith : TestArith, SolverFactory by StreamsSolverFactory { prototype.testArithLessThanEq() } } - diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAssertA.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAssertA.kt index 56ae7fb67..2506bf07d 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAssertA.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAssertA.kt @@ -6,8 +6,7 @@ import it.unibo.tuprolog.solve.TestAssertA import kotlin.test.Ignore import kotlin.test.Test - -class TestStreamsAssertA : TestAssertA, SolverFactory by StreamsSolverFactory{ +class TestStreamsAssertA : TestAssertA, SolverFactory by StreamsSolverFactory { private val prototype = TestAssertA.prototype(this) @@ -39,4 +38,4 @@ class TestStreamsAssertA : TestAssertA, SolverFactory by StreamsSolverFactory{ override fun testAssertAAtomTrue() { prototype.testAssertAAtomTrue() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAssertZ.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAssertZ.kt index 70c05c4c1..37111b3b5 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAssertZ.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAssertZ.kt @@ -1,17 +1,10 @@ package it.unibo.tuprolog.solve.systemtest import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory import kotlin.test.Ignore import kotlin.test.Test -class TestStreamsAssertZ : TestAssertZ, SolverFactory by StreamsSolverFactory{ +class TestStreamsAssertZ : TestAssertZ, SolverFactory by StreamsSolverFactory { private val prototype = TestAssertZ.prototype(this) @@ -43,4 +36,4 @@ class TestStreamsAssertZ : TestAssertZ, SolverFactory by StreamsSolverFactory{ override fun testAssertZAtomTrue() { prototype.testAssertZAtomTrue() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtom.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtom.kt index f2e48dd17..e47047d64 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtom.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtom.kt @@ -1,13 +1,6 @@ package it.unibo.tuprolog.solve.systemtest import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory import kotlin.test.Test class TestStreamsAtom : TestAtom, SolverFactory by StreamsSolverFactory { @@ -48,4 +41,4 @@ class TestStreamsAtom : TestAtom, SolverFactory by StreamsSolverFactory { override fun testAtomNumDec() { prototype.testAtomNumDec() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtomic.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtomic.kt index 55fe3ef7b..426fd1a5e 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtomic.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtomic.kt @@ -1,13 +1,6 @@ package it.unibo.tuprolog.solve.systemtest import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory import kotlin.test.Test class TestStreamsAtomic : TestAtomic, SolverFactory by StreamsSolverFactory { @@ -43,4 +36,4 @@ class TestStreamsAtomic : TestAtomic, SolverFactory by StreamsSolverFactory { override fun testAtomicNumDec() { prototype.testAtomicNumDec() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCall.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCall.kt index 37071d0ac..d8b7cb4e3 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCall.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCall.kt @@ -1,16 +1,16 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.TestCall import kotlin.test.Ignore import kotlin.test.Test -class TestClassicCall : TestCall, SolverFactory by StreamsSolverFactory { +class TestClassicCall : TestCall, SolverFactory by StreamsSolverFactory { private val prototype = TestCall.prototype(this) @Test - override fun testCallCut(){ + override fun testCallCut() { prototype.testCallCut() } @@ -70,4 +70,4 @@ class TestClassicCall : TestCall, SolverFactory by StreamsSolverFactory { override fun testCallTrue() { prototype.testCallTrue() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCatchAndThrow.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCatchAndThrow.kt index e20d8ff3a..9273d2e63 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCatchAndThrow.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCatchAndThrow.kt @@ -1,11 +1,11 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.TestCatchAndThrow import kotlin.test.Test -class TestStreamsCatchAndThrow : TestCatchAndThrow, SolverFactory by StreamsSolverFactory { +class TestStreamsCatchAndThrow : TestCatchAndThrow, SolverFactory by StreamsSolverFactory { private val prototype = TestCatchAndThrow.prototype(this) @Test @@ -17,4 +17,4 @@ class TestStreamsCatchAndThrow : TestCatchAndThrow, SolverFactory by StreamsSolv override fun testCatchFail() { prototype.testCatchFail() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsClause.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsClause.kt index 96ae9b30c..e628ea92c 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsClause.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsClause.kt @@ -7,7 +7,7 @@ import kotlin.test.Ignore import kotlin.test.Test @Ignore -class TestStreamsClause : TestClause, SolverFactory by StreamsSolverFactory { +class TestStreamsClause : TestClause, SolverFactory by StreamsSolverFactory { private val prototype = TestClause.prototype(this) @Test @@ -34,4 +34,4 @@ class TestStreamsClause : TestClause, SolverFactory by StreamsSolverFactory { override fun testClauseAtomBody() { prototype.testClauseAtomBody() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCompound.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCompound.kt index e5228b05b..4c596fd4f 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCompound.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCompound.kt @@ -5,7 +5,7 @@ import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.TestCompound import kotlin.test.Test -class TestStreamsCompound : TestCompound, SolverFactory by StreamsSolverFactory { +class TestStreamsCompound : TestCompound, SolverFactory by StreamsSolverFactory { private val prototype = TestCompound.prototype(this) @Test @@ -42,4 +42,4 @@ class TestStreamsCompound : TestCompound, SolverFactory by StreamsSolverFactory override fun testCompoundListA() { prototype.testCompoundListA() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCopyTerm.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCopyTerm.kt index 8dd69b8c6..6208d6ac2 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCopyTerm.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCopyTerm.kt @@ -1,12 +1,12 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.TestCopyTerm import kotlin.test.Ignore import kotlin.test.Test -class TestStreamsCopyTerm : TestCopyTerm, SolverFactory by StreamsSolverFactory { +class TestStreamsCopyTerm : TestCopyTerm, SolverFactory by StreamsSolverFactory { private val prototype = TestCopyTerm.prototype(this) @Test @@ -57,4 +57,4 @@ class TestStreamsCopyTerm : TestCopyTerm, SolverFactory by StreamsSolverFactory override fun testDoubleCopy() { prototype.testDoubleCopy() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCut.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCut.kt index cdb2fc10b..42f297cdd 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCut.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCut.kt @@ -6,7 +6,7 @@ import it.unibo.tuprolog.solve.TestCut import kotlin.test.Ignore import kotlin.test.Test -class TestStreamsCut: TestCut, SolverFactory by StreamsSolverFactory { +class TestStreamsCut : TestCut, SolverFactory by StreamsSolverFactory { private val prototype = TestCut.prototype(this) @@ -25,4 +25,4 @@ class TestStreamsCut: TestCut, SolverFactory by StreamsSolverFactory { override fun testCallCutFailTrue() { prototype.testCallCutFailTrue() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFail.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFail.kt index f4534557e..502a8d9f1 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFail.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFail.kt @@ -1,12 +1,12 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.TestFail import kotlin.test.Ignore import kotlin.test.Test -class TestStreamsFail : TestFail, SolverFactory by StreamsSolverFactory { +class TestStreamsFail : TestFail, SolverFactory by StreamsSolverFactory { private val prototype = TestFail.prototype(this) @Test @@ -29,4 +29,4 @@ class TestStreamsFail : TestFail, SolverFactory by StreamsSolverFactory { override fun testSetFlagWarning() { prototype.testSetFlagWarning() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFindAll.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFindAll.kt index f8ebbebfc..7f5049643 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFindAll.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFindAll.kt @@ -1,13 +1,6 @@ package it.unibo.tuprolog.solve.systemtest import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory import kotlin.test.Ignore import kotlin.test.Test @@ -62,4 +55,4 @@ class TestStreamsFindAll : TestFindAll, SolverFactory by StreamsSolverFactory { override fun testFindXinCall() { prototype.testFindXinCall() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFloat.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFloat.kt index a70aa5540..9627b205c 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFloat.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFloat.kt @@ -1,11 +1,11 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.TestFloat import kotlin.test.Test -class TestStreamsFloat : TestFloat, SolverFactory by StreamsSolverFactory { +class TestStreamsFloat : TestFloat, SolverFactory by StreamsSolverFactory { private val prototype = TestFloat.prototype(this) @Test @@ -32,4 +32,4 @@ class TestStreamsFloat : TestFloat, SolverFactory by StreamsSolverFactory { override fun testFloatX() { prototype.testFloatX() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFunctor.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFunctor.kt index d56bd946d..668fcef29 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFunctor.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFunctor.kt @@ -1,19 +1,14 @@ package it.unibo.tuprolog.solve.systemtest import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.theory.Theory import kotlin.test.Ignore import kotlin.test.Test -class TestStreamsFunctor : TestFunctor, SolverFactory by StreamsSolverFactory { +class TestStreamsFunctor : TestFunctor, SolverFactory by StreamsSolverFactory { private val prototype = TestFunctor.prototype(this) @Test - override fun testFunArity(){ + override fun testFunArity() { prototype.testFunArity() } @@ -105,4 +100,4 @@ class TestStreamsFunctor : TestFunctor, SolverFactory by StreamsSolverFactory { override fun testFunNegativeArity() { prototype.testFunNegativeArity() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIfThen.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIfThen.kt index 6261e097d..9ee13b920 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIfThen.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIfThen.kt @@ -5,7 +5,7 @@ import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.TestIfThen import kotlin.test.Test -class TestStreamsIfThen : TestIfThen, SolverFactory by StreamsSolverFactory { +class TestStreamsIfThen : TestIfThen, SolverFactory by StreamsSolverFactory { private val prototype = TestIfThen.prototype(this) @Test @@ -37,4 +37,4 @@ class TestStreamsIfThen : TestIfThen, SolverFactory by StreamsSolverFactory { override fun testIfThenXtoOne() { prototype.testIfThenXtoOne() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIfThenElse.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIfThenElse.kt index 896c475c9..9a803bd47 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIfThenElse.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIfThenElse.kt @@ -1,7 +1,7 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.TestIfThenElse import kotlin.test.Test @@ -47,4 +47,4 @@ class TestStreamsIfThenElse : TestIfThenElse, SolverFactory by StreamsSolverFact override fun testIfOrElseTrue() { prototype.testIfOrElseTrue() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsInteger.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsInteger.kt index d6b2f3d6b..6e7feace0 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsInteger.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsInteger.kt @@ -1,13 +1,6 @@ package it.unibo.tuprolog.solve.systemtest import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory import kotlin.test.Test class TestStreamsInteger : TestInteger, SolverFactory by StreamsSolverFactory { @@ -38,4 +31,4 @@ class TestStreamsInteger : TestInteger, SolverFactory by StreamsSolverFactory { override fun testIntAtom() { prototype.testIntAtom() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIs.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIs.kt index 9e7923578..c87dcb402 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIs.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsIs.kt @@ -1,12 +1,12 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.TestIs import kotlin.test.Ignore import kotlin.test.Test -class TestStreamsIs : TestIs, SolverFactory by StreamsSolverFactory { +class TestStreamsIs : TestIs, SolverFactory by StreamsSolverFactory { private val prototype = TestIs.prototype(this) @Test @@ -16,7 +16,7 @@ class TestStreamsIs : TestIs, SolverFactory by StreamsSolverFactory { @Test @Ignore - override fun testIsXY(){ + override fun testIsXY() { prototype.testIsXY() } @@ -41,4 +41,4 @@ class TestStreamsIs : TestIs, SolverFactory by StreamsSolverFactory { override fun testIsXFloat() { prototype.testIsXFloat() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNonVar.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNonVar.kt index 3aae18e19..101ee6101 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNonVar.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNonVar.kt @@ -1,13 +1,6 @@ package it.unibo.tuprolog.solve.systemtest import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory import kotlin.test.Test class TestStreamsNonVar : TestNonVar, SolverFactory by StreamsSolverFactory { @@ -43,4 +36,4 @@ class TestStreamsNonVar : TestNonVar, SolverFactory by StreamsSolverFactory { override fun testNonVar() { prototype.testNonVar() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNotProvable.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNotProvable.kt index 8b17b6458..648b53dfa 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNotProvable.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNotProvable.kt @@ -6,7 +6,7 @@ import it.unibo.tuprolog.solve.TestNotProvable import kotlin.test.Ignore import kotlin.test.Test -class TestStreamsNotProvable : TestNotProvable, SolverFactory by StreamsSolverFactory { +class TestStreamsNotProvable : TestNotProvable, SolverFactory by StreamsSolverFactory { private val prototype = TestNotProvable.prototype(this) @Test @@ -20,7 +20,7 @@ class TestStreamsNotProvable : TestNotProvable, SolverFactory by StreamsSolverFa } @Test - @Ignore //solver returns no + @Ignore // solver returns no override fun testNPCutFail() { prototype.testNPCutFail() } @@ -43,8 +43,8 @@ class TestStreamsNotProvable : TestNotProvable, SolverFactory by StreamsSolverFa } @Test - @Ignore //solver returns no + @Ignore // solver returns no override fun testOrNotCutFail() { prototype.testOrNotCutFail() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNotUnify.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNotUnify.kt index afd276f8d..0279d6a6f 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNotUnify.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNotUnify.kt @@ -1,13 +1,6 @@ package it.unibo.tuprolog.solve.systemtest import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory import kotlin.test.Test class TestStreamsNotUnify : TestNotUnify, SolverFactory by StreamsSolverFactory { @@ -63,5 +56,4 @@ class TestStreamsNotUnify : TestNotUnify, SolverFactory by StreamsSolverFactory override fun testFMultipleTermNotUnify() { prototype.testFMultipleTermNotUnify() } - -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNumber.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNumber.kt index 0abe430c4..e0940eade 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNumber.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNumber.kt @@ -33,5 +33,4 @@ class TestStreamsNumber : TestNumber, SolverFactory by StreamsSolverFactory { override fun testXNum() { prototype.testXNum() } - -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsOnce.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsOnce.kt index 8172053ca..fbaf66994 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsOnce.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsOnce.kt @@ -1,12 +1,12 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.TestOnce import kotlin.test.Ignore import kotlin.test.Test -class TestStreamsOnce : TestOnce, SolverFactory by StreamsSolverFactory { +class TestStreamsOnce : TestOnce, SolverFactory by StreamsSolverFactory { private val prototype = TestOnce.prototype(this) @Test @@ -40,4 +40,4 @@ class TestStreamsOnce : TestOnce, SolverFactory by StreamsSolverFactory { override fun testOnceX() { prototype.testOnceX() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsOr.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsOr.kt index 0c42e92c0..8b2865225 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsOr.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsOr.kt @@ -1,13 +1,6 @@ package it.unibo.tuprolog.solve.systemtest import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory import kotlin.test.Ignore import kotlin.test.Test @@ -42,6 +35,4 @@ class TestStreamsOr : TestOr, SolverFactory by StreamsSolverFactory { override fun testOrDoubleAssignment() { prototype.testOrDoubleAssignment() } - - -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsRepeat.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsRepeat.kt index 6a66144fd..6bb16e26b 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsRepeat.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsRepeat.kt @@ -1,15 +1,15 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.TestRepeat import kotlin.test.Test -class TestStreamsRepeat : TestRepeat, SolverFactory by StreamsSolverFactory { +class TestStreamsRepeat : TestRepeat, SolverFactory by StreamsSolverFactory { private val prototype = TestRepeat.prototype(this) @Test override fun testRepeat() { prototype.testRepeat() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsRetract.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsRetract.kt index 19d957989..38953a338 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsRetract.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsRetract.kt @@ -7,7 +7,7 @@ import kotlin.test.Ignore import kotlin.test.Test @Ignore -class TestStreamsRetract : TestRetract, SolverFactory by StreamsSolverFactory { +class TestStreamsRetract : TestRetract, SolverFactory by StreamsSolverFactory { private val prototype = TestRetract.prototype(this) @Test @@ -19,4 +19,4 @@ class TestStreamsRetract : TestRetract, SolverFactory by StreamsSolverFactory override fun testRetractAtomEmptyList() { prototype.testRetractAtomEmptyList() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsSolver.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsSolver.kt index 3d653dde4..e490a8da8 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsSolver.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsSolver.kt @@ -117,7 +117,6 @@ class TestStreamsSolver : SolverFactory, TestSolver { prototype.testIfThenElse2() } - @Test override fun testTimeout1() { prototype.testTimeout1() diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsTerm.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsTerm.kt index 2a2f278d8..b94e0ef13 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsTerm.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsTerm.kt @@ -1,8 +1,7 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.SolverFactory -import it.unibo.tuprolog.solve.TestInteger +import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.TestTerm import kotlin.test.Test @@ -39,4 +38,4 @@ class TestStreamsTerm : TestTerm, SolverFactory by StreamsSolverFactory { override fun testTermLessThanEq() { prototype.testTermLessThanEq() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsTrue.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsTrue.kt index 1e50b7ea0..ba0b4b7c4 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsTrue.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsTrue.kt @@ -1,15 +1,15 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory import it.unibo.tuprolog.solve.TestTrue import kotlin.test.Test -class TestStreamsTrue : TestTrue, SolverFactory by StreamsSolverFactory { +class TestStreamsTrue : TestTrue, SolverFactory by StreamsSolverFactory { private val prototype = TestTrue.prototype(this) @Test override fun testTrue() { prototype.testTrue() } -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsUnify.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsUnify.kt index 29da05422..676994708 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsUnify.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsUnify.kt @@ -1,13 +1,6 @@ package it.unibo.tuprolog.solve.systemtest import it.unibo.tuprolog.solve.* -import it.unibo.tuprolog.solve.channel.InputChannel -import it.unibo.tuprolog.solve.channel.OutputChannel -import it.unibo.tuprolog.solve.exception.PrologWarning -import it.unibo.tuprolog.solve.library.AliasedLibrary -import it.unibo.tuprolog.solve.library.Libraries -import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins -import it.unibo.tuprolog.theory.Theory import kotlin.test.Ignore import kotlin.test.Test @@ -71,5 +64,4 @@ class TestStreamsUnify : TestUnify, SolverFactory by StreamsSolverFactory { override fun testMultipleTermUnify() { prototype.testMultipleTermUnify() } - -} \ No newline at end of file +} diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/testutils/SolverTestUtils.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/testutils/SolverTestUtils.kt index 62f275f08..0da336798 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/testutils/SolverTestUtils.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/testutils/SolverTestUtils.kt @@ -2,12 +2,12 @@ package it.unibo.tuprolog.solve.testutils import it.unibo.tuprolog.core.Struct import it.unibo.tuprolog.solve.Signature -import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.Solver import it.unibo.tuprolog.solve.extractSignature import it.unibo.tuprolog.solve.library.Libraries import it.unibo.tuprolog.solve.library.Library import it.unibo.tuprolog.solve.primitive.Primitive +import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.solver.StreamsExecutionContext import it.unibo.tuprolog.theory.Theory From abe986aa7f9132b37bec8e4c70da70d216878734 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 14 Sep 2020 16:25:43 +0200 Subject: [PATCH 24/34] remove bulk imports in :solve-streams/src/commonTest --- .../tuprolog/solve/solver/SolverUtilsTest.kt | 27 ++++++++++++++++--- .../solver/fsm/StateMachineExecutorTest.kt | 7 ++++- .../solver/fsm/impl/AbstractTimedStateTest.kt | 5 +++- .../solve/stdlib/primitive/ConjunctionTest.kt | 6 ++++- .../solve/stdlib/primitive/NotTest.kt | 6 ++++- .../stdlib/primitive/testutils/CallUtils.kt | 16 ++++++----- .../solve/systemtest/TestStreamsAnd.kt | 4 ++- .../solve/systemtest/TestStreamsArg.kt | 4 ++- .../solve/systemtest/TestStreamsArith.kt | 4 ++- .../solve/systemtest/TestStreamsAssertZ.kt | 4 ++- .../solve/systemtest/TestStreamsAtom.kt | 4 ++- .../solve/systemtest/TestStreamsAtomic.kt | 4 ++- .../solve/systemtest/TestStreamsCall.kt | 2 +- .../solve/systemtest/TestStreamsFindAll.kt | 4 ++- .../solve/systemtest/TestStreamsFunctor.kt | 4 ++- .../solve/systemtest/TestStreamsInteger.kt | 4 ++- .../solve/systemtest/TestStreamsNonVar.kt | 4 ++- .../solve/systemtest/TestStreamsNotUnify.kt | 4 ++- .../solve/systemtest/TestStreamsOr.kt | 4 ++- .../solve/systemtest/TestStreamsSolver.kt | 7 ++++- .../solve/systemtest/TestStreamsUnify.kt | 4 ++- 21 files changed, 99 insertions(+), 29 deletions(-) diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/SolverUtilsTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/SolverUtilsTest.kt index f0d1fa9e1..fb5071205 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/SolverUtilsTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/SolverUtilsTest.kt @@ -1,12 +1,33 @@ package it.unibo.tuprolog.solve.solver -import it.unibo.tuprolog.core.* -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Clause +import it.unibo.tuprolog.core.Integer +import it.unibo.tuprolog.core.Scope +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Substitution +import it.unibo.tuprolog.core.Truth +import it.unibo.tuprolog.core.Tuple +import it.unibo.tuprolog.core.Var +import it.unibo.tuprolog.solve.DummyInstances +import it.unibo.tuprolog.solve.FlagStore +import it.unibo.tuprolog.solve.Signature +import it.unibo.tuprolog.solve.currentTimeInstant import it.unibo.tuprolog.solve.exception.HaltException +import it.unibo.tuprolog.solve.extractSignature +import it.unibo.tuprolog.solve.halt import it.unibo.tuprolog.solve.library.Libraries +import it.unibo.tuprolog.solve.no import it.unibo.tuprolog.solve.primitive.Solve +import it.unibo.tuprolog.solve.yes import it.unibo.tuprolog.theory.Theory -import kotlin.test.* +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith +import kotlin.test.assertFalse +import kotlin.test.assertSame +import kotlin.test.assertTrue +import kotlin.test.fail /** * Test class for SolverUtils.kt diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/StateMachineExecutorTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/StateMachineExecutorTest.kt index 473f12e72..091319f6e 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/StateMachineExecutorTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/StateMachineExecutorTest.kt @@ -12,7 +12,12 @@ import it.unibo.tuprolog.solve.solver.fsm.testutils.StateMachineExecutorUtils.th import it.unibo.tuprolog.solve.solver.fsm.testutils.StateMachineExecutorUtils.threeShotStateAlreadyExecuted import it.unibo.tuprolog.solve.solver.fsm.testutils.StateMachineExecutorUtils.toBehavedState import it.unibo.tuprolog.solve.solver.fsm.testutils.StateMachineExecutorUtils.twoAlternativeState -import kotlin.test.* +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertSame +import kotlin.test.assertTrue +import kotlin.test.fail /** * Test class for [StateMachineExecutor] diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/AbstractTimedStateTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/AbstractTimedStateTest.kt index e90b015e9..096c01c0d 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/AbstractTimedStateTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/solver/fsm/impl/AbstractTimedStateTest.kt @@ -1,7 +1,10 @@ package it.unibo.tuprolog.solve.solver.fsm.impl import it.unibo.tuprolog.core.Truth -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.ExecutionContext +import it.unibo.tuprolog.solve.TimeDuration +import it.unibo.tuprolog.solve.TimeInstant +import it.unibo.tuprolog.solve.currentTimeInstant import it.unibo.tuprolog.solve.exception.TimeOutException import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.solver.fsm.State diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ConjunctionTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ConjunctionTest.kt index fbe15a5af..b3add8c5e 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ConjunctionTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/ConjunctionTest.kt @@ -1,9 +1,12 @@ package it.unibo.tuprolog.solve.stdlib.primitive import it.unibo.tuprolog.dsl.theory.prolog -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.ExecutionContext +import it.unibo.tuprolog.solve.assertSolutionEquals +import it.unibo.tuprolog.solve.extractSignature import it.unibo.tuprolog.solve.library.Libraries import it.unibo.tuprolog.solve.library.Library +import it.unibo.tuprolog.solve.no import it.unibo.tuprolog.solve.primitive.PrimitiveWrapper import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.solver.StreamsExecutionContext @@ -13,6 +16,7 @@ import it.unibo.tuprolog.solve.stdlib.primitive.testutils.ConjunctionUtils.trueA import it.unibo.tuprolog.solve.stdlib.primitive.testutils.ConjunctionUtils.twoMatchesDB import it.unibo.tuprolog.solve.stdlib.primitive.testutils.PrimitiveUtils.assertOnlyOneSolution import it.unibo.tuprolog.solve.testutils.SolverTestUtils.createSolveRequest +import it.unibo.tuprolog.solve.yes import kotlin.test.Test import kotlin.collections.listOf as ktListOf diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/NotTest.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/NotTest.kt index 6c64808dd..dfa5058e8 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/NotTest.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/NotTest.kt @@ -2,9 +2,13 @@ package it.unibo.tuprolog.solve.stdlib.primitive import it.unibo.tuprolog.dsl.prolog import it.unibo.tuprolog.dsl.theory.PrologScopeWithTheories -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.DummyInstances +import it.unibo.tuprolog.solve.assertSolutionEquals import it.unibo.tuprolog.solve.exception.error.TypeError +import it.unibo.tuprolog.solve.halt +import it.unibo.tuprolog.solve.no import it.unibo.tuprolog.solve.testutils.SolverTestUtils.createSolveRequest +import it.unibo.tuprolog.solve.yes import kotlin.test.Ignore import kotlin.test.Test diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/CallUtils.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/CallUtils.kt index 416199b6e..4a182d2ec 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/CallUtils.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/stdlib/primitive/testutils/CallUtils.kt @@ -1,12 +1,16 @@ package it.unibo.tuprolog.solve.stdlib.primitive.testutils import it.unibo.tuprolog.dsl.theory.prolog -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.DummyInstances +import it.unibo.tuprolog.solve.Solution import it.unibo.tuprolog.solve.TestingClauseTheories.simpleFactTheory import it.unibo.tuprolog.solve.TestingClauseTheories.simpleFactTheoryNotableGoalToSolutions +import it.unibo.tuprolog.solve.changeQueriesTo import it.unibo.tuprolog.solve.exception.PrologError import it.unibo.tuprolog.solve.exception.error.InstantiationError import it.unibo.tuprolog.solve.exception.error.TypeError +import it.unibo.tuprolog.solve.halt +import it.unibo.tuprolog.solve.hasSolutions import it.unibo.tuprolog.solve.primitive.Solve import it.unibo.tuprolog.solve.solver.StreamsExecutionContext import it.unibo.tuprolog.solve.solver.fsm.impl.StateEnd @@ -16,6 +20,7 @@ import it.unibo.tuprolog.solve.stdlib.primitive.Conjunction import it.unibo.tuprolog.solve.stdlib.primitive.Cut import it.unibo.tuprolog.solve.stdlib.primitive.Throw import it.unibo.tuprolog.solve.testutils.SolverTestUtils.createSolveRequest +import it.unibo.tuprolog.solve.yes import kotlin.test.assertEquals import kotlin.test.assertNotNull import kotlin.test.assertTrue @@ -47,12 +52,9 @@ internal object CallUtils { internal val requestSolutionMap by lazy { prolog { mapOf( - Call.functor(true) - .hasSolutions({ yes() }), - Call.functor("true" and "true") - .hasSolutions({ yes() }), - Call.functor("!") - .hasSolutions({ yes() }), + Call.functor(true).hasSolutions({ yes() }), + Call.functor("true" and "true").hasSolutions({ yes() }), + Call.functor("!").hasSolutions({ yes() }), *simpleFactTheoryNotableGoalToSolutions.map { (goal, solutionList) -> Call.functor(goal).run { to(solutionList.changeQueriesTo(this)) } }.toTypedArray(), diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAnd.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAnd.kt index 161247414..9e54bd7b7 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAnd.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAnd.kt @@ -1,6 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.TestAnd import kotlin.test.Ignore import kotlin.test.Test diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArg.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArg.kt index 108cadb47..21b897a5e 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArg.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArg.kt @@ -1,6 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.TestArg import kotlin.test.Ignore import kotlin.test.Test diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArith.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArith.kt index 1f79a5989..24f123100 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArith.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsArith.kt @@ -1,6 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.TestArith import kotlin.test.Ignore import kotlin.test.Test diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAssertZ.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAssertZ.kt index 37111b3b5..44791f03f 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAssertZ.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAssertZ.kt @@ -1,6 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.TestAssertZ import kotlin.test.Ignore import kotlin.test.Test diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtom.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtom.kt index e47047d64..97f598d47 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtom.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtom.kt @@ -1,6 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.TestAtom import kotlin.test.Test class TestStreamsAtom : TestAtom, SolverFactory by StreamsSolverFactory { diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtomic.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtomic.kt index 426fd1a5e..f3d684ee9 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtomic.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsAtomic.kt @@ -1,6 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.TestAtomic import kotlin.test.Test class TestStreamsAtomic : TestAtomic, SolverFactory by StreamsSolverFactory { diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCall.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCall.kt index d8b7cb4e3..e29ef494d 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCall.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsCall.kt @@ -6,7 +6,7 @@ import it.unibo.tuprolog.solve.TestCall import kotlin.test.Ignore import kotlin.test.Test -class TestClassicCall : TestCall, SolverFactory by StreamsSolverFactory { +class TestStreamsCall : TestCall, SolverFactory by StreamsSolverFactory { private val prototype = TestCall.prototype(this) @Test diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFindAll.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFindAll.kt index 7f5049643..0676be60c 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFindAll.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFindAll.kt @@ -1,6 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.TestFindAll import kotlin.test.Ignore import kotlin.test.Test diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFunctor.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFunctor.kt index 668fcef29..9c8a6e568 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFunctor.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsFunctor.kt @@ -1,6 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.TestFunctor import kotlin.test.Ignore import kotlin.test.Test diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsInteger.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsInteger.kt index 6e7feace0..20a0aa53d 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsInteger.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsInteger.kt @@ -1,6 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.TestInteger import kotlin.test.Test class TestStreamsInteger : TestInteger, SolverFactory by StreamsSolverFactory { diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNonVar.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNonVar.kt index 101ee6101..b898b4596 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNonVar.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNonVar.kt @@ -1,6 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.TestNonVar import kotlin.test.Test class TestStreamsNonVar : TestNonVar, SolverFactory by StreamsSolverFactory { diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNotUnify.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNotUnify.kt index 0279d6a6f..78a283ba0 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNotUnify.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsNotUnify.kt @@ -1,6 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.TestNotUnify import kotlin.test.Test class TestStreamsNotUnify : TestNotUnify, SolverFactory by StreamsSolverFactory { diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsOr.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsOr.kt index 8b2865225..806b2c236 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsOr.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsOr.kt @@ -1,6 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.TestOr import kotlin.test.Ignore import kotlin.test.Test diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsSolver.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsSolver.kt index e490a8da8..06e7dcab6 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsSolver.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsSolver.kt @@ -1,12 +1,17 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.FlagStore +import it.unibo.tuprolog.solve.MutableSolver +import it.unibo.tuprolog.solve.Solver +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.TestSolver import it.unibo.tuprolog.solve.channel.InputChannel import it.unibo.tuprolog.solve.channel.OutputChannel import it.unibo.tuprolog.solve.exception.PrologWarning import it.unibo.tuprolog.solve.library.AliasedLibrary import it.unibo.tuprolog.solve.library.Libraries import it.unibo.tuprolog.solve.stdlib.DefaultBuiltins +import it.unibo.tuprolog.solve.streams import it.unibo.tuprolog.theory.Theory import kotlin.test.Ignore import kotlin.test.Test diff --git a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsUnify.kt b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsUnify.kt index 676994708..d23c88716 100644 --- a/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsUnify.kt +++ b/solve-streams/src/commonTest/kotlin/it/unibo/tuprolog/solve/systemtest/TestStreamsUnify.kt @@ -1,6 +1,8 @@ package it.unibo.tuprolog.solve.systemtest -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.SolverFactory +import it.unibo.tuprolog.solve.StreamsSolverFactory +import it.unibo.tuprolog.solve.TestUnify import kotlin.test.Ignore import kotlin.test.Test From 76e88d27ae05bc2aa87da17d4147822690b83507 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 14 Sep 2020 17:19:12 +0200 Subject: [PATCH 25/34] fix Signature --- .../commonMain/kotlin/it/unibo/tuprolog/solve/Signature.kt | 6 +++--- .../it/unibo/tuprolog/solve/primitive/SignatureTest.kt | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Signature.kt b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Signature.kt index 02c60ff46..ac068df91 100644 --- a/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Signature.kt +++ b/solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/Signature.kt @@ -93,9 +93,9 @@ data class Signature( ) } args.last().let { - it is Struct && functor == varargStructFunctor && arity == 2 && - args.first().isInt && - args.last() == varargAtom + it is Struct && it.functor == varargStructFunctor && it.arity == 2 && + it.args.first().isInt && + it.args.last() == varargAtom } -> { Signature( args.first().`as`().value, diff --git a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/primitive/SignatureTest.kt b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/primitive/SignatureTest.kt index fe86b4856..1a180923a 100644 --- a/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/primitive/SignatureTest.kt +++ b/test-solve/src/commonTest/kotlin/it/unibo/tuprolog/solve/primitive/SignatureTest.kt @@ -100,7 +100,11 @@ internal class SignatureTest { @Test fun fromTermWithStructCreatesCorrectInstance() { - signatures.forEach { assertEquals(it, Signature.fromSignatureTerm(it.toTerm()) ?: fail()) } + signatures.forEach { + val reconstructed = Signature.fromSignatureTerm(it.toTerm()) + ?: fail("Cannot reconstruct signature $it from it.toTerm(): ${it.toTerm()}") + assertEquals(it, reconstructed) + } signatureTerms.zip(signatures).forEach { (signatureTerm, signature) -> assertEquals(signature, Signature.fromSignatureTerm(signatureTerm) ?: fail()) From 890d93570993550cb18f09f66b21d9cbbacd12b7 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 14 Sep 2020 17:21:50 +0200 Subject: [PATCH 26/34] format code in :parser-theory --- .../it/unibo/tuprolog/theory/parsing/ClausesParser.kt | 2 +- .../tuprolog/theory/parsing/ClausesParserExtensions.kt | 2 +- .../unibo/tuprolog/theory/parsing/TestClausesParser.kt | 10 ++++++---- .../unibo/tuprolog/theory/parsing/ClausesParserImpl.kt | 2 +- .../unibo/tuprolog/theory/parsing/ClausesParserImpl.kt | 4 ++-- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/parser-theory/src/commonMain/kotlin/it/unibo/tuprolog/theory/parsing/ClausesParser.kt b/parser-theory/src/commonMain/kotlin/it/unibo/tuprolog/theory/parsing/ClausesParser.kt index 7d85b78cd..136369207 100644 --- a/parser-theory/src/commonMain/kotlin/it/unibo/tuprolog/theory/parsing/ClausesParser.kt +++ b/parser-theory/src/commonMain/kotlin/it/unibo/tuprolog/theory/parsing/ClausesParser.kt @@ -55,4 +55,4 @@ interface ClausesParser { @JsName("withOperators") fun withOperators(vararg operators: Operator) = withOperators(OperatorSet(*operators)) } -} \ No newline at end of file +} diff --git a/parser-theory/src/commonMain/kotlin/it/unibo/tuprolog/theory/parsing/ClausesParserExtensions.kt b/parser-theory/src/commonMain/kotlin/it/unibo/tuprolog/theory/parsing/ClausesParserExtensions.kt index d06eac5a8..7275b29d1 100644 --- a/parser-theory/src/commonMain/kotlin/it/unibo/tuprolog/theory/parsing/ClausesParserExtensions.kt +++ b/parser-theory/src/commonMain/kotlin/it/unibo/tuprolog/theory/parsing/ClausesParserExtensions.kt @@ -42,4 +42,4 @@ fun String.parseAsClausesLazily(operators: OperatorSet): Sequence = @JsName("parseAsClausesLazily") fun String.parseAsClausesLazily(): Sequence = - defaultParser.parseClausesLazily(this) \ No newline at end of file + defaultParser.parseClausesLazily(this) diff --git a/parser-theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/parsing/TestClausesParser.kt b/parser-theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/parsing/TestClausesParser.kt index dd72efa77..255b1108d 100644 --- a/parser-theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/parsing/TestClausesParser.kt +++ b/parser-theory/src/commonTest/kotlin/it/unibo/tuprolog/theory/parsing/TestClausesParser.kt @@ -15,7 +15,7 @@ class TestClausesParser { companion object { fun assertMatch(expected: Term, actual: Term) { - assertTrue("Term `$actual` does not unify with `$expected`"){ + assertTrue("Term `$actual` does not unify with `$expected`") { Unificator.default.match(expected, actual) } } @@ -65,7 +65,8 @@ class TestClausesParser { @Test fun testTheoryWithCustomOperator() { - val input = """ + val input = + """ |:- op(900, xfy, '::'). |nil. |1 :: nil. @@ -95,7 +96,8 @@ class TestClausesParser { @Test fun testTheoryWithCustomOperators() { - val input = """ + val input = + """ |:- op(900, yfx, ['++', '--']). |1 ++ 2. |1 -- 2. @@ -127,4 +129,4 @@ class TestClausesParser { fact { "++"("--"("++"(1, 2), 3), 4) } } } -} \ No newline at end of file +} diff --git a/parser-theory/src/jsMain/kotlin/it/unibo/tuprolog/theory/parsing/ClausesParserImpl.kt b/parser-theory/src/jsMain/kotlin/it/unibo/tuprolog/theory/parsing/ClausesParserImpl.kt index 7c534d312..90c06c9ff 100644 --- a/parser-theory/src/jsMain/kotlin/it/unibo/tuprolog/theory/parsing/ClausesParserImpl.kt +++ b/parser-theory/src/jsMain/kotlin/it/unibo/tuprolog/theory/parsing/ClausesParserImpl.kt @@ -15,4 +15,4 @@ class ClausesParserImpl(override val defaultOperatorSet: OperatorSet) : ClausesP .map { it.accept(PrologVisitor()) } .map { it.toClause() } } -} \ No newline at end of file +} diff --git a/parser-theory/src/jvmMain/kotlin/it/unibo/tuprolog/theory/parsing/ClausesParserImpl.kt b/parser-theory/src/jvmMain/kotlin/it/unibo/tuprolog/theory/parsing/ClausesParserImpl.kt index 9c5739a49..48df678fb 100644 --- a/parser-theory/src/jvmMain/kotlin/it/unibo/tuprolog/theory/parsing/ClausesParserImpl.kt +++ b/parser-theory/src/jvmMain/kotlin/it/unibo/tuprolog/theory/parsing/ClausesParserImpl.kt @@ -12,6 +12,6 @@ class ClausesParserImpl(override val defaultOperatorSet: OperatorSet) : ClausesP return PrologParserFactory.parseClauses(input, operators) .asSequence() .map { it.accept(PrologExpressionVisitor()) } - .map { it.toClause()} + .map { it.toClause() } } -} \ No newline at end of file +} From fdbfeac3b7d64828af8bafc10dc493c6d9c03b99 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 14 Sep 2020 17:22:38 +0200 Subject: [PATCH 27/34] format code in :repl --- repl/build.gradle.kts | 2 +- .../kotlin/it/unibo/tuprolog/ui/repl/NullInputException.kt | 2 +- .../it/unibo/tuprolog/ui/repl/PlatformSpecificUtils.kt | 2 +- .../kotlin/it/unibo/tuprolog/ui/repl/TuPrologCmd.kt | 5 ++--- .../kotlin/it/unibo/tuprolog/ui/repl/TuPrologSolveQuery.kt | 5 +---- .../kotlin/it/unibo/tuprolog/ui/repl/TuPrologUtils.kt | 3 +-- .../it/unibo/tuprolog/ui/repl/PlatformSpecificUtils.kt | 2 +- repl/src/jsMain/kotlin/it/unibo/tuprolog/ui/repl/Repl.kt | 2 +- repl/src/jvmMain/kotlin/it/unibo/tuprolog/ui/repl/Main.kt | 3 +-- .../it/unibo/tuprolog/ui/repl/PlatformSpecificUtils.kt | 2 +- 10 files changed, 11 insertions(+), 17 deletions(-) diff --git a/repl/build.gradle.kts b/repl/build.gradle.kts index 177c7a9b7..f154181c3 100644 --- a/repl/build.gradle.kts +++ b/repl/build.gradle.kts @@ -60,4 +60,4 @@ if (githubToken != null) { rootProject.tasks.withType(GithubReleaseTask::class) { dependsOn(shadowJar) } -} \ No newline at end of file +} diff --git a/repl/src/commonMain/kotlin/it/unibo/tuprolog/ui/repl/NullInputException.kt b/repl/src/commonMain/kotlin/it/unibo/tuprolog/ui/repl/NullInputException.kt index 8a1cf6651..16e33467b 100644 --- a/repl/src/commonMain/kotlin/it/unibo/tuprolog/ui/repl/NullInputException.kt +++ b/repl/src/commonMain/kotlin/it/unibo/tuprolog/ui/repl/NullInputException.kt @@ -6,4 +6,4 @@ class NullInputException : TuPrologException { constructor(message: String?, cause: Throwable?) : super(message, cause) constructor(cause: Throwable?) : super(cause) constructor(message: String?) : this(message, null) -} \ No newline at end of file +} diff --git a/repl/src/commonMain/kotlin/it/unibo/tuprolog/ui/repl/PlatformSpecificUtils.kt b/repl/src/commonMain/kotlin/it/unibo/tuprolog/ui/repl/PlatformSpecificUtils.kt index 3448edb91..6045ed7e5 100644 --- a/repl/src/commonMain/kotlin/it/unibo/tuprolog/ui/repl/PlatformSpecificUtils.kt +++ b/repl/src/commonMain/kotlin/it/unibo/tuprolog/ui/repl/PlatformSpecificUtils.kt @@ -4,4 +4,4 @@ import it.unibo.tuprolog.theory.Theory expect fun isReadableFile(path: String): Boolean -expect fun loadTheoryFromFile(path: String): Theory \ No newline at end of file +expect fun loadTheoryFromFile(path: String): Theory diff --git a/repl/src/commonMain/kotlin/it/unibo/tuprolog/ui/repl/TuPrologCmd.kt b/repl/src/commonMain/kotlin/it/unibo/tuprolog/ui/repl/TuPrologCmd.kt index ffa2cb990..3e9a038c3 100644 --- a/repl/src/commonMain/kotlin/it/unibo/tuprolog/ui/repl/TuPrologCmd.kt +++ b/repl/src/commonMain/kotlin/it/unibo/tuprolog/ui/repl/TuPrologCmd.kt @@ -62,7 +62,8 @@ class TuPrologCmd : CliktCommand( |# Line : ${e.line} |# Column : ${e.column} |# Clause : ${e.clauseIndex} - """.trimMargin(), err = true + """.trimMargin(), + err = true ) } } @@ -101,5 +102,3 @@ class TuPrologCmd : CliktCommand( ) } } - - diff --git a/repl/src/commonMain/kotlin/it/unibo/tuprolog/ui/repl/TuPrologSolveQuery.kt b/repl/src/commonMain/kotlin/it/unibo/tuprolog/ui/repl/TuPrologSolveQuery.kt index 457d8444f..927f6c59f 100644 --- a/repl/src/commonMain/kotlin/it/unibo/tuprolog/ui/repl/TuPrologSolveQuery.kt +++ b/repl/src/commonMain/kotlin/it/unibo/tuprolog/ui/repl/TuPrologSolveQuery.kt @@ -1,8 +1,6 @@ package it.unibo.tuprolog.ui.repl import com.github.ajalt.clikt.core.CliktCommand -import com.github.ajalt.clikt.core.ProgramResult -import com.github.ajalt.clikt.output.TermUi import com.github.ajalt.clikt.parameters.arguments.argument import com.github.ajalt.clikt.parameters.options.default import com.github.ajalt.clikt.parameters.options.option @@ -22,7 +20,6 @@ class TuPrologSolveQuery : CliktCommand(help = "Compute a particular query and t private val parentCommand: TuPrologCmd get() = currentContext.parent?.command as TuPrologCmd - override fun run() { val solver = parentCommand.getSolver() evalAndPrint(solver) @@ -45,4 +42,4 @@ class TuPrologSolveQuery : CliktCommand(help = "Compute a particular query and t TODO("throw adequate exception") } } -} \ No newline at end of file +} diff --git a/repl/src/commonMain/kotlin/it/unibo/tuprolog/ui/repl/TuPrologUtils.kt b/repl/src/commonMain/kotlin/it/unibo/tuprolog/ui/repl/TuPrologUtils.kt index d7d74d730..05488e775 100644 --- a/repl/src/commonMain/kotlin/it/unibo/tuprolog/ui/repl/TuPrologUtils.kt +++ b/repl/src/commonMain/kotlin/it/unibo/tuprolog/ui/repl/TuPrologUtils.kt @@ -3,7 +3,6 @@ package it.unibo.tuprolog.ui.repl import com.github.ajalt.clikt.core.ProgramResult import com.github.ajalt.clikt.output.TermUi import com.github.ajalt.clikt.output.defaultCliktConsole -import it.unibo.tuprolog.core.TermFormatter import it.unibo.tuprolog.core.TermFormatter.Companion.prettyExpressions import it.unibo.tuprolog.core.format import it.unibo.tuprolog.core.operators.OperatorSet @@ -125,4 +124,4 @@ object TuPrologUtils { } printEndOfSolutions() } -} \ No newline at end of file +} diff --git a/repl/src/jsMain/kotlin/it/unibo/tuprolog/ui/repl/PlatformSpecificUtils.kt b/repl/src/jsMain/kotlin/it/unibo/tuprolog/ui/repl/PlatformSpecificUtils.kt index f35cbbbe7..b4c7a9541 100644 --- a/repl/src/jsMain/kotlin/it/unibo/tuprolog/ui/repl/PlatformSpecificUtils.kt +++ b/repl/src/jsMain/kotlin/it/unibo/tuprolog/ui/repl/PlatformSpecificUtils.kt @@ -8,4 +8,4 @@ actual fun isReadableFile(path: String): Boolean { actual fun loadTheoryFromFile(path: String): Theory { TODO("Not yet implemented") -} \ No newline at end of file +} diff --git a/repl/src/jsMain/kotlin/it/unibo/tuprolog/ui/repl/Repl.kt b/repl/src/jsMain/kotlin/it/unibo/tuprolog/ui/repl/Repl.kt index 3eb09973d..c0076605d 100644 --- a/repl/src/jsMain/kotlin/it/unibo/tuprolog/ui/repl/Repl.kt +++ b/repl/src/jsMain/kotlin/it/unibo/tuprolog/ui/repl/Repl.kt @@ -4,4 +4,4 @@ import com.github.ajalt.clikt.core.subcommands fun main(args: Array) { TuPrologCmd().subcommands(TuPrologSolveQuery()).main(args) -} \ No newline at end of file +} diff --git a/repl/src/jvmMain/kotlin/it/unibo/tuprolog/ui/repl/Main.kt b/repl/src/jvmMain/kotlin/it/unibo/tuprolog/ui/repl/Main.kt index 4b1c74fe6..edc5a7f78 100644 --- a/repl/src/jvmMain/kotlin/it/unibo/tuprolog/ui/repl/Main.kt +++ b/repl/src/jvmMain/kotlin/it/unibo/tuprolog/ui/repl/Main.kt @@ -3,8 +3,7 @@ package it.unibo.tuprolog.ui.repl import com.github.ajalt.clikt.core.subcommands -import kotlin.jvm.JvmName fun main(args: Array) { TuPrologCmd().subcommands(TuPrologSolveQuery()).main(args) -} \ No newline at end of file +} diff --git a/repl/src/jvmMain/kotlin/it/unibo/tuprolog/ui/repl/PlatformSpecificUtils.kt b/repl/src/jvmMain/kotlin/it/unibo/tuprolog/ui/repl/PlatformSpecificUtils.kt index f4b626b10..1197738eb 100644 --- a/repl/src/jvmMain/kotlin/it/unibo/tuprolog/ui/repl/PlatformSpecificUtils.kt +++ b/repl/src/jvmMain/kotlin/it/unibo/tuprolog/ui/repl/PlatformSpecificUtils.kt @@ -12,4 +12,4 @@ actual fun loadTheoryFromFile(path: String): Theory { return File(path).let { Theory.parse(it.readText()) } -} \ No newline at end of file +} From 9009a60a3aaa745787b7ffd2c5020095e00c2206 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 14 Sep 2020 17:24:57 +0200 Subject: [PATCH 28/34] format code in :serialization-core --- .../serialize/DeobjectificationException.kt | 2 +- .../unibo/tuprolog/serialize/Deobjectifier.kt | 2 +- .../unibo/tuprolog/serialize/Deserializer.kt | 2 +- .../it/unibo/tuprolog/serialize/MimeType.kt | 3 +- .../unibo/tuprolog/serialize/Objectifier.kt | 1 - .../unibo/tuprolog/serialize/ObjectsUtils.kt | 2 +- .../serialize/SerializationException.kt | 2 +- .../it/unibo/tuprolog/serialize/Serializer.kt | 2 +- .../tuprolog/serialize/TermDeobjectifier.kt | 2 +- .../tuprolog/serialize/TermDeserializer.kt | 2 +- .../tuprolog/serialize/TermObjectifier.kt | 2 +- .../tuprolog/serialize/TermSerialization.kt | 2 +- .../tuprolog/serialize/TermSerializer.kt | 3 +- .../serialize/TestTermDeserializer.kt | 26 +++++++++----- .../tuprolog/serialize/TestTermSerializer.kt | 21 +++++++----- .../it/unibo/tuprolog/serialize/TestUtils.kt | 17 ++++++---- .../tuprolog/serialize/JsTermDeobjectifier.kt | 28 +++++++++------ .../tuprolog/serialize/JsTermDeserializer.kt | 2 +- .../tuprolog/serialize/JsTermObjectifier.kt | 20 +++++++++-- .../tuprolog/serialize/JsTermSerializer.kt | 2 +- .../it/unibo/tuprolog/serialize/JsUtils.kt | 2 +- .../unibo/tuprolog/serialize/ObjectsUtils.kt | 2 +- .../tuprolog/serialize/TermSerialization.kt | 2 +- .../it/unibo/tuprolog/serialize/YAML.kt | 2 +- .../serialize/JvmTermDeobjectifier.kt | 34 ++++++++++++------- .../tuprolog/serialize/JvmTermDeserializer.kt | 3 +- .../tuprolog/serialize/JvmTermObjectifier.kt | 18 ++++++++-- .../tuprolog/serialize/JvmTermSerializer.kt | 2 +- .../unibo/tuprolog/serialize/ObjectsUtils.kt | 2 +- .../tuprolog/serialize/ReadingDeserializer.kt | 2 +- .../serialize/ReadingTermDeserializer.kt | 2 +- .../tuprolog/serialize/TermSerialization.kt | 2 +- .../tuprolog/serialize/WritingSerializer.kt | 2 +- .../serialize/WritingTermSerializer.kt | 2 +- 34 files changed, 140 insertions(+), 80 deletions(-) diff --git a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/DeobjectificationException.kt b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/DeobjectificationException.kt index 639e5dca7..1b43b4497 100644 --- a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/DeobjectificationException.kt +++ b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/DeobjectificationException.kt @@ -2,4 +2,4 @@ package it.unibo.tuprolog.serialize import it.unibo.tuprolog.core.exception.TuPrologException -class DeobjectificationException(`object`: Any) : TuPrologException("Error while deobjectifying $`object`") \ No newline at end of file +class DeobjectificationException(`object`: Any) : TuPrologException("Error while deobjectifying $`object`") diff --git a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/Deobjectifier.kt b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/Deobjectifier.kt index 526f44cfb..41fac7b34 100644 --- a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/Deobjectifier.kt +++ b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/Deobjectifier.kt @@ -8,4 +8,4 @@ interface Deobjectifier { @JsName("deobjectifyMany") fun deobjectifyMany(`object`: Any): Iterable -} \ No newline at end of file +} diff --git a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/Deserializer.kt b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/Deserializer.kt index cc9baea8c..382ea5e1e 100644 --- a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/Deserializer.kt +++ b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/Deserializer.kt @@ -11,4 +11,4 @@ interface Deserializer { @JsName("deserializeMany") fun deserializeMany(string: String): Iterable -} \ No newline at end of file +} diff --git a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/MimeType.kt b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/MimeType.kt index 1b5030b15..a4c40d294 100644 --- a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/MimeType.kt +++ b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/MimeType.kt @@ -14,5 +14,4 @@ sealed class MimeType( object Yaml : MimeType("application", "yaml") object Xml : MimeType("application", "xml") - -} \ No newline at end of file +} diff --git a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/Objectifier.kt b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/Objectifier.kt index 6c0d73000..ea507ae29 100644 --- a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/Objectifier.kt +++ b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/Objectifier.kt @@ -17,4 +17,3 @@ interface Objectifier { fun objectifyMany(values: Sequence): Any = objectifyMany(values.asIterable()) } - diff --git a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/ObjectsUtils.kt b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/ObjectsUtils.kt index 6f234684d..23188d228 100644 --- a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/ObjectsUtils.kt +++ b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/ObjectsUtils.kt @@ -4,4 +4,4 @@ expect object ObjectsUtils { fun parseAsObject(string: String, mimeType: MimeType): Any fun deeplyEqual(obj1: Any?, obj2: Any?): Boolean -} \ No newline at end of file +} diff --git a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/SerializationException.kt b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/SerializationException.kt index 91a084c17..837bf6fd3 100644 --- a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/SerializationException.kt +++ b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/SerializationException.kt @@ -3,4 +3,4 @@ package it.unibo.tuprolog.serialize import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.core.exception.TuPrologException -class SerializationException(term: Term) : TuPrologException("Error while serialising $term") \ No newline at end of file +class SerializationException(term: Term) : TuPrologException("Error while serialising $term") diff --git a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/Serializer.kt b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/Serializer.kt index 48442f675..f796c011b 100644 --- a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/Serializer.kt +++ b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/Serializer.kt @@ -19,4 +19,4 @@ interface Serializer { @JsName("serializeManySequence") fun serializeMany(values: Sequence): String = serializeMany(values.asIterable()) -} \ No newline at end of file +} diff --git a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TermDeobjectifier.kt b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TermDeobjectifier.kt index 8736ec752..761f5fd68 100644 --- a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TermDeobjectifier.kt +++ b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TermDeobjectifier.kt @@ -11,4 +11,4 @@ interface TermDeobjectifier : Deobjectifier { val default: TermDeobjectifier get() = termDeobjectifier() } -} \ No newline at end of file +} diff --git a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TermDeserializer.kt b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TermDeserializer.kt index c1e407ced..070e375e6 100644 --- a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TermDeserializer.kt +++ b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TermDeserializer.kt @@ -12,4 +12,4 @@ interface TermDeserializer : Deserializer { return termDeserializer(mimeType) } } -} \ No newline at end of file +} diff --git a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TermObjectifier.kt b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TermObjectifier.kt index c7332c740..64d21619a 100644 --- a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TermObjectifier.kt +++ b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TermObjectifier.kt @@ -14,4 +14,4 @@ interface TermObjectifier : Objectifier, TermVisitor { val default: TermObjectifier get() = termObjectifier() } -} \ No newline at end of file +} diff --git a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TermSerialization.kt b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TermSerialization.kt index 931b6dc21..d6ce3cec1 100644 --- a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TermSerialization.kt +++ b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TermSerialization.kt @@ -10,4 +10,4 @@ expect fun termDeserializer(mimeType: MimeType): TermDeserializer expect fun termObjectifier(): TermObjectifier -expect fun termDeobjectifier(): TermDeobjectifier \ No newline at end of file +expect fun termDeobjectifier(): TermDeobjectifier diff --git a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TermSerializer.kt b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TermSerializer.kt index 8e66c4af1..e2a7a73bf 100644 --- a/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TermSerializer.kt +++ b/serialize-core/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TermSerializer.kt @@ -13,5 +13,4 @@ interface TermSerializer : Serializer { return termSerializer(mimeType) } } - -} \ No newline at end of file +} diff --git a/serialize-core/src/commonTest/kotlin/it/unibo/tuprolog/serialize/TestTermDeserializer.kt b/serialize-core/src/commonTest/kotlin/it/unibo/tuprolog/serialize/TestTermDeserializer.kt index 002c87fc5..a0596d4af 100644 --- a/serialize-core/src/commonTest/kotlin/it/unibo/tuprolog/serialize/TestTermDeserializer.kt +++ b/serialize-core/src/commonTest/kotlin/it/unibo/tuprolog/serialize/TestTermDeserializer.kt @@ -56,7 +56,6 @@ class TestTermDeserializer { deserializer.assertTermDeserializationWorks("\"other atom\"") { atomOf("other atom") } - } @Test @@ -96,7 +95,8 @@ class TestTermDeserializer { fun testListDeserializationInYAML() { val deserializer: TermDeserializer = TermDeserializer.of(MimeType.Yaml) assertEquals(MimeType.Yaml, deserializer.mimeType) - val actual = """ + val actual = + """ |list: |- hello |- 1 @@ -120,7 +120,8 @@ class TestTermDeserializer { fun testSetDeserializationInYAML() { val deserializer: TermDeserializer = TermDeserializer.of(MimeType.Yaml) assertEquals(MimeType.Yaml, deserializer.mimeType) - val actual = """ + val actual = + """ |set: |- "hello" |- 1 @@ -142,7 +143,9 @@ class TestTermDeserializer { deserializer.assertTermDeserializationWorks("{\"fun\":\"f\",\"args\":[\"prova 2\",{\"real\":3.0},{\"list\":[\"qua ci va una lista\",true]}]}") { structOf( - "f", atomOf("prova 2"), realOf(3.0), + "f", + atomOf("prova 2"), + realOf(3.0), listOf(atomOf("qua ci va una lista"), truthOf(true)) ) } @@ -152,7 +155,8 @@ class TestTermDeserializer { fun testStructDeserializationInYAML() { val deserializer: TermDeserializer = TermDeserializer.of(MimeType.Yaml) assertEquals(MimeType.Yaml, deserializer.mimeType) - var actual = """ + var actual = + """ |fun: f |args: |- hello @@ -162,7 +166,8 @@ class TestTermDeserializer { structOf("f", atomOf("hello"), numOf(2)) } - actual = """ + actual = + """ |fun: "f" |args: |- "prova 2" @@ -173,7 +178,9 @@ class TestTermDeserializer { """.trimMargin() deserializer.assertTermDeserializationWorks(actual) { structOf( - "f", atomOf("prova 2"), realOf(3.0), + "f", + atomOf("prova 2"), + realOf(3.0), listOf(atomOf("qua ci va una lista"), truthOf(true)) ) } @@ -196,7 +203,8 @@ class TestTermDeserializer { assertEquals(MimeType.Yaml, deserializer.mimeType) - val actual = """ + val actual = + """ |var: "X" """.trimMargin() deserializer.assertTermDeserializationWorks(actual) { @@ -227,4 +235,4 @@ class TestTermDeserializer { truthOf(false) } } -} \ No newline at end of file +} diff --git a/serialize-core/src/commonTest/kotlin/it/unibo/tuprolog/serialize/TestTermSerializer.kt b/serialize-core/src/commonTest/kotlin/it/unibo/tuprolog/serialize/TestTermSerializer.kt index 950555f7b..f066ed040 100644 --- a/serialize-core/src/commonTest/kotlin/it/unibo/tuprolog/serialize/TestTermSerializer.kt +++ b/serialize-core/src/commonTest/kotlin/it/unibo/tuprolog/serialize/TestTermSerializer.kt @@ -91,7 +91,8 @@ class TestTermSerializer { assertEquals(MimeType.Yaml, serializer.mimeType) - var expected = """ + var expected = + """ |list: |- hello |- false @@ -100,7 +101,8 @@ class TestTermSerializer { listOf(atomOf("hello"), truthOf(false)) } - expected = """ + expected = + """ |list: |- hello |- 1 @@ -146,7 +148,8 @@ class TestTermSerializer { assertEquals(MimeType.Yaml, serializer.mimeType) - var expected = """ + var expected = + """ |set: |- hello |- false @@ -155,7 +158,8 @@ class TestTermSerializer { setOf(atomOf("hello"), truthOf(false)) } - expected = """ + expected = + """ |set: |- hello |- 1 @@ -181,7 +185,8 @@ class TestTermSerializer { assertEquals(MimeType.Yaml, serializer.mimeType) - val expected = """ + val expected = + """ |fun: f |args: |- hello @@ -228,7 +233,6 @@ class TestTermSerializer { val serializer: TermSerializer = TermSerializer.of(MimeType.Json) assertEquals(MimeType.Json, serializer.mimeType) - serializer.assertTermSerializationWorks("{\"var\":\"Y\"}") { varOf("Y") } @@ -243,7 +247,8 @@ class TestTermSerializer { val serializer: TermSerializer = TermSerializer.of(MimeType.Yaml) assertEquals(MimeType.Yaml, serializer.mimeType) - val expected = """ + val expected = + """ |var: "Y" """.trimMargin() @@ -251,4 +256,4 @@ class TestTermSerializer { varOf("Y") } } -} \ No newline at end of file +} diff --git a/serialize-core/src/commonTest/kotlin/it/unibo/tuprolog/serialize/TestUtils.kt b/serialize-core/src/commonTest/kotlin/it/unibo/tuprolog/serialize/TestUtils.kt index da8acf691..8ab33bdcb 100644 --- a/serialize-core/src/commonTest/kotlin/it/unibo/tuprolog/serialize/TestUtils.kt +++ b/serialize-core/src/commonTest/kotlin/it/unibo/tuprolog/serialize/TestUtils.kt @@ -1,6 +1,7 @@ package it.unibo.tuprolog.serialize -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Scope +import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.serialize.ObjectsUtils.deeplyEqual import it.unibo.tuprolog.serialize.ObjectsUtils.parseAsObject @@ -10,13 +11,15 @@ import it.unibo.tuprolog.serialize.ObjectsUtils.parseAsObject fun Serializer.assertSerializationWorks(expected: String, actual: T) { val expectedObj = parseAsObject(expected, mimeType) val actualObj = TermObjectifier.default.objectify(actual) - kotlin.test.assertTrue(""" + kotlin.test.assertTrue( + """ |Expected: | $expectedObj |got instead: | $actualObj | - """.trimMargin()) { deeplyEqual(expectedObj, actualObj) } + """.trimMargin() + ) { deeplyEqual(expectedObj, actualObj) } } /** @@ -42,13 +45,15 @@ fun Serializer.assertTermSerializationWorks(expected: String, actualGenera */ fun Deserializer.assertDeserializationWorks(expected: T, actual: String) { val deserialized = deserialize(actual) - kotlin.test.assertTrue(""" + kotlin.test.assertTrue( + """ |Expected: | $expected |got: | $deserialized | - """.trimMargin()) { expected.equals(deserialized, false) } + """.trimMargin() + ) { expected.equals(deserialized, false) } } /** @@ -67,4 +72,4 @@ fun Deserializer.assertDeserializationWorks(expected: T, actual: S */ fun Deserializer.assertTermDeserializationWorks(actual: String, expectedGenerator: Scope.() -> Term) { assertDeserializationWorks(Scope.empty().expectedGenerator(), actual) -} \ No newline at end of file +} diff --git a/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTermDeobjectifier.kt b/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTermDeobjectifier.kt index 7c7f3927b..163747fcf 100644 --- a/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTermDeobjectifier.kt +++ b/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTermDeobjectifier.kt @@ -85,24 +85,31 @@ internal class JsTermDeobjectifier : TermDeobjectifier { private fun deobjectifyTuple(value: dynamic): Term { val items = value["tuple"] as? Array<*> ?: throw DeobjectificationException(value) - return scope.tupleOf(items.map { - deobjectify(it ?: throw DeobjectificationException(value)) - }) + return scope.tupleOf( + items.map { + deobjectify(it ?: throw DeobjectificationException(value)) + } + ) } private fun deobjectifySet(value: dynamic): Term { val items = value["set"] as? Array<*> ?: throw DeobjectificationException(value) - return scope.setOf(items.map { - deobjectify(it ?: throw DeobjectificationException(value)) - }) + return scope.setOf( + items.map { + deobjectify(it ?: throw DeobjectificationException(value)) + } + ) } private fun deobjectifyStructure(value: dynamic): Term { val name = value["fun"] as? String ?: throw DeobjectificationException(value) val args = value["args"] as? Array<*> ?: throw DeobjectificationException(value) - return scope.structOf(name, args.map { - deobjectify(it ?: throw DeobjectificationException(value)) - }) + return scope.structOf( + name, + args.map { + deobjectify(it ?: throw DeobjectificationException(value)) + } + ) } private fun deobjectifyVariable(value: dynamic): Term { @@ -125,5 +132,4 @@ internal class JsTermDeobjectifier : TermDeobjectifier { private fun deobjectifyNumber(value: dynamic): Term { return scope.numOf(value.toString()) } - -} \ No newline at end of file +} diff --git a/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTermDeserializer.kt b/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTermDeserializer.kt index 6ed674ede..b219e6eb1 100644 --- a/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTermDeserializer.kt +++ b/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTermDeserializer.kt @@ -15,4 +15,4 @@ internal class JsTermDeserializer(override val mimeType: MimeType) : TermDeseria is MimeType.Json -> JSON.parse(string) is MimeType.Yaml -> YAML.parse(string) } as Any -} \ No newline at end of file +} diff --git a/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTermObjectifier.kt b/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTermObjectifier.kt index ecce00b1b..d1603016f 100644 --- a/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTermObjectifier.kt +++ b/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTermObjectifier.kt @@ -1,6 +1,22 @@ package it.unibo.tuprolog.serialize -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +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.List +import it.unibo.tuprolog.core.Real +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.Truth +import it.unibo.tuprolog.core.Tuple +import it.unibo.tuprolog.core.Var internal class JsTermObjectifier : TermObjectifier { override fun defaultValue(term: Term): Any { @@ -107,4 +123,4 @@ internal class JsTermObjectifier : TermObjectifier { jsObject( "body" to term.body.accept(this) ) -} \ No newline at end of file +} diff --git a/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTermSerializer.kt b/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTermSerializer.kt index 821bdbddb..30f592e2e 100644 --- a/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTermSerializer.kt +++ b/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTermSerializer.kt @@ -18,4 +18,4 @@ internal class JsTermSerializer(override val mimeType: MimeType) : TermSerialize is MimeType.Json -> JSON.stringify(objectified) is MimeType.Yaml -> YAML.stringify(objectified) } -} \ No newline at end of file +} diff --git a/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsUtils.kt b/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsUtils.kt index 58239eb68..59c6fa580 100644 --- a/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsUtils.kt +++ b/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsUtils.kt @@ -25,4 +25,4 @@ internal fun jsObject(properties: Iterable>, config: dynam } internal fun hasProperty(obj: dynamic, name: String): Boolean = - obj[name] != undefined \ No newline at end of file + obj[name] != undefined diff --git a/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/ObjectsUtils.kt b/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/ObjectsUtils.kt index 5d7260009..be58362e9 100644 --- a/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/ObjectsUtils.kt +++ b/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/ObjectsUtils.kt @@ -13,4 +13,4 @@ actual object ObjectsUtils { actual fun deeplyEqual(obj1: Any?, obj2: Any?): Boolean { return JSON.stringify(obj1) == JSON.stringify(obj2) } -} \ No newline at end of file +} diff --git a/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/TermSerialization.kt b/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/TermSerialization.kt index 53ec154ef..7488672e3 100644 --- a/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/TermSerialization.kt +++ b/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/TermSerialization.kt @@ -14,4 +14,4 @@ actual fun termObjectifier(): TermObjectifier { actual fun termDeobjectifier(): TermDeobjectifier { return JsTermDeobjectifier() -} \ No newline at end of file +} diff --git a/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/YAML.kt b/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/YAML.kt index 75111fbbe..f60cd60ca 100644 --- a/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/YAML.kt +++ b/serialize-core/src/jsMain/kotlin/it/unibo/tuprolog/serialize/YAML.kt @@ -8,4 +8,4 @@ external object YAML { fun parse(string: String, options: dynamic): dynamic fun parse(string: String): dynamic -} \ No newline at end of file +} diff --git a/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTermDeobjectifier.kt b/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTermDeobjectifier.kt index a7a5615a9..bbcaf7e00 100644 --- a/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTermDeobjectifier.kt +++ b/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTermDeobjectifier.kt @@ -1,6 +1,10 @@ package it.unibo.tuprolog.serialize -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Real +import it.unibo.tuprolog.core.Scope +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.Var import java.math.BigDecimal import java.math.BigInteger import it.unibo.tuprolog.core.Integer as LogicInteger @@ -81,24 +85,31 @@ internal class JvmTermDeobjectifier : TermDeobjectifier { private fun deobjectifyTuple(value: Map<*, *>): Term { val items = value["tuple"] as? List<*> ?: throw DeobjectificationException(value) - return scope.tupleOf(items.map { - deobjectify(it ?: throw DeobjectificationException(value)) - }) + return scope.tupleOf( + items.map { + deobjectify(it ?: throw DeobjectificationException(value)) + } + ) } private fun deobjectifySet(value: Map<*, *>): Term { val items = value["set"] as? List<*> ?: throw DeobjectificationException(value) - return scope.setOf(items.map { - deobjectify(it ?: throw DeobjectificationException(value)) - }) + return scope.setOf( + items.map { + deobjectify(it ?: throw DeobjectificationException(value)) + } + ) } private fun deobjectifyStructure(value: Map<*, *>): Term { val name = value["fun"] as? String ?: throw DeobjectificationException(value) val args = value["args"] as? List<*> ?: throw DeobjectificationException(value) - return scope.structOf(name, args.map { - deobjectify(it ?: throw DeobjectificationException(value)) - }) + return scope.structOf( + name, + args.map { + deobjectify(it ?: throw DeobjectificationException(value)) + } + ) } private fun deobjectifyVariable(value: Map<*, *>): Term { @@ -131,5 +142,4 @@ internal class JvmTermDeobjectifier : TermDeobjectifier { private fun deobjectifyBoolean(value: Boolean): Term { return scope.truthOf(value) } - -} \ No newline at end of file +} diff --git a/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTermDeserializer.kt b/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTermDeserializer.kt index 970baa56e..63e1cc79d 100644 --- a/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTermDeserializer.kt +++ b/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTermDeserializer.kt @@ -16,5 +16,4 @@ internal class JvmTermDeserializer(override val mimeType: MimeType) : ReadingTer JvmTermDeobjectifier().deobjectifyMany( mapper.readValue(reader, java.lang.Object::class.java) ) - -} \ No newline at end of file +} diff --git a/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTermObjectifier.kt b/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTermObjectifier.kt index 96ebf8c89..0aadea8f6 100644 --- a/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTermObjectifier.kt +++ b/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTermObjectifier.kt @@ -1,8 +1,22 @@ package it.unibo.tuprolog.serialize -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +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.List +import it.unibo.tuprolog.core.Real +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.Truth +import it.unibo.tuprolog.core.Tuple +import it.unibo.tuprolog.core.Var internal class JvmTermObjectifier : TermObjectifier { override fun defaultValue(term: Term): Any { @@ -103,4 +117,4 @@ internal class JvmTermObjectifier : TermObjectifier { mapOf( "body" to term.body.accept(this) ) -} \ No newline at end of file +} diff --git a/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTermSerializer.kt b/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTermSerializer.kt index 5c5133ce3..ca0c9062f 100644 --- a/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTermSerializer.kt +++ b/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTermSerializer.kt @@ -15,4 +15,4 @@ internal class JvmTermSerializer(override val mimeType: MimeType) : WritingTermS override fun serializeMany(writer: Writer, values: Iterable) { mapper.writeValue(writer, objectifier.objectifyMany(values)) } -} \ No newline at end of file +} diff --git a/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/ObjectsUtils.kt b/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/ObjectsUtils.kt index f5fc35986..e98a4ee5d 100644 --- a/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/ObjectsUtils.kt +++ b/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/ObjectsUtils.kt @@ -22,4 +22,4 @@ actual object ObjectsUtils { else -> obj1 == obj2 } } -} \ No newline at end of file +} diff --git a/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/ReadingDeserializer.kt b/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/ReadingDeserializer.kt index c5c82eca0..1d7da848d 100644 --- a/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/ReadingDeserializer.kt +++ b/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/ReadingDeserializer.kt @@ -17,4 +17,4 @@ interface ReadingDeserializer : Deserializer { StringReader(string).use { deserializeMany(it) } -} \ No newline at end of file +} diff --git a/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/ReadingTermDeserializer.kt b/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/ReadingTermDeserializer.kt index 99cb74ee5..77b9a9091 100644 --- a/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/ReadingTermDeserializer.kt +++ b/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/ReadingTermDeserializer.kt @@ -9,4 +9,4 @@ interface ReadingTermDeserializer : TermDeserializer, ReadingDeserializer return JvmTermDeserializer(mimeType) } } -} \ No newline at end of file +} diff --git a/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/TermSerialization.kt b/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/TermSerialization.kt index 172290440..d1be356d8 100644 --- a/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/TermSerialization.kt +++ b/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/TermSerialization.kt @@ -14,4 +14,4 @@ actual fun termObjectifier(): TermObjectifier { actual fun termDeobjectifier(): TermDeobjectifier { return JvmTermDeobjectifier() -} \ No newline at end of file +} diff --git a/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/WritingSerializer.kt b/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/WritingSerializer.kt index 4da18630c..f585ee9da 100644 --- a/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/WritingSerializer.kt +++ b/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/WritingSerializer.kt @@ -25,4 +25,4 @@ interface WritingSerializer : Serializer { fun serializeMany(writer: Writer, values: Sequence) = serializeMany(writer, values.asIterable()) -} \ No newline at end of file +} diff --git a/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/WritingTermSerializer.kt b/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/WritingTermSerializer.kt index 12694fde8..311627cea 100644 --- a/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/WritingTermSerializer.kt +++ b/serialize-core/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/WritingTermSerializer.kt @@ -9,4 +9,4 @@ interface WritingTermSerializer : TermSerializer, WritingSerializer { return JvmTermSerializer(mimeType) } } -} \ No newline at end of file +} From 7b539b72d02f171bdd2d76abe890bce2f44fcda9 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 14 Sep 2020 17:26:44 +0200 Subject: [PATCH 29/34] format code in :serialization-theory --- serialize-theory/build.gradle.kts | 9 --------- .../tuprolog/serialize/TheoryDeobjectifier.kt | 2 +- .../tuprolog/serialize/TheoryDeserializer.kt | 2 +- .../tuprolog/serialize/TheoryObjectifier.kt | 2 +- .../tuprolog/serialize/TheorySerialization.kt | 2 +- .../unibo/tuprolog/serialize/TheorySerializer.kt | 2 +- .../it/unibo/tuprolog/serialize/Instances.kt | 3 ++- .../serialize/TestTheoryDeserialization.kt | 2 +- .../serialize/TestTheorySerialization.kt | 2 +- .../it/unibo/tuprolog/serialize/TestUtils.kt | 16 ++++++++++------ .../tuprolog/serialize/JsTheoryDeobjectifier.kt | 3 +-- .../tuprolog/serialize/JsTheoryDeserializer.kt | 2 +- .../tuprolog/serialize/JsTheoryObjectifier.kt | 3 +-- .../tuprolog/serialize/JsTheorySerializer.kt | 2 +- .../tuprolog/serialize/TheorySerialization.kt | 2 +- .../tuprolog/serialize/JvmTheoryDeobjectifier.kt | 2 +- .../tuprolog/serialize/JvmTheoryDeserializer.kt | 3 +-- .../tuprolog/serialize/JvmTheoryObjectifier.kt | 2 +- .../tuprolog/serialize/JvmTheorySerializer.kt | 2 +- .../serialize/ReadingTheoryDeserializer.kt | 2 +- .../tuprolog/serialize/TheorySerialization.kt | 2 +- .../serialize/WritingTheorySerializer.kt | 2 +- .../src/jvmTest/kotlin/JSONPrinter.kt | 2 +- .../src/jvmTest/kotlin/YAMLPrinter.kt | 2 +- 24 files changed, 33 insertions(+), 40 deletions(-) diff --git a/serialize-theory/build.gradle.kts b/serialize-theory/build.gradle.kts index 79934cf07..16d286b52 100644 --- a/serialize-theory/build.gradle.kts +++ b/serialize-theory/build.gradle.kts @@ -24,14 +24,6 @@ kotlin { } } } - - js { - compilations["main"].defaultSourceSet { - dependencies { -// api(npm("yaml", "^1.10.0")) - } - } - } } } @@ -47,4 +39,3 @@ listOf("yaml", "json").forEach { main = "${it.toUpperCase()}PrinterKt" } } - diff --git a/serialize-theory/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TheoryDeobjectifier.kt b/serialize-theory/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TheoryDeobjectifier.kt index f45c2f452..73a956f42 100644 --- a/serialize-theory/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TheoryDeobjectifier.kt +++ b/serialize-theory/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TheoryDeobjectifier.kt @@ -11,4 +11,4 @@ interface TheoryDeobjectifier : Deobjectifier { val default: TheoryDeobjectifier get() = theoryDeobjectifier() } -} \ No newline at end of file +} diff --git a/serialize-theory/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TheoryDeserializer.kt b/serialize-theory/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TheoryDeserializer.kt index d5f099a87..cb174416a 100644 --- a/serialize-theory/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TheoryDeserializer.kt +++ b/serialize-theory/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TheoryDeserializer.kt @@ -12,4 +12,4 @@ interface TheoryDeserializer : Deserializer { return theoryDeserializer(mimeType) } } -} \ No newline at end of file +} diff --git a/serialize-theory/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TheoryObjectifier.kt b/serialize-theory/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TheoryObjectifier.kt index 1f7f1ab2e..633cddb98 100644 --- a/serialize-theory/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TheoryObjectifier.kt +++ b/serialize-theory/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TheoryObjectifier.kt @@ -11,4 +11,4 @@ interface TheoryObjectifier : Objectifier { val default: TheoryObjectifier get() = theoryObjectifier() } -} \ No newline at end of file +} diff --git a/serialize-theory/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TheorySerialization.kt b/serialize-theory/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TheorySerialization.kt index e7fdff393..8f6c18ada 100644 --- a/serialize-theory/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TheorySerialization.kt +++ b/serialize-theory/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TheorySerialization.kt @@ -10,4 +10,4 @@ expect fun theoryDeserializer(mimeType: MimeType): TheoryDeserializer expect fun theoryObjectifier(): TheoryObjectifier -expect fun theoryDeobjectifier(): TheoryDeobjectifier \ No newline at end of file +expect fun theoryDeobjectifier(): TheoryDeobjectifier diff --git a/serialize-theory/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TheorySerializer.kt b/serialize-theory/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TheorySerializer.kt index 787d32e19..76ab2674a 100644 --- a/serialize-theory/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TheorySerializer.kt +++ b/serialize-theory/src/commonMain/kotlin/it/unibo/tuprolog/serialize/TheorySerializer.kt @@ -12,4 +12,4 @@ interface TheorySerializer : Serializer { return theorySerializer(mimeType) } } -} \ No newline at end of file +} diff --git a/serialize-theory/src/commonTest/kotlin/it/unibo/tuprolog/serialize/Instances.kt b/serialize-theory/src/commonTest/kotlin/it/unibo/tuprolog/serialize/Instances.kt index 2951df856..390b61e71 100644 --- a/serialize-theory/src/commonTest/kotlin/it/unibo/tuprolog/serialize/Instances.kt +++ b/serialize-theory/src/commonTest/kotlin/it/unibo/tuprolog/serialize/Instances.kt @@ -1,7 +1,8 @@ package it.unibo.tuprolog.serialize object Instances { - val commonRulesInJSON = """ + val commonRulesInJSON = + """ |[ | { | "head":{ diff --git a/serialize-theory/src/commonTest/kotlin/it/unibo/tuprolog/serialize/TestTheoryDeserialization.kt b/serialize-theory/src/commonTest/kotlin/it/unibo/tuprolog/serialize/TestTheoryDeserialization.kt index 47c382a8f..165038059 100644 --- a/serialize-theory/src/commonTest/kotlin/it/unibo/tuprolog/serialize/TestTheoryDeserialization.kt +++ b/serialize-theory/src/commonTest/kotlin/it/unibo/tuprolog/serialize/TestTheoryDeserialization.kt @@ -14,4 +14,4 @@ class TestTheoryDeserialization { fun testTheorySerializationYAML() { TheoryDeserializer.of(MimeType.Yaml).assertDeserializationWorks(CommonRules.theory, Instances.commonRulesInYAML) } -} \ No newline at end of file +} diff --git a/serialize-theory/src/commonTest/kotlin/it/unibo/tuprolog/serialize/TestTheorySerialization.kt b/serialize-theory/src/commonTest/kotlin/it/unibo/tuprolog/serialize/TestTheorySerialization.kt index 14139f896..2ee0882c9 100644 --- a/serialize-theory/src/commonTest/kotlin/it/unibo/tuprolog/serialize/TestTheorySerialization.kt +++ b/serialize-theory/src/commonTest/kotlin/it/unibo/tuprolog/serialize/TestTheorySerialization.kt @@ -14,4 +14,4 @@ class TestTheorySerialization { fun testTheorySerializationYAML() { TheorySerializer.of(MimeType.Yaml).assertSerializationWorks(Instances.commonRulesInYAML, CommonRules.theory) } -} \ No newline at end of file +} diff --git a/serialize-theory/src/commonTest/kotlin/it/unibo/tuprolog/serialize/TestUtils.kt b/serialize-theory/src/commonTest/kotlin/it/unibo/tuprolog/serialize/TestUtils.kt index bc808e2d3..c7dd58aea 100644 --- a/serialize-theory/src/commonTest/kotlin/it/unibo/tuprolog/serialize/TestUtils.kt +++ b/serialize-theory/src/commonTest/kotlin/it/unibo/tuprolog/serialize/TestUtils.kt @@ -1,6 +1,6 @@ package it.unibo.tuprolog.serialize -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Scope import it.unibo.tuprolog.serialize.ObjectsUtils.deeplyEqual import it.unibo.tuprolog.serialize.ObjectsUtils.parseAsObject import it.unibo.tuprolog.theory.Theory @@ -9,13 +9,15 @@ import it.unibo.tuprolog.utils.itemWiseEquals fun Serializer.assertSerializationWorks(expected: String, actual: T) { val expectedObj = parseAsObject(expected, mimeType) val actualObj = TheoryObjectifier.default.objectify(actual) - kotlin.test.assertTrue(""" + kotlin.test.assertTrue( + """ |Expected: | $expectedObj |got instead: | $actualObj | - """.trimMargin()) { deeplyEqual(expectedObj, actualObj) } + """.trimMargin() + ) { deeplyEqual(expectedObj, actualObj) } } fun Serializer.assertTermSerializationWorks(expected: String, actualGenerator: Scope.() -> Theory) { @@ -24,13 +26,15 @@ fun Serializer.assertTermSerializationWorks(expected: String, actualGene fun Deserializer.assertDeserializationWorks(expected: T, actual: String) { val deserialized = deserialize(actual) - kotlin.test.assertTrue(""" + kotlin.test.assertTrue( + """ |Expected: | $expected |got: | $deserialized | - """.trimMargin()) { representationsAreEqual(expected, deserialized) } + """.trimMargin() + ) { representationsAreEqual(expected, deserialized) } } fun Deserializer.assertTermDeserializationWorks(actual: String, expectedGenerator: Scope.() -> Theory) { @@ -41,4 +45,4 @@ private fun representationsAreEqual(t1: Theory, t2: Theory): Boolean { return itemWiseEquals(t1, t2) { x, y -> x.equals(y, false) } -} \ No newline at end of file +} diff --git a/serialize-theory/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTheoryDeobjectifier.kt b/serialize-theory/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTheoryDeobjectifier.kt index 2b8d94804..6fbab6680 100644 --- a/serialize-theory/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTheoryDeobjectifier.kt +++ b/serialize-theory/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTheoryDeobjectifier.kt @@ -18,5 +18,4 @@ internal class JsTheoryDeobjectifier : TheoryDeobjectifier { else -> throw DeobjectificationException(`object`) } } - -} \ No newline at end of file +} diff --git a/serialize-theory/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTheoryDeserializer.kt b/serialize-theory/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTheoryDeserializer.kt index d3e718668..12dcca165 100644 --- a/serialize-theory/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTheoryDeserializer.kt +++ b/serialize-theory/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTheoryDeserializer.kt @@ -15,4 +15,4 @@ internal class JsTheoryDeserializer(override val mimeType: MimeType) : TheoryDes is MimeType.Json -> JSON.parse(string) is MimeType.Yaml -> YAML.parse(string) } as Any -} \ No newline at end of file +} diff --git a/serialize-theory/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTheoryObjectifier.kt b/serialize-theory/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTheoryObjectifier.kt index 032951c93..9fcc56b74 100644 --- a/serialize-theory/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTheoryObjectifier.kt +++ b/serialize-theory/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTheoryObjectifier.kt @@ -12,5 +12,4 @@ internal class JsTheoryObjectifier : TheoryObjectifier { override fun objectifyMany(values: Iterable): Any { return values.map { objectify(it) }.toTypedArray() } - -} \ No newline at end of file +} diff --git a/serialize-theory/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTheorySerializer.kt b/serialize-theory/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTheorySerializer.kt index cdae0be82..82dfeaf0f 100644 --- a/serialize-theory/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTheorySerializer.kt +++ b/serialize-theory/src/jsMain/kotlin/it/unibo/tuprolog/serialize/JsTheorySerializer.kt @@ -18,4 +18,4 @@ internal class JsTheorySerializer(override val mimeType: MimeType) : TheorySeria is MimeType.Json -> JSON.stringify(objectified) is MimeType.Yaml -> YAML.stringify(objectified) } -} \ No newline at end of file +} diff --git a/serialize-theory/src/jsMain/kotlin/it/unibo/tuprolog/serialize/TheorySerialization.kt b/serialize-theory/src/jsMain/kotlin/it/unibo/tuprolog/serialize/TheorySerialization.kt index 123f35254..be3df8f41 100644 --- a/serialize-theory/src/jsMain/kotlin/it/unibo/tuprolog/serialize/TheorySerialization.kt +++ b/serialize-theory/src/jsMain/kotlin/it/unibo/tuprolog/serialize/TheorySerialization.kt @@ -14,4 +14,4 @@ actual fun theoryObjectifier(): TheoryObjectifier { actual fun theoryDeobjectifier(): TheoryDeobjectifier { return JsTheoryDeobjectifier() -} \ No newline at end of file +} diff --git a/serialize-theory/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTheoryDeobjectifier.kt b/serialize-theory/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTheoryDeobjectifier.kt index a83916e54..f937fcd21 100644 --- a/serialize-theory/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTheoryDeobjectifier.kt +++ b/serialize-theory/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTheoryDeobjectifier.kt @@ -18,4 +18,4 @@ internal class JvmTheoryDeobjectifier : TheoryDeobjectifier { else -> throw DeobjectificationException(`object`) } } -} \ No newline at end of file +} diff --git a/serialize-theory/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTheoryDeserializer.kt b/serialize-theory/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTheoryDeserializer.kt index 366513419..cb1493954 100644 --- a/serialize-theory/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTheoryDeserializer.kt +++ b/serialize-theory/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTheoryDeserializer.kt @@ -16,5 +16,4 @@ internal class JvmTheoryDeserializer(override val mimeType: MimeType) : ReadingT JvmTheoryDeobjectifier().deobjectifyMany( mapper.readValue(reader, java.lang.Object::class.java) ) - -} \ No newline at end of file +} diff --git a/serialize-theory/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTheoryObjectifier.kt b/serialize-theory/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTheoryObjectifier.kt index 962e99d66..3e9529567 100644 --- a/serialize-theory/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTheoryObjectifier.kt +++ b/serialize-theory/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTheoryObjectifier.kt @@ -13,4 +13,4 @@ internal class JvmTheoryObjectifier : TheoryObjectifier { override fun objectifyMany(values: Iterable): Any { return values.map { objectify(it) } } -} \ No newline at end of file +} diff --git a/serialize-theory/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTheorySerializer.kt b/serialize-theory/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTheorySerializer.kt index 9e03fc9b1..5b8ecee19 100644 --- a/serialize-theory/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTheorySerializer.kt +++ b/serialize-theory/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/JvmTheorySerializer.kt @@ -15,4 +15,4 @@ internal class JvmTheorySerializer(override val mimeType: MimeType) : WritingThe override fun serializeMany(writer: Writer, values: Iterable) { mapper.writeValue(writer, objectifier.objectifyMany(values)) } -} \ No newline at end of file +} diff --git a/serialize-theory/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/ReadingTheoryDeserializer.kt b/serialize-theory/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/ReadingTheoryDeserializer.kt index 692803e93..1ca36184b 100644 --- a/serialize-theory/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/ReadingTheoryDeserializer.kt +++ b/serialize-theory/src/jvmMain/kotlin/it/unibo/tuprolog/serialize/ReadingTheoryDeserializer.kt @@ -9,4 +9,4 @@ interface ReadingTheoryDeserializer : TheoryDeserializer, ReadingDeserializer return JvmTheorySerializer(mimeType) } } -} \ No newline at end of file +} diff --git a/serialize-theory/src/jvmTest/kotlin/JSONPrinter.kt b/serialize-theory/src/jvmTest/kotlin/JSONPrinter.kt index 927e6f905..b3e12176a 100644 --- a/serialize-theory/src/jvmTest/kotlin/JSONPrinter.kt +++ b/serialize-theory/src/jvmTest/kotlin/JSONPrinter.kt @@ -4,4 +4,4 @@ import it.unibo.tuprolog.solve.stdlib.CommonRules fun main() { println(TheorySerializer.of(MimeType.Json).serialize(CommonRules.theory)) -} \ No newline at end of file +} diff --git a/serialize-theory/src/jvmTest/kotlin/YAMLPrinter.kt b/serialize-theory/src/jvmTest/kotlin/YAMLPrinter.kt index a1520006c..d67a59c43 100644 --- a/serialize-theory/src/jvmTest/kotlin/YAMLPrinter.kt +++ b/serialize-theory/src/jvmTest/kotlin/YAMLPrinter.kt @@ -4,4 +4,4 @@ import it.unibo.tuprolog.solve.stdlib.CommonRules fun main() { println(TheorySerializer.of(MimeType.Yaml).serialize(CommonRules.theory)) -} \ No newline at end of file +} From 18e25d2a1a2b47010213c74ef7f7ede612489c6b Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 14 Sep 2020 17:30:29 +0200 Subject: [PATCH 30/34] format code in :examples --- examples/build.gradle.kts | 2 +- .../examples/core/substitution/Application.kt | 5 +++-- .../tuprolog/examples/core/substitution/Chain.kt | 6 +++--- .../examples/core/substitution/Composition.kt | 2 +- .../examples/core/substitution/Contradiction.kt | 2 +- .../tuprolog/examples/core/substitution/Creation.kt | 2 +- .../unibo/tuprolog/examples/solve/SolverExample.kt | 8 ++++++-- .../it/unibo/tuprolog/examples/unify/Caching.kt | 12 ++++++++---- .../tuprolog/examples/unify/CustomUnificator.kt | 2 +- .../it/unibo/tuprolog/examples/unify/Failure.kt | 10 +++++----- .../it/unibo/tuprolog/examples/unify/InfixMethods.kt | 8 ++++---- .../it/unibo/tuprolog/examples/unify/OccursCheck.kt | 4 ++-- .../it/unibo/tuprolog/examples/unify/Success.kt | 12 ++++++++---- 13 files changed, 44 insertions(+), 31 deletions(-) diff --git a/examples/build.gradle.kts b/examples/build.gradle.kts index e3d5b02ee..38242d858 100644 --- a/examples/build.gradle.kts +++ b/examples/build.gradle.kts @@ -22,4 +22,4 @@ tasks.withType { jvmTarget = "1.$javaVersion" freeCompilerArgs = ktFreeCompilerArgsJvm.split(";").toList() } -} \ No newline at end of file +} diff --git a/examples/src/main/kotlin/it/unibo/tuprolog/examples/core/substitution/Application.kt b/examples/src/main/kotlin/it/unibo/tuprolog/examples/core/substitution/Application.kt index 379adf4b2..32d80ff6f 100644 --- a/examples/src/main/kotlin/it/unibo/tuprolog/examples/core/substitution/Application.kt +++ b/examples/src/main/kotlin/it/unibo/tuprolog/examples/core/substitution/Application.kt @@ -1,6 +1,7 @@ package it.unibo.tuprolog.examples.core.substitution -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Scope +import it.unibo.tuprolog.core.Substitution /** * @@ -16,4 +17,4 @@ fun main() { println(result) } -} \ No newline at end of file +} diff --git a/examples/src/main/kotlin/it/unibo/tuprolog/examples/core/substitution/Chain.kt b/examples/src/main/kotlin/it/unibo/tuprolog/examples/core/substitution/Chain.kt index 097724fe9..9c45fb00a 100644 --- a/examples/src/main/kotlin/it/unibo/tuprolog/examples/core/substitution/Chain.kt +++ b/examples/src/main/kotlin/it/unibo/tuprolog/examples/core/substitution/Chain.kt @@ -11,8 +11,8 @@ import it.unibo.tuprolog.core.Substitution fun main() { Scope.empty { val substitution = Substitution.of( - varOf("X") to varOf("Y"), - varOf("Y") to varOf("Z") + varOf("X") to varOf("Y"), + varOf("Y") to varOf("Z") ) val originalZ = substitution.getOriginal(varOf("Z")) @@ -20,4 +20,4 @@ fun main() { println(substitution) println(originalZ) } -} \ No newline at end of file +} diff --git a/examples/src/main/kotlin/it/unibo/tuprolog/examples/core/substitution/Composition.kt b/examples/src/main/kotlin/it/unibo/tuprolog/examples/core/substitution/Composition.kt index 8199924c8..c63f1c430 100644 --- a/examples/src/main/kotlin/it/unibo/tuprolog/examples/core/substitution/Composition.kt +++ b/examples/src/main/kotlin/it/unibo/tuprolog/examples/core/substitution/Composition.kt @@ -20,4 +20,4 @@ fun main() { val result = substitution.applyTo(term) println(result) } -} \ No newline at end of file +} diff --git a/examples/src/main/kotlin/it/unibo/tuprolog/examples/core/substitution/Contradiction.kt b/examples/src/main/kotlin/it/unibo/tuprolog/examples/core/substitution/Contradiction.kt index baf4feeec..1dede4dbb 100644 --- a/examples/src/main/kotlin/it/unibo/tuprolog/examples/core/substitution/Contradiction.kt +++ b/examples/src/main/kotlin/it/unibo/tuprolog/examples/core/substitution/Contradiction.kt @@ -21,4 +21,4 @@ fun main() { println(substitution) println(result) } -} \ No newline at end of file +} diff --git a/examples/src/main/kotlin/it/unibo/tuprolog/examples/core/substitution/Creation.kt b/examples/src/main/kotlin/it/unibo/tuprolog/examples/core/substitution/Creation.kt index a77214b21..a3aecf1b9 100644 --- a/examples/src/main/kotlin/it/unibo/tuprolog/examples/core/substitution/Creation.kt +++ b/examples/src/main/kotlin/it/unibo/tuprolog/examples/core/substitution/Creation.kt @@ -17,4 +17,4 @@ fun main() { println(substitution) } -} \ No newline at end of file +} diff --git a/examples/src/main/kotlin/it/unibo/tuprolog/examples/solve/SolverExample.kt b/examples/src/main/kotlin/it/unibo/tuprolog/examples/solve/SolverExample.kt index 51f74334b..f8c2aa79f 100644 --- a/examples/src/main/kotlin/it/unibo/tuprolog/examples/solve/SolverExample.kt +++ b/examples/src/main/kotlin/it/unibo/tuprolog/examples/solve/SolverExample.kt @@ -3,7 +3,11 @@ package it.unibo.tuprolog.examples.solve import it.unibo.tuprolog.core.Numeric import it.unibo.tuprolog.core.Term import it.unibo.tuprolog.dsl.theory.prolog -import it.unibo.tuprolog.solve.* +import it.unibo.tuprolog.solve.ExecutionContext +import it.unibo.tuprolog.solve.Signature +import it.unibo.tuprolog.solve.Solution +import it.unibo.tuprolog.solve.Solver +import it.unibo.tuprolog.solve.classicWithDefaultBuiltins import it.unibo.tuprolog.solve.exception.error.TypeError import it.unibo.tuprolog.solve.library.Libraries import it.unibo.tuprolog.solve.library.Library @@ -74,4 +78,4 @@ fun main() { } } } -} \ No newline at end of file +} diff --git a/examples/src/main/kotlin/it/unibo/tuprolog/examples/unify/Caching.kt b/examples/src/main/kotlin/it/unibo/tuprolog/examples/unify/Caching.kt index d54f06095..64f70af43 100644 --- a/examples/src/main/kotlin/it/unibo/tuprolog/examples/unify/Caching.kt +++ b/examples/src/main/kotlin/it/unibo/tuprolog/examples/unify/Caching.kt @@ -1,6 +1,10 @@ package it.unibo.tuprolog.examples.unify -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Substitution +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.unify.Unificator fun main() { @@ -15,6 +19,6 @@ fun main() { val unified: Term? = cached.unify(term, template) println(substitution) // {X_0=abraham} - println(match) // true - println(unified) // father(abraham, isaac) -} \ No newline at end of file + println(match) // true + println(unified) // father(abraham, isaac) +} diff --git a/examples/src/main/kotlin/it/unibo/tuprolog/examples/unify/CustomUnificator.kt b/examples/src/main/kotlin/it/unibo/tuprolog/examples/unify/CustomUnificator.kt index c25f819b2..89ee6e8e9 100644 --- a/examples/src/main/kotlin/it/unibo/tuprolog/examples/unify/CustomUnificator.kt +++ b/examples/src/main/kotlin/it/unibo/tuprolog/examples/unify/CustomUnificator.kt @@ -32,4 +32,4 @@ fun main() { println(match) println(result) } -} \ No newline at end of file +} diff --git a/examples/src/main/kotlin/it/unibo/tuprolog/examples/unify/Failure.kt b/examples/src/main/kotlin/it/unibo/tuprolog/examples/unify/Failure.kt index 06d0865d0..3934b5d35 100644 --- a/examples/src/main/kotlin/it/unibo/tuprolog/examples/unify/Failure.kt +++ b/examples/src/main/kotlin/it/unibo/tuprolog/examples/unify/Failure.kt @@ -16,8 +16,8 @@ fun main() { val match: Boolean = unificator.match(term, template) val unified: Term? = unificator.unify(term, template) - println(substitution is Substitution.Fail) // true - println(substitution.isFailed) // true - println(match) // false - println(unified) // null -} \ No newline at end of file + println(substitution is Substitution.Fail) // true + println(substitution.isFailed) // true + println(match) // false + println(unified) // null +} diff --git a/examples/src/main/kotlin/it/unibo/tuprolog/examples/unify/InfixMethods.kt b/examples/src/main/kotlin/it/unibo/tuprolog/examples/unify/InfixMethods.kt index 979873c4b..8f7e6fc6b 100644 --- a/examples/src/main/kotlin/it/unibo/tuprolog/examples/unify/InfixMethods.kt +++ b/examples/src/main/kotlin/it/unibo/tuprolog/examples/unify/InfixMethods.kt @@ -11,7 +11,7 @@ fun main() { val term = Struct.of("father", Atom.of("abraham"), Atom.of("isaac")) val template = Struct.of("father", Var.of("X"), Atom.of("isaac")) - println(term mguWith template) // {X_0=abraham} - println(term matches template) // true - println(term unifyWith template) // father(abraham, isaac) -} \ No newline at end of file + println(term mguWith template) // {X_0=abraham} + println(term matches template) // true + println(term unifyWith template) // father(abraham, isaac) +} diff --git a/examples/src/main/kotlin/it/unibo/tuprolog/examples/unify/OccursCheck.kt b/examples/src/main/kotlin/it/unibo/tuprolog/examples/unify/OccursCheck.kt index e33adfaf7..354c6df0a 100644 --- a/examples/src/main/kotlin/it/unibo/tuprolog/examples/unify/OccursCheck.kt +++ b/examples/src/main/kotlin/it/unibo/tuprolog/examples/unify/OccursCheck.kt @@ -13,7 +13,7 @@ fun main() { val unificator = Unificator.default val mgu = unificator.mgu(term, otherTerm, occurCheckEnabled = false) - println(mgu) // {X_0=f(X_0), Y_1=a} => WRONG + println(mgu) // {X_0=f(X_0), Y_1=a} => WRONG } } -} \ No newline at end of file +} diff --git a/examples/src/main/kotlin/it/unibo/tuprolog/examples/unify/Success.kt b/examples/src/main/kotlin/it/unibo/tuprolog/examples/unify/Success.kt index 6a78c88fa..59f97f335 100644 --- a/examples/src/main/kotlin/it/unibo/tuprolog/examples/unify/Success.kt +++ b/examples/src/main/kotlin/it/unibo/tuprolog/examples/unify/Success.kt @@ -1,6 +1,10 @@ package it.unibo.tuprolog.examples.unify -import it.unibo.tuprolog.core.* +import it.unibo.tuprolog.core.Atom +import it.unibo.tuprolog.core.Struct +import it.unibo.tuprolog.core.Substitution +import it.unibo.tuprolog.core.Term +import it.unibo.tuprolog.core.Var import it.unibo.tuprolog.unify.Unificator fun main() { @@ -14,6 +18,6 @@ fun main() { val unified: Term? = unificator.unify(term, template) println(substitution) // {X_0=abraham} - println(match) // true - println(unified) // father(abraham, isaac) -} \ No newline at end of file + println(match) // true + println(unified) // father(abraham, isaac) +} From 1ba587953378e5796169417b7d97f5260fc9a881 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 14 Sep 2020 17:31:02 +0200 Subject: [PATCH 31/34] format code in :parser-jvm --- .../unibo/tuprolog/parser/ParsingException.kt | 2 +- .../tuprolog/parser/dynamic/Associativity.kt | 2 +- .../tuprolog/parser/dynamic/StringType.kt | 2 +- .../unibo/tuprolog/parser/PrologParserTest.kt | 134 ++++++++++-------- 4 files changed, 80 insertions(+), 60 deletions(-) diff --git a/parser-jvm/src/main/kotlin/it/unibo/tuprolog/parser/ParsingException.kt b/parser-jvm/src/main/kotlin/it/unibo/tuprolog/parser/ParsingException.kt index 02b31c1f6..480580aa7 100644 --- a/parser-jvm/src/main/kotlin/it/unibo/tuprolog/parser/ParsingException.kt +++ b/parser-jvm/src/main/kotlin/it/unibo/tuprolog/parser/ParsingException.kt @@ -17,4 +17,4 @@ class ParsingException( ", offendingSymbol='" + offendingSymbol + '\'' + '}' } -} \ No newline at end of file +} diff --git a/parser-jvm/src/main/kotlin/it/unibo/tuprolog/parser/dynamic/Associativity.kt b/parser-jvm/src/main/kotlin/it/unibo/tuprolog/parser/dynamic/Associativity.kt index f55919edc..95b1fc5ea 100644 --- a/parser-jvm/src/main/kotlin/it/unibo/tuprolog/parser/dynamic/Associativity.kt +++ b/parser-jvm/src/main/kotlin/it/unibo/tuprolog/parser/dynamic/Associativity.kt @@ -39,4 +39,4 @@ enum class Associativity { } } } -} \ No newline at end of file +} diff --git a/parser-jvm/src/main/kotlin/it/unibo/tuprolog/parser/dynamic/StringType.kt b/parser-jvm/src/main/kotlin/it/unibo/tuprolog/parser/dynamic/StringType.kt index 4a96c5aea..c35791936 100644 --- a/parser-jvm/src/main/kotlin/it/unibo/tuprolog/parser/dynamic/StringType.kt +++ b/parser-jvm/src/main/kotlin/it/unibo/tuprolog/parser/dynamic/StringType.kt @@ -2,4 +2,4 @@ package it.unibo.tuprolog.parser.dynamic enum class StringType { SINGLE_QUOTED, DOUBLE_QUOTED -} \ No newline at end of file +} diff --git a/parser-jvm/src/test/kotlin/it/unibo/tuprolog/parser/PrologParserTest.kt b/parser-jvm/src/test/kotlin/it/unibo/tuprolog/parser/PrologParserTest.kt index 84b5ad104..f7a6790f2 100644 --- a/parser-jvm/src/test/kotlin/it/unibo/tuprolog/parser/PrologParserTest.kt +++ b/parser-jvm/src/test/kotlin/it/unibo/tuprolog/parser/PrologParserTest.kt @@ -1,14 +1,19 @@ package it.unibo.tuprolog.parser import it.unibo.tuprolog.parser.dynamic.DynamicLexer -import org.antlr.v4.runtime.* +import org.antlr.v4.runtime.BaseErrorListener +import org.antlr.v4.runtime.BufferedTokenStream +import org.antlr.v4.runtime.CharStreams +import org.antlr.v4.runtime.RecognitionException +import org.antlr.v4.runtime.Recognizer +import org.antlr.v4.runtime.Token +import org.antlr.v4.runtime.TokenStream import org.junit.Assert import org.junit.Test -import java.util.* +import java.util.LinkedList import kotlin.test.assertEquals import kotlin.test.assertTrue - class PrologParserTest { companion object { @@ -43,35 +48,39 @@ class PrologParserTest { private fun parseTerm(string: String): PrologParser.SingletonTermContext { val parser: PrologParser = this.createParser(string) - parser.addErrorListener(object : BaseErrorListener() { - override fun syntaxError( - recognizer: Recognizer<*, *>, - offendingSymbol: Any, - line: Int, - charPositionInLine: Int, - msg: String, - e: RecognitionException - ) { - throw e + parser.addErrorListener( + object : BaseErrorListener() { + override fun syntaxError( + recognizer: Recognizer<*, *>, + offendingSymbol: Any, + line: Int, + charPositionInLine: Int, + msg: String, + e: RecognitionException + ) { + throw e + } } - }) + ) return parser.singletonTerm() } private fun parseExpression(string: String): PrologParser.SingletonExpressionContext { val parser: PrologParser = createParser(string) - parser.addErrorListener(object : BaseErrorListener() { - override fun syntaxError( - recognizer: Recognizer<*, *>, - offendingSymbol: Any, - line: Int, - charPositionInLine: Int, - msg: String, - e: RecognitionException - ) { - throw e + parser.addErrorListener( + object : BaseErrorListener() { + override fun syntaxError( + recognizer: Recognizer<*, *>, + offendingSymbol: Any, + line: Int, + charPositionInLine: Int, + msg: String, + e: RecognitionException + ) { + throw e + } } - }) + ) return parser.singletonExpression() } @@ -87,7 +96,7 @@ class PrologParserTest { } @Test - fun testInteger(){ + fun testInteger() { val tc = parseTerm("1").term() assertTrue(tc.isNum && !tc.isExpr && !tc.isList && !tc.isStruct && !tc.isVar) val nc = tc.number() @@ -97,38 +106,40 @@ class PrologParserTest { } @Test - fun testReal(){ + fun testReal() { val tc = parseTerm("1.1").term() assertTrue(tc.isNum && !tc.isExpr && !tc.isList && !tc.isStruct && !tc.isVar) val nc = tc.number() assertTrue(nc.isReal && !nc.isInt) val rc = nc.real() - assertEquals(rc.value.text.toDouble(),1.1) + assertEquals(rc.value.text.toDouble(), 1.1) } @Test - fun testAtom(){ + fun testAtom() { val tc = parseTerm("a").term() assertTrue(tc.isStruct && !tc.isExpr && !tc.isList && !tc.isNum && !tc.isVar) val sc = tc.structure() - assertTrue(sc.arity == sc.args.count() && + assertTrue( + sc.arity == sc.args.count() && sc.arity == 0 && !sc.isList && !sc.isSet && !sc.isTruth && sc.functor.text == "a" && - sc.functor.type == PrologLexer.ATOM) + sc.functor.type == PrologLexer.ATOM + ) } - @Test - fun testString(){ - sequenceOf("'a'","\"a\"").forEach{ + fun testString() { + sequenceOf("'a'", "\"a\"").forEach { val tc = parseTerm(it).term() assertTrue(tc.isStruct && !tc.isExpr && !tc.isList && !tc.isNum && !tc.isVar) val s = tc.structure() - assertTrue(s.arity == s.args.count() && - s.arity == 0 && s.isString && !s.isSet &&!s.isList && !s.isTruth && + assertTrue( + s.arity == s.args.count() && + s.arity == 0 && s.isString && !s.isSet && !s.isList && !s.isTruth && s.functor.text == "a" && (s.functor.type == PrologLexer.DQ_STRING || s.functor.type == PrologLexer.SQ_STRING) ) @@ -136,61 +147,71 @@ class PrologParserTest { } @Test - fun testTrue(){ + fun testTrue() { val tc = parseTerm("true").term() assertTrue(tc.isStruct && !tc.isExpr && !tc.isList && !tc.isNum && !tc.isVar) val s = tc.structure() - assertTrue(s.arity == s.args.count() && + assertTrue( + s.arity == s.args.count() && s.isTruth && !s.isList && !s.isString && s.functor.text == "true" && - s.functor.type == PrologLexer.BOOL) + s.functor.type == PrologLexer.BOOL + ) } @Test - fun testFalse(){ + fun testFalse() { val tc = parseTerm("fail").term() assertTrue(tc.isStruct && !tc.isExpr && !tc.isList && !tc.isNum && !tc.isVar) val s = tc.structure() - assertTrue(s.arity == s.args.count() && + assertTrue( + s.arity == s.args.count() && s.isTruth && !s.isList && !s.isString && s.functor.text == "fail" && - s.functor.type == PrologLexer.BOOL) + s.functor.type == PrologLexer.BOOL + ) } @Test - fun testEmptyList(){ - sequenceOf("[]","[ ]","[ ]").forEach{ + fun testEmptyList() { + sequenceOf("[]", "[ ]", "[ ]").forEach { val tc = parseTerm(it).term() assertTrue(tc.isStruct && !tc.isExpr && !tc.isList && !tc.isNum && !tc.isVar) val s = tc.structure() - assertTrue(s.arity == s.args.count() && + assertTrue( + s.arity == s.args.count() && s.arity == 0 && - s.isList && !s.isTruth && !s.isString && - s.functor.type == PrologLexer.EMPTY_LIST ) + s.isList && !s.isTruth && !s.isString && + s.functor.type == PrologLexer.EMPTY_LIST + ) } } @Test - fun testVar(){ - sequenceOf("A","_A","_1A","A_").forEach { + fun testVar() { + sequenceOf("A", "_A", "_1A", "A_").forEach { val tc = parseTerm(it).term() assertTrue(tc.isVar && !tc.isExpr && !tc.isList && !tc.isNum && !tc.isStruct) val v = tc.variable() - assertTrue(!v.isAnonymous && + assertTrue( + !v.isAnonymous && v.value.text.contains("A") && - v.value.type == PrologLexer.VARIABLE) + v.value.type == PrologLexer.VARIABLE + ) } } @Test - fun testSingletonList(){ - sequenceOf("[1]", "[1 ]","[ 1]", "[ 1 ]").forEach { + fun testSingletonList() { + sequenceOf("[1]", "[1 ]", "[ 1]", "[ 1 ]").forEach { val tc = parseTerm(it).term() assertTrue(tc.isList && !tc.isExpr && !tc.isVar && !tc.isNum && !tc.isStruct) val l = tc.list() - assertTrue(l.length == l.items.count() && + assertTrue( + l.length == l.items.count() && l.length == 1 && - !l.hasTail && l.tail==null) + !l.hasTail && l.tail == null + ) val expr = l.items[0] assertTrue(expr.isTerm && expr.left != null && expr.operators.count() == 0 && expr.right.count() == 0) val t = expr.left!! @@ -198,8 +219,7 @@ class PrologParserTest { val n = t.number() assertTrue(n.isInt && !n.isReal) val i = n.integer() - assertEquals(i.value.text.toInt(),1) + assertEquals(i.value.text.toInt(), 1) } } - } From cbae0a43051afafc16fc1fc91c06fb207ed34a9e Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 14 Sep 2020 17:31:12 +0200 Subject: [PATCH 32/34] format code in root project --- build.gradle.kts | 23 ++++++++++++----------- settings.gradle.kts | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index b6e4de8e0..51766cf52 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -142,7 +142,7 @@ ktSubprojects.forEachProject { tasks.withType { kotlinOptions { moduleKind = "umd" - //noStdlib = true + // noStdlib = true metaInfo = true sourceMap = true sourceMapEmbedSources = "always" @@ -164,7 +164,6 @@ ktSubprojects.forEachProject { } } } - } tasks.withType { @@ -345,8 +344,10 @@ fun Project.configureUploadToBintray(vararg publicationNames: String) { user = bintrayUser key = bintrayKey if (publicationNames.isEmpty()) { - setPublications(*project.publishing.publications.withType().map { it.name } - .toTypedArray()) + setPublications( + *project.publishing.publications.withType().map { it.name } + .toTypedArray() + ) } else { setPublications(*publicationNames) } @@ -400,7 +401,7 @@ fun Project.configureMavenPublications(docArtifactBaseName: String) { } else if (!docArtifact.endsWith("KotlinMultiplatform")) { log( "no javadoc artifact for publication $name in project ${project.name}: " + - "no such a task: $docArtifact" + "no such a task: $docArtifact" ) } @@ -410,7 +411,6 @@ fun Project.configureMavenPublications(docArtifactBaseName: String) { } fun Project.createMavenPublications(name: String, vararg componentsStrings: String, docArtifact: String? = null) { - val sourcesJar by tasks.creating(Jar::class) { archiveBaseName.set(project.name) archiveVersion.set(project.version.toString()) @@ -423,8 +423,9 @@ fun Project.createMavenPublications(name: String, vararg componentsStrings: Stri version = project.version.toString() for (component in componentsStrings) { - if (component in components.names) + if (component in components.names) { from(components[component]) + } } if (docArtifact != null && docArtifact in tasks.names) { @@ -434,7 +435,7 @@ fun Project.createMavenPublications(name: String, vararg componentsStrings: Stri } else if (docArtifact == null || !docArtifact.endsWith("KotlinMultiplatform")) { log( "no javadoc artifact for publication $name in project ${project.name}: " + - "no such a task: $docArtifact" + "no such a task: $docArtifact" ) } @@ -448,9 +449,9 @@ fun Project.createMavenPublications(name: String, vararg componentsStrings: Stri fun Set.forEachProject(f: Project.() -> Unit) = allprojects.filter { it.name in this }.forEach(f) fun NamedDomainObjectContainerScope.registerPlatform( - platform: String, configuration: Action + platform: String, + configuration: Action ) { - val low = platform.toLowerCase() val up = platform.toUpperCase() @@ -505,4 +506,4 @@ fun Project.configureJsPackage(packageJsonTask: String = "jsPackageJson", compil .replace("\"2p", "\"@tuprolog/2p") } } -} \ No newline at end of file +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 688fc11c3..175fb9755 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -21,4 +21,4 @@ include("serialize-core") include("serialize-theory") include("repl") -include("examples") \ No newline at end of file +include("examples") From cdfc4073c662b247e62cd1697a8d24590a750351 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 14 Sep 2020 18:24:58 +0200 Subject: [PATCH 33/34] add ktlint check to ci --- .gitlab-ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d808e3829..ae555e94e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,6 +7,7 @@ variables: AFTER_TASK: "" GCMD: "gradle" BUILD_TASK: "clean assemble" + CHECK_CODE_TASK: "ktlintCheck" TEST_TASK: "check -x dokka" TEST_JVM_TASK: "jvmTest -x dokka" TEST_JS_TASK: "clean jsTest -x dokka" @@ -33,6 +34,10 @@ Compile: stage: build script: $GCMD $BEFORE_TASK $BUILD_TASK $AFTER_TASK $GOPTS +Check Format: + stage: build + script: $GCMD $BEFORE_TASK $CHECK_CODE_TASK $AFTER_TASK $GOPTS + Test JVM: stage: test script: $GCMD $BEFORE_TASK $TEST_JVM_TASK $AFTER_TASK $GOPTS From 1af78ac326f9fe5234bc9633ef36800c15f5d032 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 14 Sep 2020 18:27:23 +0200 Subject: [PATCH 34/34] ktlint check in test stage --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ae555e94e..537b86e3c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -35,7 +35,7 @@ Compile: script: $GCMD $BEFORE_TASK $BUILD_TASK $AFTER_TASK $GOPTS Check Format: - stage: build + stage: test script: $GCMD $BEFORE_TASK $CHECK_CODE_TASK $AFTER_TASK $GOPTS Test JVM: