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

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


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

commit d8ac64a01372df06aa7ce0007b0cf34fbb7a66cf
Author: Sergey Kamov <[email protected]>
AuthorDate: Tue Mar 23 16:39:55 2021 +0300

    WIP.
---
 .../idl/compiler/functions/NCIdlFunctions.scala    | 16 ++++++++-------
 .../compiler/functions/NCIdlFunctionsColl.scala    | 12 +++++------
 .../compiler/functions/NCIdlFunctionsCompany.scala |  2 +-
 .../compiler/functions/NCIdlFunctionsDate.scala    | 24 +++++++++++-----------
 .../compiler/functions/NCIdlFunctionsMath.scala    |  6 +++---
 .../compiler/functions/NCIdlFunctionsMeta.scala    |  4 ++--
 .../compiler/functions/NCIdlFunctionsOther.scala   |  8 ++++----
 .../compiler/functions/NCIdlFunctionsRequest.scala |  2 +-
 .../compiler/functions/NCIdlFunctionsStat.scala    |  4 ++--
 .../compiler/functions/NCIdlFunctionsStrings.scala | 12 +++++------
 .../compiler/functions/NCIdlFunctionsToken.scala   |  4 ++--
 .../compiler/functions/NCIdlFunctionsUser.scala    |  2 +-
 12 files changed, 49 insertions(+), 47 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 46a4290..92e42eb 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
