Skip to content

Commit

Permalink
fix: ✅ 修复测试文件的路径问题
Browse files Browse the repository at this point in the history
从BabelNAR.rs中迁移`src/tests`的内容
  • Loading branch information
ARCJ137442 committed Sep 12, 2024
1 parent 2357f6f commit 07c276d
Show file tree
Hide file tree
Showing 24 changed files with 501 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/tests/cli/config/_arg_parse_test.opennars.hjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#hjson
// * ⚠️仅作「读取配置」测试用
// * 📌包含OpenNARS转译器 及其jar启动的命令配置
// * 🎯用于测试「预加载NAL输入」,加载「简单演绎推理」
{
// 转译器
translators: "opennars"
// 启动命令
command: {
// 命令:启动java运行时
cmd: "java"
// 传入的命令参数
cmdArgs: [
// 设置最大堆内存为1024M
"-Xmx1024m"
// 启动jar包
-jar
nars.jar
]
// 启动时的工作目录 | 仅测试「以配置自身为根」
currentDir: ./../executables
}
}
19 changes: 19 additions & 0 deletions src/tests/cli/config/cin_cxin_js.hjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#hjson
// * 🎯用于测试CXinNARS(JS版本)
// * 📌使用Node.js启动
{
// 转译器支持单独指定「输入转译器」和「输出转译器」
translators: cxin_js
command: {
// * ⚠️必须前缀`./`以指定是「启动当前工作目录下的exe文件」
cmd: node
cmdArgs: [
cxin-nars-shell.js
shell
]
// * 🚩现在基于「固定位置的CIN程序包」运行测试
// * 回溯路径:config(`./`) => cli => tests => src => BabelNAR.rs / executables
currentDir: ./../../../../executables
}
autoRestart: true
}
16 changes: 16 additions & 0 deletions src/tests/cli/config/cin_native_il_1.hjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#hjson
// * 🎯用于测试原生「IL-1」运行时
// * ✨基于NAVM,纯Rust编写
{
// 使用「原生」输入输出转译器
translators: native
command: {
// * ⚠️必须前缀`./`以指定是「启动当前工作目录下的exe文件」
cmd: ./native-IL-1.exe
cmdArgs: []
// * 🚩现在基于「固定位置的CIN程序包」运行测试
// * 回溯路径:config(`./`) => cli => tests => src => BabelNAR.rs / executables
currentDir: ./../../../../executables
}
autoRestart: true
}
22 changes: 22 additions & 0 deletions src/tests/cli/config/cin_ona.hjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#hjson
// * 🎯用于测试ONA
// * ⚠️启动需要cygwin
// * 🔗中文官网: http://www.cygwin.cn/
{
// 转译器支持单独指定「输入转译器」和「输出转译器」
translators: {
in: ona
out: ona
}
command: {
// * ⚠️必须前缀`./`以指定是「启动当前工作目录下的exe文件」
cmd: ./ONA.exe
cmdArgs: [
shell
]
// * 🚩现在基于「固定位置的CIN程序包」运行测试
// * 回溯路径:config(`./`) => cli => tests => src => BabelNAR.rs / executables
currentDir: ./../../../../executables
}
autoRestart: true
}
23 changes: 23 additions & 0 deletions src/tests/cli/config/cin_opennars.hjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#hjson
// OpenNARS 3.0.4 的启动配置
{
// 转译器
translators: "opennars"
// 启动命令
command: {
// 命令:启动java运行时
cmd: "java"
// 传入的命令参数
cmdArgs: [
// 设置最大堆内存为1024M
"-Xmx1024m"
// 启动jar包
-jar
./opennars-304-T-modified.jar
]
// 启动时的工作目录
// * 🚩现在基于「固定位置的CIN程序包」运行测试
// * 回溯路径:config(`./`) => cli => tests => src => BabelNAR.rs / executables
currentDir: ./../../../../executables
}
}
23 changes: 23 additions & 0 deletions src/tests/cli/config/cin_opennars_158.hjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#hjson
// OpenNARS 1.5.8 的启动配置
{
// 转译器
translators: "opennars"
// 启动命令
command: {
// 命令:启动java运行时
cmd: "java"
// 传入的命令参数
cmdArgs: [
// 设置最大堆内存为1024M
"-Xmx1024m"
// 启动jar包
-jar
./opennars-158-shell.jar
]
// 启动时的工作目录
// * 🚩现在基于「固定位置的CIN程序包」运行测试
// * 回溯路径:config(`./`) => cli => tests => src => BabelNAR.rs / executables
currentDir: ./../../../../executables
}
}
15 changes: 15 additions & 0 deletions src/tests/cli/config/cin_pynars.hjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// PyNARS的启动配置
{
translators: pynars
command: {
cmd: python
cmdArgs: [
"-m"
// * 🚩【2024-04-07 14:41:20】使用扩展了「附加指令」的「高级控制台」
pynars.ConsolePlus
]
// * 🚩【2024-04-07 14:26:30】现在「CIN测试用运行时」路径已固定
currentDir: ./../../../../executables/PyNARS
}
autoRestart: true
}
18 changes: 18 additions & 0 deletions src/tests/cli/config/matriangle_server.hjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#hjson
// * 🎯对接Matriangle服务器
// * ✨兼容旧BabelNAR与Matriangle的Websocket交互逻辑
{
// Websocket服务端地址
websocket: {
// * ❌【2024-04-07 23:05:21】不能是`localhost`,需要是`127.0.0.1`(Matriangle端要求)
host: 127.0.0.1
port: 8765
}
// 【2024-04-04 04:49:32】Matriangle环境目前以「NAVM指令」的形式传入
inputMode: cmd
preludeNAL: {
// 预置的NAL指令
// * 🔬【2024-04-08 15:43:27】控制程序输出:当产生大量输出时,将会发生线程死锁
text: "'''VOL 0"
}
}
10 changes: 10 additions & 0 deletions src/tests/cli/config/nal_higher_deduction.hjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#hjson
// * 🎯测试「高阶演绎推理」
// * ℹ️测试环境交由`prelude_test.hjson`加载
// * 📌原则:每个配置文件中引用的相对路径,均基于「配置文件自身」的路径
{
preludeNAL: {
// 预置的NAL测试文件(相对配置文件自身)
file: ./../../nal/test_higher_deduction.nal
}
}
10 changes: 10 additions & 0 deletions src/tests/cli/config/nal_i_var_elimination.hjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#hjson
// * 🎯测试「自变量消去推理」
// * ℹ️测试环境交由`prelude_test.hjson`加载
// * 📌原则:每个配置文件中引用的相对路径,均基于「配置文件自身」的路径
{
preludeNAL: {
// 预置的NAL测试文件(相对配置文件自身)
file: ./../../nal/test_i_var_elimination.nal
}
}
10 changes: 10 additions & 0 deletions src/tests/cli/config/nal_operation.hjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#hjson
// * 🎯测试「操作推理」
// * ℹ️测试环境交由`prelude_test.hjson`加载
// * 📌原则:每个配置文件中引用的相对路径,均基于「配置文件自身」的路径
{
preludeNAL: {
// 预置的NAL测试文件(相对配置文件自身)
file: ./../../nal/test_operation.nal
}
}
10 changes: 10 additions & 0 deletions src/tests/cli/config/nal_simple_deduction.hjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#hjson
// * 🎯测试「简单演绎推理」
// * ℹ️测试环境交由`prelude_test.hjson`加载
// * 📌原则:每个配置文件中引用的相对路径,均基于「配置文件自身」的路径
{
preludeNAL: {
// 预置的NAL测试文件(相对配置文件自身)
file: ./../../nal/test_simple_deduction.nal
}
}
10 changes: 10 additions & 0 deletions src/tests/cli/config/nal_simple_operation.hjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#hjson
// * 🎯测试「简单操作推理」
// * ℹ️测试环境交由`prelude_test.hjson`加载
// * 📌原则:每个配置文件中引用的相对路径,均基于「配置文件自身」的路径
{
preludeNAL: {
// 预置的NAL测试文件(相对配置文件自身)
file: ./../../nal/test_simple_operation.nal
}
}
10 changes: 10 additions & 0 deletions src/tests/cli/config/nal_temporal_induction.hjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#hjson
// * 🎯测试「时间归纳推理」
// * ℹ️测试环境交由`prelude_test.hjson`加载
// * 📌原则:每个配置文件中引用的相对路径,均基于「配置文件自身」的路径
{
preludeNAL: {
// 预置的NAL测试文件(相对配置文件自身)
file: ./../../nal/test_temporal_induction.nal
}
}
10 changes: 10 additions & 0 deletions src/tests/cli/config/nal_truth_wildcard.hjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#hjson
// * 🎯测试「真值通配」
// * ℹ️测试环境交由`prelude_test.hjson`加载
// * 📌原则:每个配置文件中引用的相对路径,均基于「配置文件自身」的路径
{
preludeNAL: {
// 预置的NAL测试文件(相对配置文件自身)
file: ./../../nal/test_truth_wildcard.nal
}
}
14 changes: 14 additions & 0 deletions src/tests/cli/config/prelude_test.hjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#hjson
// * 🎯测试「预加载NAL输入」,并统一设置「测试环境」
// * ⚠️不包括具体的「预引入NAL」文件定义
{
// preludeNAL: ""
// 禁止用户输入
userInput: false
// 不自动重启
autoRestart: false
// 开启严格模式
// * 🎯用于自动化测试中捕获错误
// * ✨可由此被外部脚本调用
strictMode: true
}
8 changes: 8 additions & 0 deletions src/tests/cli/config/websocket.hjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#hjson
// 用于测试可作补丁的Websocket配置
{
websocket: {
host: localhost
port: 8080
}
}
33 changes: 33 additions & 0 deletions src/tests/nal/test_higher_deduction.nal
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
' 用于测试CIN的「高阶演绎推理」
' * 📍所涉及NAL层级:NAL-5
' * 📝在「文件表示」上利用现有`Narsese`语法
'
' 输出等待 `expect-contains`
' * 📝统一的NAL等待语法:`''await: 【输入类别】 【其它内容】`
' * ⚠️可能会阻塞测试,慎用
' * 🚩以下await已被注释失效,仅作语法演示
'
' 输出预期 `expect-contains`
' * 📝统一的NAL测试语法:`''expect-contains: 【输出类别】 【其它内容】`
' * 📄预期「回答」:`''expect-contains: ANSWER 【CommonNarsese】`
' * 📄预期「操作」:`''expect-contains: EXE (^【操作名】, 【操作参数(CommonNarsese词项)】)`

