diff --git a/Cargo.lock b/Cargo.lock index 89c3bef..e8d1427 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,7 +74,7 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "babel_nar" -version = "0.24.5" +version = "0.24.6" dependencies = [ "anyhow", "clap", diff --git a/Cargo.toml b/Cargo.toml index 7174cb5..ad253a2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "babel_nar" -version = "0.24.5" +version = "0.24.6" edition = "2021" description = """ Implementation and application supports of the NAVM model diff --git a/src/bin/babelnar_cli/main.rs b/src/bin/babelnar_cli/main.rs index 161af4e..880f424 100644 --- a/src/bin/babelnar_cli/main.rs +++ b/src/bin/babelnar_cli/main.rs @@ -193,6 +193,10 @@ mod tests { cin_tests! { ONA; + /// 真值通配 + /// * 📝✅【2024-06-15 20:31:10】成功 + nal_tw => NAL_TRUTH_WILDCARD + /// 简单演绎 /// * 📝✅【2024-04-19 22:49:51】成功 nal_de => NAL_SIMPLE_DEDUCTION @@ -229,6 +233,10 @@ mod tests { #[ignore = "【2024-04-14 20:24:52】会导致残留子进程"] OPENNARS; + /// 真值通配 + /// * 📝✅【2024-06-15 20:31:10】成功 + nal_tw => NAL_TRUTH_WILDCARD + /// 简单演绎 /// * 📝✅【2024-04-19 22:49:02】成功(步数性能上不佳) nal_de => NAL_SIMPLE_DEDUCTION @@ -263,6 +271,10 @@ mod tests { #[ignore = "【2024-04-14 20:24:52】会导致残留子进程"] OPENNARS_158; + /// 真值通配 + /// * 📝✅【2024-06-15 20:31:10】成功 + nal_tw => NAL_TRUTH_WILDCARD + /// 简单演绎 /// * 📝✅【2024-04-19 23:02:59】成功 nal_de => NAL_SIMPLE_DEDUCTION @@ -296,6 +308,10 @@ mod tests { cin_tests! { PYNARS; + /// 真值通配 + /// * 📝❌【2024-06-15 20:39:59】失败:原因不明 + nal_tw => NAL_TRUTH_WILDCARD + /// 简单演绎 /// * 📝✅【2024-04-19 23:04:24】成功 nal_de => NAL_SIMPLE_DEDUCTION @@ -334,6 +350,10 @@ mod tests { cin_tests! { CXIN_JS; + /// 真值通配 + /// * 📝❌【2024-06-15 20:41:37】失败:没有ANSWER + nal_tw => NAL_TRUTH_WILDCARD + /// 简单演绎 /// * 📝❌【2024-04-07 14:37:49】失败:导出了结论,但没法回答 /// * 📄只能导出`C>. %1;0.9%` @@ -370,6 +390,10 @@ mod tests { cin_tests! { NATIVE_IL_1; + /// 真值通配 + /// * 📝❌【2024-06-15 20:42:18】失败:尚不支持 + nal_tw => NAL_TRUTH_WILDCARD + /// 简单演绎 /// * 📝✅【2024-04-09 21:12:10】成功 nal_de => NAL_SIMPLE_DEDUCTION diff --git a/src/lib.rs b/src/lib.rs index 592a638..aae2129 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -93,6 +93,8 @@ pub mod tests { NAL_OPERATION = "./src/tests/cli/config/nal_operation.hjson" /// NAL/简单操作 NAL_SIMPLE_OPERATION = "./src/tests/cli/config/nal_simple_operation.hjson" + /// NAL/真值通配 + NAL_TRUTH_WILDCARD = "./src/tests/cli/config/nal_truth_wildcard.hjson" /// Websocket WEBSOCKET = "./src/tests/cli/config/websocket.hjson" diff --git a/src/test_tools/vm_interact/narsese_expectation.rs b/src/test_tools/vm_interact/narsese_expectation.rs index fb790b9..0f4817a 100644 --- a/src/test_tools/vm_interact/narsese_expectation.rs +++ b/src/test_tools/vm_interact/narsese_expectation.rs @@ -46,7 +46,7 @@ fn _is_expected_narsese(mut expected: Narsese, mut out: Narsese) -> bool { let fold = PartialFoldResult::try_from; match (fold(expected), fold(out)) { // * 🚩若均解析成功⇒进一步判等 - (Ok(expected), Ok(out)) => out.is_expected_out(&expected), + (Ok(expected), Ok(out)) => expected.is_expected_out(&out), // * 🚩任一解析失败⇒直接失败 _ => false, } @@ -227,3 +227,5 @@ pub fn is_expected_operation(expected: &Operation, out: &Operation) -> bool { (false, false) => expected.params == out.params, } } + +// TODO: 单元测试 diff --git a/src/tests/cli/config/nal_truth_wildcard.hjson b/src/tests/cli/config/nal_truth_wildcard.hjson new file mode 100644 index 0000000..75186be --- /dev/null +++ b/src/tests/cli/config/nal_truth_wildcard.hjson @@ -0,0 +1,10 @@ +#hjson +// * 🎯测试「真值通配」 +// * ℹ️测试环境交由`prelude_test.hjson`加载 +// * 📌原则:每个配置文件中引用的相对路径,均基于「配置文件自身」的路径 +{ + preludeNAL: { + // 预置的NAL测试文件(相对配置文件自身) + file: ./../../nal/test_truth_wildcard.nal + } +} \ No newline at end of file diff --git a/src/tests/nal/test_truth_wildcard.nal b/src/tests/nal/test_truth_wildcard.nal new file mode 100644 index 0000000..cea965a --- /dev/null +++ b/src/tests/nal/test_truth_wildcard.nal @@ -0,0 +1,22 @@ +' 用于测试BabelNAR CLI的「真值通配」功能 +' * 📍所涉及NAL层级:NAL-1 +' * 📝在「文件表示」上利用现有`Narsese`语法 +' +' 输出预期 `expect-contains` +' * 📝统一的NAL测试语法:`''expect-contains: 【输出类别】 【其它内容】` +' * 📄预期「回答」:`''expect-contains: ANSWER A. [可选的真值]` + +' 🚩降低音量,减少无关输出 +'/VOL 0 + +' 🚩【2024-04-07 14:22:28】兼容PyNARS:给启动留足时间 +''sleep: 0.5s + +A. +A? + +' 检验输出 | 每10步有0.25s睡眠延时,给足输出呈现时间 +''expect-cycle(100, 10, 0.25s): ANSWER A. + +' 用户无法输入时退出(正常退出) +''terminate(if-no-user)