WIP.
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 @@
"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 @@
/**
* Tests for 'meta' functions.
- * TODO: add meta_model
- * TODO: add meta_intent
*/
class NCIdlFunctionsMeta extends NCIdlFunctions {
@Test
@@ -38,40 +36,40 @@
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 @@
@Test
def testMetaCompany(): Unit =
- test(
+ testValue(
"meta_company",
ctx(comp =
new NCCompany {
@@ -108,8 +106,17 @@
)
)
- 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 @@
"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"
- )
- }
}