42 lines
No EOL
1.1 KiB
Kotlin
42 lines
No EOL
1.1 KiB
Kotlin
package prolog.logic
|
|
|
|
import org.junit.jupiter.api.Assertions.*
|
|
import org.junit.jupiter.api.Test
|
|
import prolog.ast.terms.Atom
|
|
import prolog.ast.terms.Functor
|
|
import prolog.ast.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))
|
|
|
|
assertEquals(Functor("foo", 0), atom.functor)
|
|
}
|
|
|
|
@Test
|
|
fun compound_arity_0_properties() {
|
|
val structure = Structure("foo")
|
|
|
|
assertFalse(atomic(structure))
|
|
assertTrue(compound(structure))
|
|
}
|
|
|
|
@Test
|
|
fun compound_arity_1_properties() {
|
|
val structure = Structure("foo", Atom("bar"))
|
|
|
|
assertFalse(atomic(structure))
|
|
assertTrue(compound(structure))
|
|
|
|
assertEquals(Functor("foo", 1), structure.functor)
|
|
}
|
|
} |