Checkpoint
This commit is contained in:
parent
39c3af4ba5
commit
da21d890fb
39 changed files with 1166 additions and 48 deletions
43
tests/prolog/builtins/TermAnalysisConstructionTest.kt
Normal file
43
tests/prolog/builtins/TermAnalysisConstructionTest.kt
Normal file
|
@ -0,0 +1,43 @@
|
|||
package prolog.builtins
|
||||
|
||||
import org.junit.jupiter.api.Assertions.assertFalse
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.assertThrows
|
||||
import prolog.components.terms.Atom
|
||||
import prolog.components.terms.Structure
|
||||
|
||||
/**
|
||||
* Based on [Predicates for analyzing/constructing terms](https://github.com/dtonhofer/prolog_notes/blob/master/swipl_notes/about_term_analysis_and_construction/term_analysis_construction.png)
|
||||
*
|
||||
* Notes by [David Tonhofer](https://github.com/dtonhofer)
|
||||
*/
|
||||
class TermAnalysisConstructionTest {
|
||||
@Test
|
||||
fun atomic_term_properties() {
|
||||
val atom = Atom("foo")
|
||||
|
||||
assertTrue(atomic(atom))
|
||||
assertFalse(compound(atom))
|
||||
|
||||
assertTrue(functor(atom, Atom("foo"), 0))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun compound_arity_0_properties() {
|
||||
val structure = Structure(Atom("foo"), emptyList())
|
||||
|
||||
assertFalse(atomic(structure))
|
||||
assertTrue(compound(structure))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun compound_arity_1_properties() {
|
||||
val structure = Structure(Atom("foo"), listOf(Atom("bar")))
|
||||
|
||||
assertFalse(atomic(structure))
|
||||
assertTrue(compound(structure))
|
||||
|
||||
assertTrue(functor(structure, Atom("foo"), 1))
|
||||
}
|
||||
}
|
Reference in a new issue