test: 对象化前的最后稳定版本

- OopInheritTest 全部类补类体字段声明(x/y/r/w/h/health/battery 等), 保证父类字段展平与 GEP 偏移正确
- 多个测试适配 i8* 指针比较语义(== 指针地址比较改 string.strcmp)
- 删除 ZlibTest/__zlib 旧实现与 find.py 调试脚本
- 更新 TODO 与 TestProject
This commit is contained in:
TermiNexus committed 2026-08-09 22:19:29 +08:00
1 parent cd1f662e17
commit e1cb560df0
23 files changed
+151 -3265

No files matched your search

+22 -22
View File
@@ -116,9 +116,9 @@ def main() -> CInt | CExport:
p1: str = parts[1]
p2: str = parts[2]
stdio.printf("parts[0]='%s' [1]='%s' [2]='%s'\n", p0, p1, p2)
testcheck.check(p0 == "a", "split[0]=='a' OK", "split[0] FAILED")
testcheck.check(p1 == "b", "split[1]=='b' OK", "split[1] FAILED")
testcheck.check(p2 == "c", "split[2]=='c' OK", "split[2] FAILED")
testcheck.check(string.strcmp(p0, "a") == 0, "split[0]=='a' OK", "split[0] FAILED")
testcheck.check(string.strcmp(p1, "b") == 0, "split[1]=='b' OK", "split[1] FAILED")
testcheck.check(string.strcmp(p2, "c") == 0, "split[2]=='c' OK", "split[2] FAILED")
# Test 2: 空字符串分割
testcheck.section("Test 2: 无分隔符 'hello'")
@@ -129,7 +129,7 @@ def main() -> CInt | CExport:
stdio.printf("split('hello', ',') len=%lu\n", n2)
testcheck.check(n2 == 1, "no-delim len OK (1)", "no-delim len FAILED expect 1")
h0: str = parts2.get(0)
testcheck.check(h0 == "hello", "no-delim[0]=='hello' OK", "no-delim[0] FAILED")
testcheck.check(string.strcmp(h0, "hello") == 0, "no-delim[0]=='hello' OK", "no-delim[0] FAILED")
# Test 3: 连续分隔符
testcheck.section("Test 3: 连续分隔符 'a,,b'")
@@ -143,9 +143,9 @@ def main() -> CInt | CExport:
e1: str = parts3.get(1)
e2: str = parts3.get(2)
stdio.printf("parts[0]='%s' [1]='%s' [2]='%s'\n", e0, e1, e2)
testcheck.check(e0 == "a", "consec[0]=='a' OK", "consec[0] FAILED")
testcheck.check(e1 == "", "consec[1]=='' OK", "consec[1] FAILED")
testcheck.check(e2 == "b", "consec[2]=='b' OK", "consec[2] FAILED")
testcheck.check(string.strcmp(e0, "a") == 0, "consec[0]=='a' OK", "consec[0] FAILED")
testcheck.check(string.strcmp(e1, "") == 0, "consec[1]=='' OK", "consec[1] FAILED")
testcheck.check(string.strcmp(e2, "b") == 0, "consec[2]=='b' OK", "consec[2] FAILED")
# Test 4: 空字符串
testcheck.section("Test 4: 空字符串 ''")
@@ -168,9 +168,9 @@ def main() -> CInt | CExport:
w1: str = parts5[1]
w2: str = parts5[2]
stdio.printf("words[0]='%s' [1]='%s' [2]='%s'\n", w0, w1, w2)
testcheck.check(w0 == "hello", "space[0]=='hello' OK", "space[0] FAILED")
testcheck.check(w1 == "world", "space[1]=='world' OK", "space[1] FAILED")
testcheck.check(w2 == "foo", "space[2]=='foo' OK", "space[2] FAILED")
testcheck.check(string.strcmp(w0, "hello") == 0, "space[0]=='hello' OK", "space[0] FAILED")
testcheck.check(string.strcmp(w1, "world") == 0, "space[1]=='world' OK", "space[1] FAILED")
testcheck.check(string.strcmp(w2, "foo") == 0, "space[2]=='foo' OK", "space[2] FAILED")
# Test 6: 多字符分隔符 '::'
testcheck.section("Test 6: 多字符分隔符 '::' on 'a::b::c'")
@@ -184,9 +184,9 @@ def main() -> CInt | CExport:
m1: str = parts6[1]
m2: str = parts6[2]
stdio.printf("parts[0]='%s' [1]='%s' [2]='%s'\n", m0, m1, m2)
testcheck.check(m0 == "a", "multi-colon[0]=='a' OK", "multi-colon[0] FAILED")
testcheck.check(m1 == "b", "multi-colon[1]=='b' OK", "multi-colon[1] FAILED")
testcheck.check(m2 == "c", "multi-colon[2]=='c' OK", "multi-colon[2] FAILED")
testcheck.check(string.strcmp(m0, "a") == 0, "multi-colon[0]=='a' OK", "multi-colon[0] FAILED")
testcheck.check(string.strcmp(m1, "b") == 0, "multi-colon[1]=='b' OK", "multi-colon[1] FAILED")
testcheck.check(string.strcmp(m2, "c") == 0, "multi-colon[2]=='c' OK", "multi-colon[2] FAILED")
# Test 7: 多字符分隔符 ', ' (逗号+空格)
testcheck.section("Test 7: 多字符分隔符 ', ' on 'hello, world, foo'")
@@ -200,9 +200,9 @@ def main() -> CInt | CExport:
cs1: str = parts7[1]
cs2: str = parts7[2]
stdio.printf("parts[0]='%s' [1]='%s' [2]='%s'\n", cs0, cs1, cs2)
testcheck.check(cs0 == "hello", "comma-space[0]=='hello' OK", "comma-space[0] FAILED")
testcheck.check(cs1 == "world", "comma-space[1]=='world' OK", "comma-space[1] FAILED")
testcheck.check(cs2 == "foo", "comma-space[2]=='foo' OK", "comma-space[2] FAILED")
testcheck.check(string.strcmp(cs0, "hello") == 0, "comma-space[0]=='hello' OK", "comma-space[0] FAILED")
testcheck.check(string.strcmp(cs1, "world") == 0, "comma-space[1]=='world' OK", "comma-space[1] FAILED")
testcheck.check(string.strcmp(cs2, "foo") == 0, "comma-space[2]=='foo' OK", "comma-space[2] FAILED")
# Test 8: 多字符分隔符在首尾
testcheck.section("Test 8: 多字符分隔符首尾 '::a::b::'")
@@ -217,10 +217,10 @@ def main() -> CInt | CExport:
ed2: str = parts8[2]
ed3: str = parts8[3]
stdio.printf("parts[0]='%s' [1]='%s' [2]='%s' [3]='%s'\n", ed0, ed1, ed2, ed3)
testcheck.check(ed0 == "", "edge[0]=='' OK", "edge[0] FAILED")
testcheck.check(ed1 == "a", "edge[1]=='a' OK", "edge[1] FAILED")
testcheck.check(ed2 == "b", "edge[2]=='b' OK", "edge[2] FAILED")
testcheck.check(ed3 == "", "edge[3]=='' OK", "edge[3] FAILED")
testcheck.check(string.strcmp(ed0, "") == 0, "edge[0]=='' OK", "edge[0] FAILED")
testcheck.check(string.strcmp(ed1, "a") == 0, "edge[1]=='a' OK", "edge[1] FAILED")
testcheck.check(string.strcmp(ed2, "b") == 0, "edge[2]=='b' OK", "edge[2] FAILED")
testcheck.check(string.strcmp(ed3, "") == 0, "edge[3]=='' OK", "edge[3] FAILED")
# === with 上下文自动注入测试 ===
testcheck.section("Test 9: with 上下文自动注入 __mbuddy__")
@@ -237,12 +237,12 @@ def main() -> CInt | CExport:
# upper() 不需要手动设置 __mbuddy__
w_upper: str = w_str.upper()
stdio.printf("with upper('WithTest') = %s\n", w_upper)
testcheck.check(w_upper == "WITHTEST", "with upper OK", "with upper FAILED")
testcheck.check(string.strcmp(w_upper, "WITHTEST") == 0, "with upper OK", "with upper FAILED")
# lower() 不需要手动设置 __mbuddy__
w_lower: str = w_str.lower()
stdio.printf("with lower('WithTest') = %s\n", w_lower)
testcheck.check(w_lower == "withtest", "with lower OK", "with lower FAILED")
testcheck.check(string.strcmp(w_lower, "withtest") == 0, "with lower OK", "with lower FAILED")
# split() 不需要手动设置 __mbuddy__
w_split_str: str = "x,y,z"