You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by se...@apache.org on 2022/08/22 11:24:39 UTC

[incubator-nlpcraft] branch NLPCRAFT-511 created (now 8ca3c79d)

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

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


      at 8ca3c79d Test fixes.

This branch includes the following new commits:

     new 8ca3c79d Test fixes.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[incubator-nlpcraft] 01/01: Test fixes.

Posted by se...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 8ca3c79d3a730d84ace45c42636b87ffabf5a98f
Author: Sergey Kamov <sk...@gmail.com>
AuthorDate: Mon Aug 22 14:24:30 2022 +0300

    Test fixes.
---
 .../internal/intent/compiler/NCIDLCodeGenerator.scala       |  4 ++--
 .../intent/compiler/functions/NCIDLFunctionsModel.scala     | 13 ++++++++++++-
 .../intent/compiler/functions/NCIDLFunctionsOther.scala     |  3 ++-
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLCodeGenerator.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLCodeGenerator.scala
index 2bd957ec..6c48be8c 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLCodeGenerator.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLCodeGenerator.scala
@@ -897,7 +897,7 @@ trait NCIDLCodeGenerator:
                 // Metadata access.
                 case "meta_ent" => z[ST](arg1, { x => val Z(v, _) = x(); Z(box(ent.impl.get[Object](toStr(v))), 0) })
                 case "meta_cfg" => z[ST](arg1, { x => val Z(v, _) = x(); Z(box(idlCtx.mdlCfg.get[Object](toStr(v))), 0) })
-                case "meta_req" => z[ST](arg1, { x => val Z(v, _) = x(); Z(box(idlCtx.req.getRequestData.get(toStr(v))), 0) })
+                case "meta_req" => z[ST](arg1, { x => val Z(v, _) = x(); Z(box(idlCtx.req.getRequestData.get(toStr(v)).orNull.asInstanceOf[Object]), 0) })
                 case "meta_intent" => z[ST](arg1, { x => val Z(v, _) = x(); Z(box(idlCtx.intentMeta.get(toStr(v)).orNull), 0) })
                 case "meta_conv" => z[ST](arg1, { x => val Z(v, _) = x(); Z(box(idlCtx.convMeta.get(toStr(v)).orNull), 0) })
                 case "meta_frag" => z[ST](arg1, { x => val Z(v, f) = x(); Z(box(idlCtx.fragMeta.get(toStr(v)).orNull), f) })
@@ -914,7 +914,7 @@ trait NCIDLCodeGenerator:
                 case "mdl_id" => z0(() => Z(idlCtx.mdlCfg.getId, 0))
                 case "mdl_name" => z0(() => Z(idlCtx.mdlCfg.getName, 0))
                 case "mdl_ver" => z0(() => Z(idlCtx.mdlCfg.getVersion, 0))
-                case "mdl_origin" => z0(() => Z(idlCtx.mdlCfg.getOrigin, 0))
+                case "mdl_origin" => z0(() => Z(idlCtx.mdlCfg.getOrigin.orNull, 0))
 
                 // Entity functions.
                 case "ent_id" => arg1Tok() match { case x => stack.push(() => Z(toEntity(x().value).impl.getId, 1)) }
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsModel.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsModel.scala
index 91576a39..a059f4ee 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsModel.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsModel.scala
@@ -32,11 +32,22 @@ class NCIDLFunctionsModel extends NCIDLFunctions:
     def test(): Unit =
         val idlCtx = mkIdlContext(cfg = CFG)
 
+        require(idlCtx.mdlCfg.getOrigin.nonEmpty)
+
         def mkTestDesc(truth: String): TestDesc = TestDesc(truth = truth, idlCtx = idlCtx)
 
         test(
             mkTestDesc(s"mdl_id == '${idlCtx.mdlCfg.getId}'"),
             mkTestDesc(s"mdl_name == '${idlCtx.mdlCfg.getName}'"),
             mkTestDesc(s"mdl_ver == '${idlCtx.mdlCfg.getVersion}'"),
-            mkTestDesc(s"mdl_origin == '${idlCtx.mdlCfg.getOrigin}'")
+            mkTestDesc(s"mdl_origin == '${idlCtx.mdlCfg.getOrigin.orNull}'")
         )
+
+    @Test
+    def testEmptyOrigin(): Unit =
+        val idlCtx = mkIdlContext(cfg = NCModelConfig("testId", "test", "1.0"))
+
+        require(idlCtx.mdlCfg.getOrigin.isEmpty)
+
+        test(TestDesc(truth = s"null == ${idlCtx.mdlCfg.getOrigin.orNull}", idlCtx = idlCtx))
+
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsOther.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsOther.scala
index e1f7fb34..650a773c 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsOther.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsOther.scala
@@ -69,5 +69,6 @@ class NCIDLFunctionsOther extends NCIDLFunctions:
             "true == true",
             "false == false",
             "false != true",
-            "true != false"
+            "true != false",
+            "null == null"
         )