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 9d33369 WIP.
9d33369 is described below
commit 9d3336977ead5a5f6df989863298a5c116dd1cb5
Author: Sergey Kamov <[email protected]>
AuthorDate: Fri Mar 26 15:39:14 2021 +0300
WIP.
---
.../idl/compiler/functions/NCIdlFunctions.scala | 29 +++++++++++-----------
.../compiler/functions/NCIdlFunctionsCustom.scala | 24 ++++++++++--------
.../compiler/functions/NCIdlFunctionsMath.scala | 18 +++++++-------
.../compiler/functions/NCIdlFunctionsOther.scala | 1 -
.../compiler/functions/NCIdlFunctionsRequest.scala | 2 +-
.../compiler/functions/NCIdlFunctionsStat.scala | 15 +++++------
.../compiler/functions/NCIdlFunctionsStrings.scala | 15 +++++------
.../compiler/functions/NCIdlFunctionsToken.scala | 4 +--
8 files changed, 56 insertions(+), 52 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 d034a19..35eb0f7 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
@@ -205,24 +205,25 @@ private[functions] trait NCIdlFunctions {
}
}
- protected def expectError(f: TestDesc): Unit =
- try {
- test(f)
+ protected def expectError(funcs: TestDesc*): Unit =
+ for (f ← funcs)
+ try {
+ test(f)
- require(false)
- }
- catch {
- case e: Exception ⇒
- println(s"Expected error: ${e.getLocalizedMessage}")
+ require(false)
+ }
+ catch {
+ case e: Exception ⇒
+ println(s"Expected error: ${e.getLocalizedMessage}")
- var cause = e.getCause
+ var cause = e.getCause
- while (cause != null) {
- println(s" Cause: ${cause.getLocalizedMessage}
(${cause.getClass.getName})")
+ while (cause != null) {
+ println(s" Cause: ${cause.getLocalizedMessage}
(${cause.getClass.getName})")
- cause = cause.getCause
- }
- }
+ cause = cause.getCause
+ }
+ }
protected implicit def convert(pred: String): TestDesc = TestDesc(truth =
pred)
}
\ No newline at end of file
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 1edd7cc..651ca1e 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
@@ -43,17 +43,21 @@ class NCIdlFunctionsCustom extends NCIdlFunctions {
@Test
def testErrors(): Unit = {
- def test(truth: String): Unit = expectError(TestDesc(truth = truth,
isCustom = true))
+ def test(truth: String*): Unit =
+ for (t ← truth)
+ expectError(TestDesc(truth = t, isCustom = true))
- test("invalid")
- test(s"$C#missed")
- test(s"$C#wrongParams1")
- test(s"$C#wrongParams2")
- test(s"$C#wrongParams3")
- test(s"$C#wrongRet1")
- test(s"$C#wrongRet2")
- test(s"$C#wrongExec1")
- test(s"$C#wrongExec2")
+ test(
+ "invalid",
+ s"$C#missed",
+ s"$C#wrongParams1",
+ s"$C#wrongParams2",
+ s"$C#wrongParams3",
+ s"$C#wrongRet1",
+ s"$C#wrongRet2",
+ s"$C#wrongExec1",
+ s"$C#wrongExec2"
+ )
}
@Test
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 9596dc2..e921ee8 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
@@ -25,15 +25,15 @@ import org.junit.jupiter.api.Test
*/
class NCIdlFunctionsMath extends NCIdlFunctions {
@Test
- def testError(): Unit = {
- // Invalid name.
- expectError("xxx(1, 1)")
- expectError("xxx()")
-
- // Invalid arguments count.
- expectError("atan(1, 1) == 1")
- expectError("pi(1)")
- }
+ def testError(): Unit =
+ expectError(
+ // Invalid name.
+ "xxx(1, 1)",
+ "xxx()",
+ // Invalid arguments count.
+ "atan(1, 1) == 1",
+ "pi(1)"
+ )
@Test
def test(): Unit =
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 6d0dacf..de1c718 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
@@ -68,5 +68,4 @@ class NCIdlFunctionsOther extends NCIdlFunctions {
"false != true",
"true != 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 b756389..32daca3 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
@@ -46,7 +46,7 @@ class NCIdlFunctionsRequest extends NCIdlFunctions {
mkTestDesc(s"req_normtext() == '$reqNormText'"),
mkTestDesc(s"req_tstamp() == $reqTstamp"),
mkTestDesc(s"req_addr() == '$reqAddr'"),
- mkTestDesc(s"req_agent() == '$reqAgent'"),
+ mkTestDesc(s"req_agent() == '$reqAgent'")
)
}
}
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 4e99c1b..b41b596 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
@@ -24,12 +24,13 @@ import org.junit.jupiter.api.Test
*/
class NCIdlFunctionsStat extends NCIdlFunctions {
@Test
- def testError(): Unit = {
- expectError("avg(list()) == 2")
- expectError("avg(list('A')) == 2")
- expectError("stdev(list()) == 2")
- expectError("stdev(list('A')) == 2")
- }
+ def testError(): Unit =
+ expectError(
+ "avg(list()) == 2",
+ "avg(list('A')) == 2",
+ "stdev(list()) == 2",
+ "stdev(list('A')) == 2"
+ )
@Test
def test(): Unit =
@@ -45,6 +46,6 @@ class NCIdlFunctionsStat extends NCIdlFunctions {
"stdev(list(1, 2.2, 3.1)) > 0",
"stdev(list(1, 2, 3)) > 0",
"stdev(list(0.0, 0.0, 0.0)) == 0.0",
- "stdev(list(0, 0, 0)) == 0.0",
+ "stdev(list(0, 0, 0)) == 0.0"
)
}
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 9a33eaf..12e621b 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
@@ -77,11 +77,12 @@ class NCIdlFunctionsStrings extends NCIdlFunctions {
)
@Test
- def testError(): Unit = {
- expectError("substr('abc', 10, 30) == 'bc'")
- expectError("split('1 A') == true")
- expectError("split_trim('1 A') == true")
- expectError("to_double('1, 1') == true")
- expectError("to_double('A') == true")
- }
+ def testError(): Unit =
+ expectError(
+ "substr('abc', 10, 30) == 'bc'",
+ "split('1 A') == true",
+ "split_trim('1 A') == true",
+ "to_double('1, 1') == true",
+ "to_double('A') == 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 f985559..cdf2e49 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
@@ -105,8 +105,6 @@ class NCIdlFunctionsToken extends NCIdlFunctions {
truth = "tok_end_idx() == 123",
token = tkn(end = 123)
),
- TestDesc(
- truth = "tok_this() == tok_this()"
- )
+ TestDesc(truth = "tok_this() == tok_this()")
)
}