From b8b465e093c299b392820465d108df04ea19f776 Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 14 Sep 2020 15:10:58 +0200 Subject: [PATCH] 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