' 🚩降低音量,减少无关输出
'/VOL 0

' 🚩【2024-04-07 14:22:28】兼容PyNARS:给启动留足时间
''sleep: 0.5s

<<A --> B> ==> <C --> D>>.
' // ''await: IN <<A --> B> ==> <C --> D>>.
<A --> B>.
' // ''await: IN <A --> B>.
<C --> D>?

' 检验输出
''expect-cycle(100, 10, 0.25s): ANSWER <C --> D>.
' * 🚩【2024-04-19 21:45:12】↑OpenNARS 3.x引入了大量心理操作,因此在「逐步递进」测试中性能不佳
' * 📝【2024-04-19 21:46:42】OpenNARS 158、ONA、PyNARS等均能在五步之内回答

' 用户无法输入时退出(正常退出)
''terminate(if-no-user)
24 changes: 24 additions & 0 deletions src/tests/nal/test_i_var_elimination.nal
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
' 用于测试「自变量消除」
' * 📍所涉及NAL层级:NAL-5、NAL-6
'
' 输出预期
' * 📝统一的NAL测试语法:`''expect-contains: 【输出类别】 【其它内容】`
' * 📄预期「回答」:`''expect-contains: ANSWER 【CommonNarsese】`
' * 📄预期「操作」:`''expect-contains: EXE (^【操作名】, 【操作参数(CommonNarsese词项)】)`
' * 🚩【2024-04-03 02:10:19】有时对操作需要等待足够的时长,才能捕获到输出

' 🚩降低音量,减少无关输出
'/VOL 0

' 🚩【2024-04-07 14:22:28】兼容PyNARS:给启动留足时间
''sleep: 0.5s

<A --> B>.
<<A --> $1> ==> <$1 --> C>>.
<B --> C>?

' 检验输出 | ⚠️0.25s需要兼容PyNARS
''expect-cycle(200, 20, 0.25s): ANSWER <B --> C>.

' 用户无法输入时退出(正常退出)
''terminate(if-no-user)
Loading

0 comments on commit 07c276d

Please sign in to comment.