Skip to content

Commit d9e1714

Browse files
committed
test: alternative syntax for lists
1 parent 78ba1c8 commit d9e1714

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/main/scala/io/github/kelvindev15/prolog/dsl/DSLConversions.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ package io.github.kelvindev15.prolog.dsl
22

33
import io.github.kelvindev15.prolog.core.Constant.Atom
44
import io.github.kelvindev15.prolog.core.Struct.Fact
5-
import io.github.kelvindev15.prolog.core.{Constant, Struct}
5+
import io.github.kelvindev15.prolog.core.{Constant, PrologList, Struct, Term}
66

77
object DSLConversions:
88
given Conversion[String, Atom] = Atom(_)
99
given Conversion[AnyVal, Constant.Numeric] = Constant.Numeric(_)
1010
given Conversion[Struct, Fact] = Fact(_)
11+
given Conversion[Seq[Term], PrologList] = PrologList(_*)

src/test/scala/io/github/kelvindev15/dsl/TestDSL.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package io.github.kelvindev15.dsl
44
import io.github.kelvindev15.prolog.core.Constant.Atom
55
import io.github.kelvindev15.prolog.core.Struct.{Directive, Fact, Rule}
66
import io.github.kelvindev15.prolog.core.Variable.anonymous
7-
import io.github.kelvindev15.prolog.core.{Constant, RecursiveStruct, Struct, Term, Variable}
7+
import io.github.kelvindev15.prolog.core.{Constant, PrologList, RecursiveStruct, Struct, Term, Variable}
88
import io.github.kelvindev15.prolog.dsl.PrologDSL
99
import org.scalatest.funsuite.AnyFunSuite
1010
import org.scalatest.matchers.should.Matchers
@@ -53,3 +53,9 @@ class TestDSL extends AnyFunSuite with Matchers with PrologDSL:
5353

5454
test("Alternative syntax for pipe notation"):
5555
(head(1, 2, 3, 4) | T) shouldBe cons(1, 2, 3, 4)(T)
56+
57+
test("Sequence of terms as a PrologList"):
58+
val toBeMatched = PrologList(H, "a", "b", 1, 2)
59+
val list = cons(H, Seq[Term]("a", "b", 1, 2))
60+
list shouldBe toBeMatched
61+
cons(H, head("a", "b", 1, 2)) shouldBe list

0 commit comments

Comments
 (0)