TestDirectives

Conformance tests for directive clauses (:- Goal.), covering dynamic/1, static/1, initialization/1, solve/1, set_flag/2, set_prolog_flag/2, op/3, malformed directives, and directives that fail or raise during theory loading. Shared by every Solver implementation via the TestDirectives.prototype(solverFactory) factory (see TestClassicDirectives in :solve-classic for a concrete usage).

Every test case that loads a directive-bearing theory does so via DirectiveTestsUtils.solverInitializers or DirectiveTestsUtils.solverInitializersWithEventsList, i.e. through all four equivalent ways a theory can end up as a solver's knowledge base (as the static/dynamic theory passed to a factory method, or loaded afterwards into a fresh MutableSolver), since a directive must be honored the same way regardless of how its theory was loaded.

Inheritors

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

A long test max duration, four times mediumDuration; used for queries involving deeper search or recursion.

Link copied to clipboard

A medium test max duration, twice shortDuration; used for queries involving a handful of resolution steps.

Link copied to clipboard

A short test max duration, used for queries expected to resolve almost immediately.

Functions

Link copied to clipboard

Tests that loading, with default built-ins, a theory of DirectiveTestsUtils.bigTheory's default size (40000 facts) completes at all within this suite's test timeout — a basic guard against quadratic-or-worse loading time regressions. Unlike the other test cases here, it does not inspect the resulting solver.

Link copied to clipboard
abstract fun testDynamic1()

Tests that a theory containing

Link copied to clipboard

Tests that a theory with a single initialization/1 directive whose goal raises an it.unibo.tuprolog.solve.exception.error.InstantiationError (an unbound variable used in an arithmetic expression) still loads, and that exactly one InitializationIssue warning event, mentioning the raised error, is emitted.

Link copied to clipboard
abstract fun testExceptionalSolve1()

Same as testExceptionalInitialization1, but for the solve/1 directive instead of initialization/1.

Link copied to clipboard

Tests that a theory with a single initialization/1 directive whose goal always fails still loads (the fact ends up in the appropriate theory), and that exactly one InitializationIssue warning event, mentioning "failure", is emitted.

Link copied to clipboard
abstract fun testFailingSolve1()

Same as testFailingInitialization1, but for the solve/1 directive instead of initialization/1.

Link copied to clipboard
abstract fun testInitialization1()

Tests that, for a theory containing an initialization/1 directive whose goal writes to the standard output and calls another predicate that also writes, loading the theory (via any of DirectiveTestsUtils.solverInitializers) triggers those writes, in clause order, exactly once each, and that the predicate defined after the last initialization/1 directive remains solvable afterwards.

Link copied to clipboard
abstract fun testOp3()

Tests that a theory containing

Link copied to clipboard
abstract fun testSetFlag2()

Tests that a theory containing

Link copied to clipboard
abstract fun testSetPrologFlag2()

Same as testSetFlag2, but using the set_prolog_flag/2 directive instead of set_flag/2.

Link copied to clipboard
abstract fun testSolve1()

Same as testInitialization1, but for the solve/1 directive instead of initialization/1.

Link copied to clipboard
abstract fun testStatic1()

Tests that a theory with the same shape as in testDynamic1 but loaded as a solver's dynamic knowledge base ends up with g/1's facts (following the static/1 directive) moved to the static theory, and every other fact (f/1 and h/1) remaining in the dynamic theory; and that loading it into a fresh MutableSolver via loadDynamicKb produces the same split.

Link copied to clipboard
abstract fun testWrongDirectives()

Tests that a theory mixing malformed directives (op("a", xfx, "++") with a non-integer priority, op(3, "b", "+++") with a non-atom specifier, set_flag(a, x) with an inadmissible value, and misspelled dinamic/1/statyc/1 directives) with well-formed facts still loads without emitting any writing/warning event, and that the facts end up in the theory (static or dynamic, depending on how it was loaded).