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 3328ecf WIP.
3328ecf is described below
commit 3328ecf41659a6fefd3774bac00238e6d9c1d44e
Author: Sergey Kamov <[email protected]>
AuthorDate: Thu Mar 25 11:58:17 2021 +0300
WIP.
---
.../functions/NCIdlFunctionsTokensUsed.scala | 54 ++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsTokensUsed.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsTokensUsed.scala
new file mode 100644
index 0000000..b6267d5
--- /dev/null
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsTokensUsed.scala
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.nlpcraft.model.intent.idl.compiler.functions
+
+import org.junit.jupiter.api.Test
+
+/**
+ * Tests for 'tokens used' result.
+ */
+class NCIdlFunctionsTokensUsed extends NCIdlFunctions {
+ @Test
+ def test(): Unit =
+ test(
+ TestDesc(
+ truth = "1 == 1",
+ expectedTokensUsed = Some(0)
+ ),
+ TestDesc(
+ truth = "tok_id() == 'a'",
+ token = Some(tkn(id = "a")),
+ expectedTokensUsed = Some(1)
+ ),
+ TestDesc(
+ truth = "tok_id() == 'a' && tok_id() == 'a'",
+ token = Some(tkn(id = "a")),
+ expectedTokensUsed = Some(2)
+ ),
+ TestDesc(
+ truth = "tok_id() == 'a' && tok_parent() == 'b'",
+ token = Some(tkn(id = "a", parentId = "b")),
+ expectedTokensUsed = Some(2)
+ ),
+ TestDesc(
+ truth = "tok_id() == 'a' && tok_id() == 'a' && tok_parent()
== 'b'",
+ token = Some(tkn(id = "a", parentId = "b")),
+ expectedTokensUsed = Some(3)
+ )
+ )
+}