This is an automated email from the ASF dual-hosted git repository.
sergeykamov pushed a commit to branch NLPCRAFT-500
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-500 by this push:
new 26f649ee Tests minor improvements.
26f649ee is described below
commit 26f649ee1cd7c286820672e8fda3077ebba8e193
Author: Sergey Kamov <[email protected]>
AuthorDate: Thu Aug 25 16:35:29 2022 +0300
Tests minor improvements.
---
.../intent/compiler/NCIDLFragmentsOverridingSpec.scala | 14 ++++++++------
.../intent/compiler/NCIDLFragmentsOverridingSpec2.scala | 6 +++---
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsOverridingSpec.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsOverridingSpec.scala
index f03a7a6e..ca071802 100644
---
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsOverridingSpec.scala
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsOverridingSpec.scala
@@ -30,18 +30,20 @@ class NCIDLFragmentsOverridingSpec:
@NCIntent("fragment=f term(x)~{# == 'x1'}")
class M extends NCTestModelAdapter:
// Uses fragment defined on class level.
- @NCIntent("intent=i2 fragment(f)")
- private def onX(ctx: NCContext, im: NCIntentMatch): NCResult =
NCResult(1)
+ @NCIntent("intent=i1 fragment(f)")
+ private def on1(ctx: NCContext, im: NCIntentMatch): NCResult =
NCResult(1)
// Overrides fragment defined on class level by its own.
- @NCIntent("fragment=f term(y)~{# == 'x2'} intent=i1 fragment(f)")
- private def onY(ctx: NCContext, im: NCIntentMatch): NCResult =
NCResult(2)
+ @NCIntent("fragment=f term(y)~{# == 'x2'} intent=i2 fragment(f)")
+ private def on2(ctx: NCContext, im: NCIntentMatch): NCResult =
NCResult(2)
override val getPipeline: NCPipeline = mkEnPipeline(TE("x1"), TE("x2"))
@Test
def test(): Unit =
Using.resource(new NCModelClient(new M())) { client =>
- require(client.ask("x1", "usr").getBody == 1)
- require(client.ask("x2", "usr").getBody == 2)
+ def test(ps: (String, Int)*): Unit =
+ ps.foreach { case (txt, res) => require(client.ask(txt,
"usr").getBody == res) }
+
+ test("x1" -> 1, "x2" -> 2)
}
\ No newline at end of file
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsOverridingSpec2.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsOverridingSpec2.scala
index 4021f3ea..c5b74543 100644
---
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsOverridingSpec2.scala
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsOverridingSpec2.scala
@@ -46,7 +46,7 @@ class NCIDLFragmentsOverridingSpec2:
@Test
def test(): Unit =
Using.resource(new NCModelClient(new M())) { client =>
- require(client.ask("x1", "usr").getBody == 1)
- require(client.ask("x2", "usr").getBody == 2)
- require(client.ask("x3", "usr").getBody == 3)
+ def test(ps: (String, Int)*): Unit = ps.foreach { case (txt, res)
=> require(client.ask(txt, "usr").getBody == res) }
+
+ test("x1" -> 1, "x2" -> 2, "x3" -> 3)
}
\ No newline at end of file