This is an automated email from the ASF dual-hosted git repository.

sergeykamov pushed a commit to branch NLPCRAFT-283
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git


The following commit(s) were added to refs/heads/NLPCRAFT-283 by this push:
     new 9d6e877  WIP.
9d6e877 is described below

commit 9d6e877e7c36a83e394ad7916e341e193e496075
Author: Sergey Kamov <[email protected]>
AuthorDate: Thu Mar 25 16:55:45 2021 +0300

    WIP.
---
 .../idl/compiler/functions/NCIdlFunctions.scala    |  4 +--
 .../compiler/functions/NCIdlFunctionsCustom.scala  | 33 +++++++++++-----------
 .../functions/NCIdlFunctionsTokensUsed.scala       | 12 ++++----
 3 files changed, 25 insertions(+), 24 deletions(-)

diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctions.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctions.scala
index 052a3b9..6e7b58f 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctions.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctions.scala
@@ -51,7 +51,7 @@ private[functions] trait NCIdlFunctions {
         idlCtx: NCIdlContext = ctx(),
         isCustom: Boolean = false,
         expectedRes: Boolean = true,
-        expectedTokensUsed: Option[Int] = None
+        tokensUsed: Option[Int] = None
     ) {
         // It should be lazy for errors verification methods.
         lazy val term: NCIdlTerm = {
@@ -184,7 +184,7 @@ private[functions] trait NCIdlFunctions {
                     )
             }
 
-            f.expectedTokensUsed match {
+            f.tokensUsed match {
                 case Some(exp) ⇒
                     require(
                         exp == item.tokUse,
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsCustom.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsCustom.scala
index 14a4272..2dae012 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsCustom.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsCustom.scala
@@ -20,13 +20,14 @@ package 
org.apache.nlpcraft.model.intent.idl.compiler.functions
 import org.apache.nlpcraft.model.{NCTokenPredicateContext, 
NCTokenPredicateResult}
 import org.junit.jupiter.api.Test
 
-class NCIdlFunctionsCustomImpl {
+class NCIdlTokensTestWrapper {
     def trueOn123(ctx: NCTokenPredicateContext): NCTokenPredicateResult =
         new NCTokenPredicateResult(ctx.getToken.getOriginalText == "123", 1)
 
-    def wrongParams1(): NCTokenPredicateResult = null
-    def wrongParams2(s: String): NCTokenPredicateResult = null
-    def wrongParams3(s: String, ctx: NCTokenPredicateContext): 
NCTokenPredicateResult = null
+    def wrongParams1(): NCTokenPredicateResult = new 
NCTokenPredicateResult(true, 1)
+    def wrongParams2(s: String): NCTokenPredicateResult = new 
NCTokenPredicateResult(true, 1)
+    def wrongParams3(s: String, ctx: NCTokenPredicateContext): 
NCTokenPredicateResult =
+        new NCTokenPredicateResult(true, 1)
     def wrongRet1(ctx: NCTokenPredicateContext): String = ""
     def wrongRet2(ctx: NCTokenPredicateContext): Unit = {}
     def wrongExec1(ctx: NCTokenPredicateContext): NCTokenPredicateResult = null
@@ -42,31 +43,31 @@ class NCIdlFunctionsCustom extends NCIdlFunctions {
         def test(truth: String): Unit = expectError(TestDesc(truth = truth, 
isCustom = true))
 
         test("invalid")
-        
test("org.apache.nlpcraft.model.intent.idl.compiler.functions.NCIdlFunctionsCustomImpl#missed")
-        
test("org.apache.nlpcraft.model.intent.idl.compiler.functions.NCIdlFunctionsCustomImpl#wrongParams1")
-        
test("org.apache.nlpcraft.model.intent.idl.compiler.functions.NCIdlFunctionsCustomImpl#wrongParams2")
-        
test("org.apache.nlpcraft.model.intent.idl.compiler.functions.NCIdlFunctionsCustomImpl#wrongParams3")
-        
test("org.apache.nlpcraft.model.intent.idl.compiler.functions.NCIdlFunctionsCustomImpl#wrongRet1")
-        
test("org.apache.nlpcraft.model.intent.idl.compiler.functions.NCIdlFunctionsCustomImpl#wrongRet2")
-        
test("org.apache.nlpcraft.model.intent.idl.compiler.functions.NCIdlFunctionsCustomImpl#wrongExec1")
-        
test("org.apache.nlpcraft.model.intent.idl.compiler.functions.NCIdlFunctionsCustomImpl#wrongExec2")
+        
test("org.apache.nlpcraft.model.intent.idl.compiler.functions.NCIdlTokensTestWrapper#missed")
+        
test("org.apache.nlpcraft.model.intent.idl.compiler.functions.NCIdlTokensTestWrapper#wrongParams1")
+        
test("org.apache.nlpcraft.model.intent.idl.compiler.functions.NCIdlTokensTestWrapper#wrongParams2")
+        
test("org.apache.nlpcraft.model.intent.idl.compiler.functions.NCIdlTokensTestWrapper#wrongParams3")
+        
test("org.apache.nlpcraft.model.intent.idl.compiler.functions.NCIdlTokensTestWrapper#wrongRet1")
+        
test("org.apache.nlpcraft.model.intent.idl.compiler.functions.NCIdlTokensTestWrapper#wrongRet2")
+        
test("org.apache.nlpcraft.model.intent.idl.compiler.functions.NCIdlTokensTestWrapper#wrongExec1")
+        
test("org.apache.nlpcraft.model.intent.idl.compiler.functions.NCIdlTokensTestWrapper#wrongExec2")
     }
 
     @Test
     def test(): Unit =
         test(
             TestDesc(
-                truth = 
"org.apache.nlpcraft.model.intent.idl.compiler.functions.NCIdlFunctionsCustomImpl#trueOn123",
+                truth = 
"org.apache.nlpcraft.model.intent.idl.compiler.functions.NCIdlTokensTestWrapper#trueOn123",
                 isCustom = true,
                 token = Some(tkn(txt = "123")),
-                expectedTokensUsed = Some(1)
+                tokensUsed = Some(1)
             ),
             TestDesc(
-                truth = 
"org.apache.nlpcraft.model.intent.idl.compiler.functions.NCIdlFunctionsCustomImpl#trueOn123",
+                truth = 
"org.apache.nlpcraft.model.intent.idl.compiler.functions.NCIdlTokensTestWrapper#trueOn123",
                 isCustom = true,
                 token = Some(tkn(txt = "456")),
                 expectedRes = false,
-                expectedTokensUsed = Some(1)
+                tokensUsed = Some(1)
             )
         )
 }
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsTokensUsed.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsTokensUsed.scala
index b6267d5..8b62bdd 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsTokensUsed.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsTokensUsed.scala
@@ -28,27 +28,27 @@ class NCIdlFunctionsTokensUsed extends NCIdlFunctions {
         test(
             TestDesc(
                 truth = "1 == 1",
-                expectedTokensUsed = Some(0)
+                tokensUsed = Some(0)
             ),
             TestDesc(
                 truth = "tok_id() == 'a'",
                 token = Some(tkn(id = "a")),
-                expectedTokensUsed = Some(1)
+                tokensUsed = Some(1)
             ),
             TestDesc(
                 truth = "tok_id() == 'a' && tok_id() == 'a'",
                 token = Some(tkn(id = "a")),
-                expectedTokensUsed = Some(2)
+                tokensUsed = Some(2)
             ),
             TestDesc(
                 truth = "tok_id() == 'a' && tok_parent() == 'b'",
                 token = Some(tkn(id = "a", parentId = "b")),
-                expectedTokensUsed = Some(2)
+                tokensUsed = Some(2)
             ),
             TestDesc(
-                truth = "tok_id() == 'a'  && tok_id() == 'a' && tok_parent() 
== 'b'",
+                truth = "tok_id() == 'a' && tok_id() == 'a' && tok_parent() == 
'b'",
                 token = Some(tkn(id = "a", parentId = "b")),
-                expectedTokensUsed = Some(3)
+                tokensUsed = Some(3)
             )
         )
 }

Reply via email to