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 a8db1cf WIP.
a8db1cf is described below
commit a8db1cfc50bd5b8206d9a17cf19b9b28bb1e1e33
Author: Sergey Kamov <[email protected]>
AuthorDate: Wed Mar 24 11:10:01 2021 +0300
WIP.
---
.../compiler/functions/NCIdlFunctionsMath.scala | 3 ++
.../compiler/functions/NCIdlFunctionsMeta.scala | 33 +++++++++++++---------
.../compiler/functions/NCIdlFunctionsOther.scala | 9 ------
3 files changed, 23 insertions(+), 22 deletions(-)
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 1e89459..cec7346 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
@@ -45,6 +45,9 @@ class NCIdlFunctionsMath extends NCIdlFunctions {
"floor(1.1) == 1.0",
"rint(1.8) == 2.0",
"round(1.8) == 2",
+ s"to_double(25) == 25.0",
+ s"to_double(25) != 25", // double != int without rounding.
+ s"round(to_double(25)) == 25",
"signum(-1.8) == -1.0",
"sqrt(4) - 2 < 0.001",
"cbrt(8) - 2 < 0.001",
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 f05802f..91f5a4e 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
@@ -28,8 +28,6 @@ import scala.sys.SystemProperties
/**
* Tests for 'meta' functions.
- * TODO: add meta_model
- * TODO: add meta_intent
*/
class NCIdlFunctionsMeta extends NCIdlFunctions {
@Test
@@ -38,40 +36,40 @@ class NCIdlFunctionsMeta extends NCIdlFunctions {
sys.put("k1", "v1")
- test("meta_sys")
+ testValue("meta_sys")
}
@Test
def testMetaToken(): Unit =
- test(
+ testValue(
"meta_token",
token = Some(tkn(meta = Map("k1" → "v1")))
)
@Test
def testMetaRequest(): Unit =
- test(
+ testValue(
"meta_req",
ctx(reqData = Map("k1" → "v1"))
)
@Test
def testMetaConv(): Unit =
- test(
+ testValue(
"meta_conv",
ctx(convMeta = Map("k1" → "v1"))
)
@Test
def testMetaFrag(): Unit =
- test(
+ testValue(
"meta_frag",
ctx(fragMeta = Map("k1" → "v1"))
)
@Test
def testMetaUser(): Unit =
- test(
+ testValue(
"meta_user",
ctx(usr =
new NCUser {
@@ -90,7 +88,7 @@ class NCIdlFunctionsMeta extends NCIdlFunctions {
@Test
def testMetaCompany(): Unit =
- test(
+ testValue(
"meta_company",
ctx(comp =
new NCCompany {
@@ -108,8 +106,17 @@ class NCIdlFunctionsMeta extends NCIdlFunctions {
)
)
- private def test(f: String, idlCtx: ⇒ NCIdlContext = ctx(), token:
Option[NCToken] = None): Unit =
- test(
- TestDesc(truth = s"$f('k1') == 'v1'", token = token, idlCtx =
idlCtx)
- )
+ // Simplified test.
+ @Test
+ def testMetaModel(): Unit = testNoValue("meta_model", ctx())
+
+ // Simplified test.
+ @Test
+ def testMetaIntent(): Unit = testNoValue("meta_intent", ctx())
+
+ private def testValue(f: String, idlCtx: ⇒ NCIdlContext = ctx(), token:
Option[NCToken] = None): Unit =
+ test(TestDesc(truth = s"$f('k1') == 'v1'", token = token, idlCtx =
idlCtx))
+
+ private def testNoValue(f: String, idlCtx: ⇒ NCIdlContext = ctx(), token:
Option[NCToken] = None): Unit =
+ test(TestDesc(truth = s"$f('k1') == null", token = token, 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 284144e..a47e46e 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
@@ -55,13 +55,4 @@ class NCIdlFunctionsOther extends NCIdlFunctions {
"to_string(3.123) == '3.123'"
)
}
-
- @Test
- def test4(): Unit = {
- test(
- s"to_double(25) == 25.0",
- s"to_double(25) != 25", // double != int without rounding.
- s"round(to_double(25)) == 25"
- )
- }
}