chore(syntax): Test 仓 R1 + R12 迁移
R1:T | t.CPtr -> T*(40 文件 / 1121 处;含多级 **、强转位 (T*)(x)、下标内 list[AST*]);引号前向引用 'Rect' | t.CPtr 26 处按例外保留,T | t.CPtr | t.State 25 处因 T* 后不能接 | 保持原联合写法。 R12:i = 0 + while i < N: + 尾 i += 1 -> or i in range(N):(10 文件 / 42 处;含 <= -> range(EXPR + 1)、带注解初始化 i: int = 0、尾 i = i + 1)。余 20 处经守卫判定不可安全改写(复合条件 1、尾部非自增 8、体内重绑定/continue 5、while-else 2、循环后仍被读取 2、找不到初始化 2)。
This commit is contained in:
1 parent
f5da836fbb
commit
aa5a7e7250
43 files changed
+851
-935
No files matched your search
@@ -6,13 +6,13 @@ import w32.win32memory
|
||||
|
||||
def test_strlen():
|
||||
testcheck.section("Test 1: strlen")
|
||||
s: char | t.CPtr = "Hello, World!"
|
||||
s: char* = "Hello, World!"
|
||||
length: uint64 = string.strlen(s)
|
||||
testcheck.check(length == 13, "strlen (len=13)", "strlen (expect 13)")
|
||||
|
||||
def test_strcpy():
|
||||
testcheck.section("Test 2: strcpy")
|
||||
buf: char | t.CPtr = w32.win32memory.VirtualAlloc(None, 64, 12288, 4)
|
||||
buf: char* = w32.win32memory.VirtualAlloc(None, 64, 12288, 4)
|
||||
if uint64(buf) == 0:
|
||||
stdio.printf("SKIP: VirtualAlloc returned NULL\n")
|
||||
return
|
||||
@@ -23,14 +23,14 @@ def test_strcpy():
|
||||
|
||||
def test_strcat():
|
||||
testcheck.section("Test 3: strcat (via memcpy)")
|
||||
buf: char | t.CPtr = w32.win32memory.VirtualAlloc(None, 64, 12288, 4)
|
||||
buf: char* = w32.win32memory.VirtualAlloc(None, 64, 12288, 4)
|
||||
if uint64(buf) == 0:
|
||||
stdio.printf("SKIP: VirtualAlloc returned NULL\n")
|
||||
return
|
||||
string.memset(buf, 0, 64)
|
||||
# 手动拼接: 先拷贝 "Hello",再拷贝 " World"
|
||||
hello: char | t.CPtr = "Hello"
|
||||
world: char | t.CPtr = " World"
|
||||
hello: char* = "Hello"
|
||||
world: char* = " World"
|
||||
string.memcpy(buf, hello, 5)
|
||||
string.memcpy(t.CPtr(uint64(buf) + 5), world, 6)
|
||||
cmp_result: int = string.strcmp(buf, "Hello World")
|
||||
@@ -45,7 +45,7 @@ def test_strcmp():
|
||||
|
||||
def test_strncpy():
|
||||
testcheck.section("Test 5: strncpy")
|
||||
buf: char | t.CPtr = w32.win32memory.VirtualAlloc(None, 64, 12288, 4)
|
||||
buf: char* = w32.win32memory.VirtualAlloc(None, 64, 12288, 4)
|
||||
if uint64(buf) == 0:
|
||||
stdio.printf("SKIP: VirtualAlloc returned NULL\n")
|
||||
return
|
||||
@@ -56,13 +56,13 @@ def test_strncpy():
|
||||
|
||||
def test_char_access():
|
||||
testcheck.section("Test 6: char access")
|
||||
s: char | t.CPtr = "ABCDE"
|
||||
s: char* = "ABCDE"
|
||||
val: uint8 = s[2] # 'C' = 67
|
||||
testcheck.check(val == 67, "char access (s[2]=67='C')", "char access (s[2] expect 67)")
|
||||
|
||||
def test_snprintf():
|
||||
testcheck.section("Test 7: snprintf")
|
||||
buf: char | t.CPtr = w32.win32memory.VirtualAlloc(None, 128, 12288, 4)
|
||||
buf: char* = w32.win32memory.VirtualAlloc(None, 128, 12288, 4)
|
||||
if uint64(buf) == 0:
|
||||
stdio.printf("SKIP: VirtualAlloc returned NULL\n")
|
||||
return
|
||||
|
||||
Reference in new issue
Block a user