-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some test referred to the built in: atom_chars, atom_length , cha…
…r_code, atom_codes and atom_concat.
- Loading branch information
1 parent
d2bafa3
commit 1524d19
Showing
5 changed files
with
267 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
146 changes: 146 additions & 0 deletions
146
test-solve/src/commonMain/kotlin/it/unibo/tuprolog/solve/TestingAtomBuiltIn.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
package it.unibo.tuprolog.solve | ||
|
||
import it.unibo.tuprolog.dsl.theory.prolog | ||
import kotlin.collections.listOf as ktListOf | ||
|
||
object TestingAtomBuiltIn { | ||
|
||
/** | ||
* atom_chars Testing | ||
* | ||
* Contained requests: | ||
* ```prolog | ||
* ?- atom_chars(X,[t,e,s,t]). | ||
* ?- atom_chars(test,[t,e,s,t]). | ||
* ?- atom_chars(test,[t,e,s,T]). | ||
* ?- atom_chars(test1,[t,e,s,T]). | ||
* ``` | ||
*/ | ||
|
||
val atomCharsTesting by lazy { | ||
prolog { | ||
ktListOf( | ||
"atom_chars"("X",listOf("t","e","s","t")).hasSolutions({yes("X" to "test")} | ||
), | ||
"atom_chars"(atomOf("test"),listOf("t","e","s","t")).hasSolutions({yes()} | ||
), | ||
"atom_chars"(atomOf("test"),listOf("t","e","s","T")).hasSolutions({yes("T" to "t")} | ||
), | ||
"atom_chars"(atomOf("test1"),listOf("t","e","s","t")).hasSolutions({no()} | ||
) | ||
) | ||
} | ||
} | ||
|
||
/** | ||
* atom_length Testing | ||
* | ||
* Contained requests: | ||
* ```prolog | ||
* ?- atom_length(test,4). | ||
* ?- atom_length(test,X). | ||
* ?- atom_length(X,4). | ||
* ?- atom_length(42,X). | ||
* ?- atom_chars(test,5). | ||
* ``` | ||
*/ | ||
|
||
val atomLenghtTesting by lazy{ | ||
prolog { | ||
ktListOf( | ||
"atom_length"(atomOf("test"),intOf(4)).hasSolutions({yes()} | ||
), | ||
"atom_length"(atomOf("test"),"X").hasSolutions({yes("X" to 4)} | ||
), | ||
"atom_length"("X",intOf(4)).hasSolutions({no()} | ||
), | ||
"atom_length"(atomOf("42"),"X").hasSolutions({yes("X" to 2)} | ||
), | ||
"atom_length"(atomOf("test"),intOf(5)).hasSolutions({no()} | ||
) | ||
) | ||
} | ||
} | ||
|
||
/** | ||
* char_code Testing | ||
* | ||
* Contained requests: | ||
* ```prolog | ||
* ?- char_code(a,X). | ||
* ?- char_code(X,97). | ||
* ?- char_code(X,a). | ||
* ?- char_code(g,103). | ||
* ``` | ||
*/ | ||
|
||
|
||
|
||
val charCodeTesting by lazy{ | ||
prolog { | ||
ktListOf( | ||
"char_code"("a","X").hasSolutions({yes("X" to 97)} | ||
), | ||
"char_code"("X",intOf(97)).hasSolutions({yes("X" to "a")} | ||
), | ||
"char_code"("X","a").hasSolutions({no()} | ||
), | ||
"char_code"("g",intOf(103)).hasSolutions({yes()} | ||
) | ||
) | ||
} | ||
} | ||
|
||
/** | ||
* atom_codes Testing | ||
* | ||
* Contained requests: | ||
* ```prolog | ||
* ?- atom_codes(abc,X). | ||
* ?- atom_codes(test,X). | ||
* ?- atom_codes(test,[116,101,115,116]). | ||
* ?- atom_codes(test,[112,101,115,116]). | ||
* ``` | ||
*/ | ||
|
||
val atomCodesTesting by lazy{ | ||
prolog { | ||
ktListOf( | ||
"atom_codes"(atomOf("abc"),"X").hasSolutions({yes("X" to listOf("97,98,99"))} | ||
), | ||
"atom_codes"(atomOf("test"),"X").hasSolutions({yes("X" to listOf("116,101,115,116"))} | ||
), | ||
"atom_codes"(atomOf("test"),listOf("116,101,115,116")).hasSolutions({yes()} | ||
), | ||
"atom_codes"(atomOf("test"),listOf("112,101,115,116")).hasSolutions({no()} | ||
) | ||
) | ||
} | ||
} | ||
|
||
/** | ||
* atom_concat Testing | ||
* | ||
* Contained requests: | ||
* ```prolog | ||
* ?- atom_concat(test,concat,X). | ||
* ?- atom_concat(test,concat,test). | ||
* ?- atom_concat(test,X,testTest). | ||
* ``` | ||
*/ | ||
|
||
val atomConcatTesting by lazy { | ||
prolog { | ||
ktListOf( | ||
"atom_concat"(atomOf("test"),atomOf("concat"),"X").hasSolutions({yes("X" to atomOf("testconcat"))} | ||
), | ||
"atom_concat"(atomOf("test"),atomOf("concat"),atomOf("test")).hasSolutions({no()} | ||
), | ||
"atom_concat"(atomOf("test"),atomOf("X"),atomOf("testTest")).hasSolutions({yes("X" to atomOf("Test"))} | ||
) | ||
) | ||
} | ||
} | ||
|
||
|
||
} |