@@ -43,7 +43,7 @@ private[functions] trait NCIdlFunctions {
     @BeforeEach
     def before(): Unit = NCIdlCompilerGlobal.clearCache(MODEL_ID)
 
-    case class TestData(truth: String, token: Option[NCToken] = None, idlCtx: 
NCIdlContext = ctx()) {
+    case class TestDesc(truth: String, token: Option[NCToken] = None, idlCtx: 
NCIdlContext = ctx()) {
         val predicate: NCIdlFunction = {
             val intents = NCIdlCompiler.compileIntents(s"intent=i 
term(t)={$truth}", MODEL, MODEL_ID)
 
@@ -60,12 +60,12 @@ private[functions] trait NCIdlFunctions {
             }
     }
 
-    object TestData {
-        def apply(truth: String, token: NCToken, idlCtx: NCIdlContext): 
TestData =
-            TestData(truth = truth, token = Some(token), idlCtx = idlCtx)
+    object TestDesc {
+        def apply(truth: String, token: NCToken, idlCtx: NCIdlContext): 
TestDesc =
+            TestDesc(truth = truth, token = Some(token), idlCtx = idlCtx)
 
-        def apply(truth: String, token: NCToken): TestData =
-            TestData(truth = truth, token = Some(token))
+        def apply(truth: String, token: NCToken): TestDesc =
+            TestDesc(truth = truth, token = Some(token))
     }
 
     private def t2s(t: NCToken) = {
@@ -137,7 +137,7 @@ private[functions] trait NCIdlFunctions {
         }
     }
 
-    protected def test(funcs: TestData*): Unit =
+    protected def test(funcs: TestDesc*): Unit =
         for (f ← funcs) {
             val res =
                 try
@@ -159,4 +159,6 @@ private[functions] trait NCIdlFunctions {
                     )
             }
         }
+
+    protected implicit def convert(pred: String): TestDesc = TestDesc(truth = 
pred)
 }
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsColl.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsColl.scala
index a56a9da..9e4bd14 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsColl.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsColl.scala
@@ -26,11 +26,11 @@ class NCIdlFunctionsColl extends NCIdlFunctions {
     @Test
     def test(): Unit =
         test(
-            TestData(truth = "is_empty(list()) == true"),
-            TestData(truth = "is_empty(list(1)) == false"),
-            TestData(truth = "non_empty(list()) == false"),
-            TestData(truth = "non_empty(list(1)) == true"),
-            TestData(truth = "first(list(1, 2, 3)) == 1"),
-            TestData(truth = "last(list(1, 2, 3)) == 3")
+            "is_empty(list()) == true",
+            "is_empty(list(1)) == false",
+            "non_empty(list()) == false",
+            "non_empty(list(1)) == true",
+            "first(list(1, 2, 3)) == 1",
+            "last(list(1, 2, 3)) == 3"
         )
 }
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsCompany.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsCompany.scala
index 708e922..6ac6b0f 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsCompany.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsCompany.scala
@@ -46,7 +46,7 @@ class NCIdlFunctionsCompany extends NCIdlFunctions {
         val idlCtx = ctx(comp = comp)
 
         test(
-            TestData(
+            TestDesc(
                 truth = s"comp_name() == '${comp.getName}'",
                 idlCtx = idlCtx
             )
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsDate.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsDate.scala
index 427b341..32bd8bf 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsDate.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsDate.scala
@@ -35,18 +35,18 @@ class NCIdlFunctionsDate extends NCIdlFunctions {
             val c = Calendar.getInstance()
 
             test(
-                TestData(truth = s"year() - ${d.getYear} == 0"),
-                TestData(truth = s"month() - ${d.getMonthValue} == 0"),
-                TestData(truth = s"day_of_month() - ${d.getDayOfMonth} == 0"),
-                TestData(truth = s"day_of_week() - ${d.getDayOfWeek.getValue} 
== 0"),
-                TestData(truth = s"day_of_year() - ${d.getDayOfYear} == 0"),
-                TestData(truth = s"hour() - ${t.getHour} == 0"),
-                TestData(truth = s"minute() - ${t.getMinute} == 0"),
-                TestData(truth = s"second() - ${t.getSecond} < 5"),
-                TestData(truth = s"week_of_month() - 
${c.get(Calendar.WEEK_OF_MONTH)} == 0"),
-                TestData(truth = s"week_of_year() - 
${c.get(Calendar.WEEK_OF_YEAR)} == 0"),
-                TestData(truth = s"quarter() - 
${d.get(IsoFields.QUARTER_OF_YEAR)} == 0"),
-                TestData(truth = s"now() - ${System.currentTimeMillis()} < 
5000")
+                s"year() - ${d.getYear} == 0",
+                s"month() - ${d.getMonthValue} == 0",
+                s"day_of_month() - ${d.getDayOfMonth} == 0",
+                s"day_of_week() - ${d.getDayOfWeek.getValue} == 0",
+                s"day_of_year() - ${d.getDayOfYear} == 0",
+                s"hour() - ${t.getHour} == 0",
+                s"minute() - ${t.getMinute} == 0",
+                s"second() - ${t.getSecond} < 5",
+                s"week_of_month() - ${c.get(Calendar.WEEK_OF_MONTH)} == 0",
+                s"week_of_year() - ${c.get(Calendar.WEEK_OF_YEAR)} == 0",
+                s"quarter() - ${d.get(IsoFields.QUARTER_OF_YEAR)} == 0",
+                s"now() - ${System.currentTimeMillis()} < 5000"
             )
         }
 
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsMath.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsMath.scala
index 033ffb1..a6e15a5 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsMath.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsMath.scala
@@ -26,8 +26,8 @@ class NCIdlFunctionsMath extends NCIdlFunctions {
     @Test
     def test(): Unit =
         test(
-            TestData(truth = "sin(90.0) == 0"),
-            TestData(truth = "sin(90) == 0"),
-            TestData(truth = "rand() < 1")
+            "sin(90.0) == 0",
+            "sin(90) == 0",
+            "rand() < 1)"
         )
 }
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsMeta.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsMeta.scala
index 1cd74f1..5a54c20 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsMeta.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsMeta.scala
@@ -32,7 +32,7 @@ class NCIdlFunctionsMeta extends NCIdlFunctions {
         sys.put("k1", "v1")
 
         test(
-            TestData(truth = "get(meta_sys(), 'k1') == 'v1'")
+            TestDesc(truth = "get(meta_sys(), 'k1') == 'v1'")
         )
     }
 
@@ -41,7 +41,7 @@ class NCIdlFunctionsMeta extends NCIdlFunctions {
         val idlCtx = ctx(reqData = Map("k1" → "v1"))
 
         test(
-            TestData(truth = "get(meta_req(), 'k1') == 'v1'", idlCtx = idlCtx)
+            TestDesc(truth = "get(meta_req(), 'k1') == 'v1'", idlCtx = idlCtx)
         )
     }
 }
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsOther.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsOther.scala
index d1e04eb..b8c2e52 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsOther.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsOther.scala
@@ -29,8 +29,8 @@ class NCIdlFunctionsOther extends NCIdlFunctions {
     def test1(): Unit =
         // If.
         test(
-            TestData(truth = "if(true, 1, 0) == 1"),
-            TestData(truth = "if(false, 1, 0) == 0")
+            TestDesc(truth = "if(true, 1, 0) == 1"),
+            TestDesc(truth = "if(false, 1, 0) == 0")
         )
 
     @Test
@@ -41,8 +41,8 @@ class NCIdlFunctionsOther extends NCIdlFunctions {
 
         // JSON.
         test(
-            TestData(truth = "has(json(meta_sys()), 'k1') == true"),
-            TestData(truth = "has(json(meta_sys()), 'k2') == false")
+            "has(json(meta_sys()), 'k1') == true",
+            "has(json(meta_sys()), 'k2') == false"
         )
     }
 }
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsRequest.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsRequest.scala
index ea4b1d0..d28cdad 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsRequest.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsRequest.scala
@@ -28,7 +28,7 @@ class NCIdlFunctionsRequest extends NCIdlFunctions {
         val idlCtx = ctx(srvReqId = "req.id")
 
         test(
-            TestData(
+            TestDesc(
                 truth = s"req_id() == '${idlCtx.req.getServerRequestId}'",
                 idlCtx = idlCtx
             )
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsStat.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsStat.scala
index 5ec613f..1d2b607 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsStat.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsStat.scala
@@ -26,7 +26,7 @@ class NCIdlFunctionsStat extends NCIdlFunctions {
     @Test
     def test(): Unit =
         test(
-            TestData(truth = "max(list(1, 2, 3)) == 3"),
-            TestData(truth = "min(list(1, 2, 3)) == 1")
+            "max(list(1, 2, 3)) == 3",
+            "min(list(1, 2, 3)) == 1"
         )
 }
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsStrings.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsStrings.scala
index 43d19b2..3784115 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsStrings.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsStrings.scala
@@ -26,11 +26,11 @@ class NCIdlFunctionsStrings extends NCIdlFunctions {
     @Test
     def test(): Unit =
         test(
-            TestData(truth = "trim(' a b  ') == 'a b'"),
-            TestData(truth = "strip(' a b  ') == 'a b'"),
-            TestData(truth = "uppercase('aB') == 'AB'"),
-            TestData(truth = "lowercase('aB') == 'ab'"),
-            TestData(truth = "is_num('a') == false"),
-            TestData(truth = "is_num('1') == true")
+            "trim(' a b  ') == 'a b'",
+            "strip(' a b  ') == 'a b'",
+            "uppercase('aB') == 'AB'",
+            "lowercase('aB') == 'ab'",
+            "is_num('a') == false",
+            "is_num('1') == true"
         )
 }
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsToken.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsToken.scala
index fb9721d..36c07f1 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsToken.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsToken.scala
@@ -26,11 +26,11 @@ class NCIdlFunctionsToken extends NCIdlFunctions {
     @Test
     def test(): Unit =
         test(
-            TestData(
+            TestDesc(
                 truth = "id() == 'a'",
                 token = tkn(id = "a")
             ),
-            TestData(
+            TestDesc(
                 truth = "parent() == 'a'",
                 token = tkn(parentId = "a")
             )
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsUser.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsUser.scala
index 3883aaa..1e2c11d 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsUser.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsUser.scala
@@ -45,7 +45,7 @@ class NCIdlFunctionsUser extends NCIdlFunctions {
         val idlCtx = ctx(usr = usr)
 
         test(
-            TestData(
+            TestDesc(
                 truth = s"user_email() == '${usr.getEmail.get()}'",
                 idlCtx = idlCtx
             )

Reply via email to