test: 全仓同步 w32→win32 模块改名与窄化断言适配
This commit is contained in:
1 parent
384fccd8b8
commit
e5e4163167
30 files changed
+148
-147
No files matched your search
+3
-3
@@ -7,7 +7,7 @@ import stdlib
|
||||
import sys
|
||||
import string
|
||||
import ast
|
||||
import w32.win32console
|
||||
import win32.win32console
|
||||
|
||||
|
||||
# MBuddy arena size: 1MB
|
||||
@@ -94,8 +94,8 @@ def classify_print(node: ast.AST*, depth: int):
|
||||
|
||||
|
||||
def main() -> CInt | CExport:
|
||||
w32.win32console.SetConsoleCP(65001)
|
||||
w32.win32console.SetConsoleOutputCP(65001)
|
||||
win32.win32console.SetConsoleCP(65001)
|
||||
win32.win32console.SetConsoleOutputCP(65001)
|
||||
|
||||
printf("AST Comprehensive Test Start\n")
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from stdint import *
|
||||
import w32.win32console
|
||||
import win32.win32console
|
||||
import t, c
|
||||
from t import CInt, CExport
|
||||
import memhub
|
||||
@@ -7,8 +7,8 @@ import mbuddytest
|
||||
|
||||
|
||||
def main() -> CInt | CExport:
|
||||
w32.win32console.SetConsoleCP(65001)
|
||||
w32.win32console.SetConsoleOutputCP(65001)
|
||||
win32.win32console.SetConsoleCP(65001)
|
||||
win32.win32console.SetConsoleOutputCP(65001)
|
||||
|
||||
# BuddyTest has a negative case that deliberately double-frees. With memhub's
|
||||
# [MEMDBG] checks on (_memdbg_enable=1) the second free aborts, so disable it.
|
||||
|
||||
@@ -6,9 +6,9 @@ import stdlib
|
||||
import memhub
|
||||
import string
|
||||
import testcheck
|
||||
import w32.win32process
|
||||
import w32.win32sync
|
||||
import w32.win32base
|
||||
import win32.win32process
|
||||
import win32.win32sync
|
||||
import win32.win32base
|
||||
|
||||
|
||||
# Thread body: alloc/free on a shared MBuddy to exercise the spinlock
|
||||
@@ -386,14 +386,14 @@ def mbuddy_main() -> CInt:
|
||||
# Spawn 4 threads doing concurrent alloc/free
|
||||
t_idx: CInt
|
||||
for t_idx in range(NUM_THREADS):
|
||||
h: bytes = w32.win32process.CreateThread(None, 0, _thread_alloc_free, t.CPtr(bd_mt), 0, &tid)
|
||||
h: bytes = win32.win32process.CreateThread(None, 0, _thread_alloc_free, t.CPtr(bd_mt), 0, &tid)
|
||||
handles[t_idx] = CUInt64T(h)
|
||||
|
||||
# Wait for all threads to finish
|
||||
for t_idx in range(NUM_THREADS):
|
||||
h: bytes = t.CPtr(handles[t_idx])
|
||||
w32.win32sync.WaitForSingleObject(h, w32.win32base.INFINITE)
|
||||
w32.win32base.CloseHandle(h)
|
||||
win32.win32sync.WaitForSingleObject(h, win32.win32base.INFINITE)
|
||||
win32.win32base.CloseHandle(h)
|
||||
|
||||
# Verify allocator state: self-check passes and all blocks coalesced
|
||||
testcheck.check(bd_mt.self_check() == 0, "mt: self_check OK", "mt: self_check FAILED")
|
||||
|
||||
@@ -3,7 +3,7 @@ from t import CInt, CInt32T, CUInt32T, CUInt64T, CFloat64T, CPtr, CChar, CDefine
|
||||
import viperlib
|
||||
import stdlib
|
||||
import platmacro
|
||||
import w32.win32console
|
||||
import win32.win32console
|
||||
import testcheck
|
||||
|
||||
|
||||
@@ -380,8 +380,8 @@ def test_cifdef_complex() -> CInt:
|
||||
|
||||
|
||||
def main() -> int:
|
||||
w32.win32console.SetConsoleCP(65001)
|
||||
w32.win32console.SetConsoleOutputCP(65001)
|
||||
win32.win32console.SetConsoleCP(65001)
|
||||
win32.win32console.SetConsoleOutputCP(65001)
|
||||
|
||||
testcheck.begin("DefineTest: CDefine 宏与 cif 测试")
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from stdint import *
|
||||
import w32.win32console
|
||||
import win32.win32console
|
||||
import t, c
|
||||
from t import CInt, CExport
|
||||
import stdio
|
||||
@@ -10,8 +10,8 @@ import testcheck
|
||||
|
||||
|
||||
def main() -> CInt | CExport:
|
||||
w32.win32console.SetConsoleCP(65001)
|
||||
w32.win32console.SetConsoleOutputCP(65001)
|
||||
win32.win32console.SetConsoleCP(65001)
|
||||
win32.win32console.SetConsoleOutputCP(65001)
|
||||
|
||||
testcheck.begin("DictTest: 万能 dict (Variant 存储) 测试")
|
||||
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
from stdint import *
|
||||
import w32.win32console
|
||||
import win32.win32console
|
||||
import t, c
|
||||
from t import CInt, CExport
|
||||
import stdio
|
||||
@@ -9,8 +9,8 @@ import testcheck
|
||||
|
||||
|
||||
def main() -> CInt | CExport:
|
||||
w32.win32console.SetConsoleCP(65001)
|
||||
w32.win32console.SetConsoleOutputCP(65001)
|
||||
win32.win32console.SetConsoleCP(65001)
|
||||
win32.win32console.SetConsoleOutputCP(65001)
|
||||
|
||||
testcheck.begin("== 重载和 is 地址比较测试")
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from stdint import *
|
||||
import w32.win32console
|
||||
import win32.win32console
|
||||
import t, c
|
||||
from t import CInt, CExport
|
||||
import _fakeduck
|
||||
@@ -12,8 +12,8 @@ import _withcontent
|
||||
|
||||
|
||||
def main() -> CInt | CExport:
|
||||
w32.win32console.SetConsoleCP(65001)
|
||||
w32.win32console.SetConsoleOutputCP(65001)
|
||||
win32.win32console.SetConsoleCP(65001)
|
||||
win32.win32console.SetConsoleOutputCP(65001)
|
||||
|
||||
# FakeDuck: str calls extension method b()
|
||||
a: str = "Hello"
|
||||
|
||||
@@ -3,11 +3,11 @@ from t import CInt, CInt32T, CUInt32T, CPtr, CChar, CExport
|
||||
from stdint import *
|
||||
import stdlib
|
||||
import viperlib
|
||||
import w32.win32base
|
||||
import w32.win32file
|
||||
import w32.win32console
|
||||
import w32.fileio
|
||||
from w32.fileio import File, FileW, MODE, FRESULT, SEEK_SET, SEEK_CUR, SEEK_END
|
||||
import win32.win32base
|
||||
import win32.win32file
|
||||
import win32.win32console
|
||||
import win32.fileio
|
||||
from win32.fileio import File, FileW, MODE, FRESULT, SEEK_SET, SEEK_CUR, SEEK_END
|
||||
|
||||
|
||||
define BUF_SIZE = 4096
|
||||
@@ -20,20 +20,20 @@ def fileio_main():
|
||||
bytes_written: ULONG = 0
|
||||
bytes_read: ULONG = 0
|
||||
|
||||
w32.win32console.SetConsoleCP(65001)
|
||||
w32.win32console.SetConsoleOutputCP(65001)
|
||||
win32.win32console.SetConsoleCP(65001)
|
||||
win32.win32console.SetConsoleOutputCP(65001)
|
||||
|
||||
hFile: w32.win32base.HANDLE = w32.win32file.CreateFileA(
|
||||
hFile: win32.win32base.HANDLE = win32.win32file.CreateFileA(
|
||||
"testfile.txt",
|
||||
w32.win32file.GENERIC_WRITE,
|
||||
w32.win32file.FILE_SHARE_READ,
|
||||
win32.win32file.GENERIC_WRITE,
|
||||
win32.win32file.FILE_SHARE_READ,
|
||||
None,
|
||||
w32.win32file.CREATE_ALWAYS,
|
||||
w32.win32file.FILE_ATTRIBUTE_NORMAL,
|
||||
win32.win32file.CREATE_ALWAYS,
|
||||
win32.win32file.FILE_ATTRIBUTE_NORMAL,
|
||||
None
|
||||
)
|
||||
|
||||
if hFile == w32.win32base.INVALID_HANDLE_VALUE:
|
||||
if hFile == win32.win32base.INVALID_HANDLE_VALUE:
|
||||
print("Failed to create file")
|
||||
return
|
||||
|
||||
@@ -48,32 +48,32 @@ def fileio_main():
|
||||
i = i + 1
|
||||
ch = ch + 1
|
||||
|
||||
result: BOOL = w32.win32file.WriteFile(hFile, write_buf, write_len, &bytes_written, None)
|
||||
result: BOOL = win32.win32file.WriteFile(hFile, write_buf, write_len, &bytes_written, None)
|
||||
if result == 0:
|
||||
print("WriteFile failed")
|
||||
else:
|
||||
viperlib.snprintf(buf, 256, "Written %d bytes to testfile.txt", bytes_written)
|
||||
print(buf)
|
||||
|
||||
w32.win32file.FlushFileBuffers(hFile)
|
||||
w32.win32base.CloseHandle(hFile)
|
||||
win32.win32file.FlushFileBuffers(hFile)
|
||||
win32.win32base.CloseHandle(hFile)
|
||||
|
||||
hFile = w32.win32file.CreateFileA(
|
||||
hFile = win32.win32file.CreateFileA(
|
||||
"testfile.txt",
|
||||
w32.win32file.GENERIC_READ,
|
||||
w32.win32file.FILE_SHARE_READ,
|
||||
win32.win32file.GENERIC_READ,
|
||||
win32.win32file.FILE_SHARE_READ,
|
||||
None,
|
||||
w32.win32file.OPEN_EXISTING,
|
||||
w32.win32file.FILE_ATTRIBUTE_NORMAL,
|
||||
win32.win32file.OPEN_EXISTING,
|
||||
win32.win32file.FILE_ATTRIBUTE_NORMAL,
|
||||
None
|
||||
)
|
||||
|
||||
if hFile == w32.win32base.INVALID_HANDLE_VALUE:
|
||||
if hFile == win32.win32base.INVALID_HANDLE_VALUE:
|
||||
print("Failed to open file for reading")
|
||||
return
|
||||
|
||||
read_len: ULONG = 0
|
||||
result = w32.win32file.ReadFile(hFile, read_buf, BUF_SIZE - 1, &read_len, None)
|
||||
result = win32.win32file.ReadFile(hFile, read_buf, BUF_SIZE - 1, &read_len, None)
|
||||
if result == 0:
|
||||
print("ReadFile failed")
|
||||
else:
|
||||
@@ -87,20 +87,20 @@ def fileio_main():
|
||||
print(read_buf)
|
||||
print("--- End ---")
|
||||
|
||||
fileSize: ULONG = w32.win32file.GetFileSize(hFile, None)
|
||||
fileSize: ULONG = win32.win32file.GetFileSize(hFile, None)
|
||||
viperlib.snprintf(buf, 256, "File size: %d bytes", fileSize)
|
||||
print(buf)
|
||||
|
||||
w32.win32base.CloseHandle(hFile)
|
||||
win32.win32base.CloseHandle(hFile)
|
||||
|
||||
attrs: ULONG = w32.win32file.GetFileAttributesA("testfile.txt")
|
||||
if attrs == w32.win32base.INVALID_HANDLE_VALUE:
|
||||
attrs: ULONG = win32.win32file.GetFileAttributesA("testfile.txt")
|
||||
if attrs == win32.win32base.INVALID_HANDLE_VALUE:
|
||||
print("GetFileAttributes failed")
|
||||
else:
|
||||
viperlib.snprintf(buf, 256, "File attributes: 0x%X", attrs)
|
||||
print(buf)
|
||||
|
||||
w32.win32file.DeleteFileA("testfile.txt")
|
||||
win32.win32file.DeleteFileA("testfile.txt")
|
||||
print("File deleted")
|
||||
|
||||
stdlib.free(write_buf)
|
||||
@@ -168,7 +168,7 @@ def fileio_with_test():
|
||||
viperlib.snprintf(buf, 256, "[with] After seek: Pos=%d", pos)
|
||||
print(buf)
|
||||
|
||||
w32.win32file.DeleteFileA("oop_with.txt")
|
||||
win32.win32file.DeleteFileA("oop_with.txt")
|
||||
print("[with] test file deleted")
|
||||
|
||||
stdlib.free(buf)
|
||||
@@ -229,7 +229,7 @@ def fileio_handle_test():
|
||||
print(buf)
|
||||
fr4.close()
|
||||
|
||||
w32.win32file.DeleteFileA("oop_handle.txt")
|
||||
win32.win32file.DeleteFileA("oop_handle.txt")
|
||||
print("[handle] test file deleted")
|
||||
|
||||
stdlib.free(buf)
|
||||
@@ -273,7 +273,7 @@ def fileio_rw_test():
|
||||
print(buf)
|
||||
fap.close()
|
||||
|
||||
w32.win32file.DeleteFileA("rw_test.txt")
|
||||
win32.win32file.DeleteFileA("rw_test.txt")
|
||||
print("[rw] test file deleted")
|
||||
|
||||
print("=== OOP FileIO: wide char (u\"...\") ===")
|
||||
@@ -295,7 +295,7 @@ def fileio_wide_test():
|
||||
print(buf)
|
||||
fw2.close()
|
||||
|
||||
w32.win32file.DeleteFileA("wide_test.txt")
|
||||
win32.win32file.DeleteFileA("wide_test.txt")
|
||||
print("[wide] test file deleted")
|
||||
|
||||
stdlib.free(buf)
|
||||
@@ -325,7 +325,7 @@ def fileio_chinese_test():
|
||||
print(buf)
|
||||
fr.close()
|
||||
|
||||
w32.win32file.DeleteFileW(u"中文文件.txt")
|
||||
win32.win32file.DeleteFileW(u"中文文件.txt")
|
||||
print("[chinese] T1: deleted")
|
||||
|
||||
# === T2: Chinese filename + Chinese wide content (WCHAR_T) ===
|
||||
@@ -335,7 +335,7 @@ def fileio_chinese_test():
|
||||
print("[chinese] T2: create failed")
|
||||
else:
|
||||
# u"你好世界\n" = 5 WCHARs = 10 bytes (UTF-16LE)
|
||||
w32.win32file.WriteFile(fw2.handle, u"你好世界\n", 10, &bytes_written, None)
|
||||
win32.win32file.WriteFile(fw2.handle, u"你好世界\n", 10, &bytes_written, None)
|
||||
viperlib.snprintf(buf, 256, "[chinese] T2: wrote %d WCHAR bytes", bytes_written)
|
||||
print(buf)
|
||||
fw2.close()
|
||||
@@ -346,7 +346,7 @@ def fileio_chinese_test():
|
||||
print(buf)
|
||||
fr2.close()
|
||||
|
||||
w32.win32file.DeleteFileW(u"中文内容.txt")
|
||||
win32.win32file.DeleteFileW(u"中文内容.txt")
|
||||
print("[chinese] T2: deleted")
|
||||
|
||||
# === T3: Chinese filename + mixed ANSI + wide content ===
|
||||
@@ -357,14 +357,14 @@ def fileio_chinese_test():
|
||||
else:
|
||||
fw3.write_str("ASCII line\n")
|
||||
# u"中文行\n" = 4 WCHARs = 8 bytes (UTF-16LE)
|
||||
w32.win32file.WriteFile(fw3.handle, u"中文行\n", 8, &bytes_written, None)
|
||||
win32.win32file.WriteFile(fw3.handle, u"中文行\n", 8, &bytes_written, None)
|
||||
fw3.seek(0, SEEK_SET)
|
||||
n: LONG = fw3.read_all(buf, 512)
|
||||
viperlib.snprintf(buf, 256, "[chinese] T3: total %d bytes", n)
|
||||
print(buf)
|
||||
fw3.close()
|
||||
|
||||
w32.win32file.DeleteFileW(u"混合测试.txt")
|
||||
win32.win32file.DeleteFileW(u"混合测试.txt")
|
||||
print("[chinese] T3: deleted")
|
||||
|
||||
# === T4: Chinese filename + Chinese content via WriteConsoleW ===
|
||||
@@ -374,7 +374,7 @@ def fileio_chinese_test():
|
||||
print("[chinese] T4: create failed")
|
||||
else:
|
||||
# u"你好,世界!\n" = 7 WCHARs = 14 bytes (UTF-16LE)
|
||||
w32.win32file.WriteFile(fw4.handle, u"你好,世界!\n", 14, &bytes_written, None)
|
||||
win32.win32file.WriteFile(fw4.handle, u"你好,世界!\n", 14, &bytes_written, None)
|
||||
viperlib.snprintf(buf, 256, "[chinese] T4: wrote %d WCHAR bytes", bytes_written)
|
||||
print(buf)
|
||||
fw4.close()
|
||||
@@ -385,11 +385,11 @@ def fileio_chinese_test():
|
||||
print(buf)
|
||||
# Print wide content to console using WriteConsoleW
|
||||
chars_written: ULONG = 0
|
||||
hOut: w32.win32base.HANDLE = w32.win32file.GetStdHandle(w32.win32file.STD_OUTPUT_HANDLE)
|
||||
w32.win32console.WriteConsoleW(hOut, u"你好,世界!\n", 7, &chars_written, None)
|
||||
hOut: win32.win32base.HANDLE = win32.win32file.GetStdHandle(win32.win32file.STD_OUTPUT_HANDLE)
|
||||
win32.win32console.WriteConsoleW(hOut, u"你好,世界!\n", 7, &chars_written, None)
|
||||
fr4.close()
|
||||
|
||||
w32.win32file.DeleteFileW(u"控制台测试.txt")
|
||||
win32.win32file.DeleteFileW(u"控制台测试.txt")
|
||||
print("[chinese] T4: deleted")
|
||||
|
||||
stdlib.free(buf)
|
||||
+2
-2
@@ -31,10 +31,10 @@ def caller1_sum_chain(head: G4Node*) -> int:
|
||||
"""Sum the chain by walking Next directly."""
|
||||
if head is None:
|
||||
return 0
|
||||
total: int = head.IntVal
|
||||
total: int = int(head.IntVal)
|
||||
cur: G4Node* = head
|
||||
# Access Next directly (bypass g4node_get_next).
|
||||
while cur.Next is not None:
|
||||
cur = cur.Next
|
||||
total = total + cur.IntVal
|
||||
total = total + int(cur.IntVal)
|
||||
return total
|
||||
+5
-5
@@ -27,7 +27,7 @@ def test_g4node_create():
|
||||
testcheck.check(False, "new_g4node", "FAIL")
|
||||
return
|
||||
n.IntVal = 42
|
||||
v: int = n.IntVal
|
||||
v: int = int(n.IntVal)
|
||||
testcheck.check(v == 42, "G4Node.IntVal = 42", "expect 42")
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ def test_g4node_next_field():
|
||||
if next_node is None:
|
||||
testcheck.check(False, "g4node_get_next", "FAIL")
|
||||
return
|
||||
v: int = next_node.IntVal
|
||||
v: int = int(next_node.IntVal)
|
||||
testcheck.check(v == 20, "n1.Next.IntVal = 20", "expect 20")
|
||||
|
||||
|
||||
@@ -72,11 +72,11 @@ def test_g4node_chain():
|
||||
c.IntVal = 3
|
||||
g4node_set_next(a, b)
|
||||
g4node_set_next(b, c)
|
||||
sum: int = a.IntVal
|
||||
sum: int = int(a.IntVal)
|
||||
p: G4Node* = g4node_get_next(a)
|
||||
sum = sum + p.IntVal
|
||||
sum = sum + int(p.IntVal)
|
||||
p = g4node_get_next(p)
|
||||
sum = sum + p.IntVal
|
||||
sum = sum + int(p.IntVal)
|
||||
testcheck.check(sum == 6, "chain sum = 1+2+3 = 6", "expect 6")
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ def test_value_struct_fields():
|
||||
node.IntVal = 42
|
||||
node.FloatVal = 3.14
|
||||
# Read back and verify
|
||||
v: int = node.IntVal
|
||||
v: int = int(node.IntVal)
|
||||
testcheck.check(v == 42, "Value.IntVal = 42", "expect 42")
|
||||
f: double = node.FloatVal
|
||||
testcheck.check(f > 3.0 and f < 4.0, "Value.FloatVal = 3.14", "expect ~3.14")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from stdint import *
|
||||
import w32.win32console
|
||||
import win32.win32console
|
||||
import t, c
|
||||
from t import CInt, CPtr, CChar, CInt32T, CUInt64T, CFloat64T, CExport, State
|
||||
import viperlib
|
||||
@@ -70,8 +70,8 @@ class Container[T]():
|
||||
|
||||
|
||||
def main() -> CInt | CExport:
|
||||
w32.win32console.SetConsoleCP(65001)
|
||||
w32.win32console.SetConsoleOutputCP(65001)
|
||||
win32.win32console.SetConsoleCP(65001)
|
||||
win32.win32console.SetConsoleOutputCP(65001)
|
||||
|
||||
testcheck.begin("GenericOopTest: 泛型专项测试")
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import testcheck
|
||||
import hashlib
|
||||
import binascii
|
||||
import base64
|
||||
import w32.win32console
|
||||
import win32.win32console
|
||||
|
||||
|
||||
# ==============================================
|
||||
@@ -23,8 +23,8 @@ def default_value_test_function(a: int, b: int = 1):
|
||||
|
||||
|
||||
def main() -> int | t.CExport:
|
||||
w32.win32console.SetConsoleCP(65001)
|
||||
w32.win32console.SetConsoleOutputCP(65001)
|
||||
win32.win32console.SetConsoleCP(65001)
|
||||
win32.win32console.SetConsoleOutputCP(65001)
|
||||
|
||||
testcheck.begin("HashLibTest: 哈希与校验测试")
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from stdint import *
|
||||
import w32.win32console
|
||||
import win32.win32console
|
||||
import t, c
|
||||
from t import CInt, CExport
|
||||
import stdio
|
||||
@@ -11,8 +11,8 @@ import testcheck
|
||||
|
||||
|
||||
def main() -> CInt | CExport:
|
||||
w32.win32console.SetConsoleCP(65001)
|
||||
w32.win32console.SetConsoleOutputCP(65001)
|
||||
win32.win32console.SetConsoleCP(65001)
|
||||
win32.win32console.SetConsoleOutputCP(65001)
|
||||
|
||||
testcheck.begin("HashTableTest: 开放寻址哈希表测试")
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ def test_strcpy_for_in():
|
||||
testcheck.section("Test 3: strcpy using for-in")
|
||||
src: char* = "test"
|
||||
# Implement strcpy by hand with for-in.
|
||||
import w32.win32memory
|
||||
buf: char* = w32.win32memory.VirtualAlloc(None, 64, 12288, 4)
|
||||
import win32.win32memory
|
||||
buf: char* = win32.win32memory.VirtualAlloc(None, 64, 12288, 4)
|
||||
if uint64(buf) == 0:
|
||||
stdio.printf("SKIP: VirtualAlloc returned NULL\n")
|
||||
return
|
||||
@@ -42,7 +42,7 @@ def test_strcpy_for_in():
|
||||
# '==' on pointers compares addresses (C-like); use strcmp for contents.
|
||||
testcheck.check(string.strcmp(buf, "test") == 0, "strcpy for-in (result=test)", "strcpy for-in (cmp mismatch)")
|
||||
|
||||
import w32.win32memory
|
||||
import win32.win32memory
|
||||
|
||||
def main() -> int:
|
||||
testcheck.begin("IterTest: 指针迭代测试")
|
||||
|
||||
@@ -4,7 +4,7 @@ from stdio import printf
|
||||
import memhub
|
||||
import json
|
||||
import string
|
||||
import w32.win32memory as win32mem
|
||||
import win32.win32memory as win32mem
|
||||
import testcheck
|
||||
|
||||
# --- Test 1: construct JSON values (with mpool) ---
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from stdint import *
|
||||
import w32.win32console
|
||||
import win32.win32console
|
||||
import t, c
|
||||
from t import CInt, CExport
|
||||
import stdlib
|
||||
@@ -9,8 +9,8 @@ import testcheck
|
||||
|
||||
|
||||
def main() -> CInt | CExport:
|
||||
w32.win32console.SetConsoleCP(65001)
|
||||
w32.win32console.SetConsoleOutputCP(65001)
|
||||
win32.win32console.SetConsoleCP(65001)
|
||||
win32.win32console.SetConsoleOutputCP(65001)
|
||||
|
||||
testcheck.begin("ListTest: list[T] 堆容器测试")
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from stdint import *
|
||||
import w32.win32console
|
||||
import win32.win32console
|
||||
import t, c
|
||||
from t import CInt, CPtr, CChar, CInt32T, CFloat64T, CExport, State
|
||||
import viperlib
|
||||
@@ -138,8 +138,8 @@ class Vec2Both(Vec2M, Vec2Extra):
|
||||
|
||||
|
||||
def main() -> CInt | CExport:
|
||||
w32.win32console.SetConsoleCP(65001)
|
||||
w32.win32console.SetConsoleOutputCP(65001)
|
||||
win32.win32console.SetConsoleCP(65001)
|
||||
win32.win32console.SetConsoleOutputCP(65001)
|
||||
|
||||
testcheck.begin("MultiInheritTest: 多继承专项测试")
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ from stdlib import calloc, free
|
||||
import string
|
||||
import math
|
||||
import memhub
|
||||
import w32.win32base
|
||||
import win32.win32base
|
||||
import t, c
|
||||
|
||||
# ============================================================
|
||||
@@ -71,7 +71,7 @@ def section_footer():
|
||||
# Timer: monotonic clock (GetTickCount64 ms -> s) via Win32 API.
|
||||
# ============================================================
|
||||
def timer_sec() -> double:
|
||||
return double(w32.win32base.GetTickCount64()) / double(1000.0)
|
||||
return double(win32.win32base.GetTickCount64()) / double(1000.0)
|
||||
|
||||
|
||||
# ============================================================
|
||||
@@ -988,7 +988,7 @@ def test_numpy_correct() -> int:
|
||||
global arena, pool, test_passed, test_failed
|
||||
|
||||
arena = calloc(2 * 1024 * 1024, 1)
|
||||
pool = memhub.MemPool(arena, 2 * 1024 * 1024)
|
||||
pool = new memhub.MemPool(arena, 2 * 1024 * 1024)
|
||||
|
||||
test_passed = 0
|
||||
test_failed = 0
|
||||
@@ -1038,7 +1038,7 @@ def test_numpy_edge_main() -> int:
|
||||
global arena, pool, test_passed, test_failed
|
||||
|
||||
arena = calloc(2 * 1024 * 1024, 1)
|
||||
pool = memhub.MemPool(arena, 2 * 1024 * 1024)
|
||||
pool = new memhub.MemPool(arena, 2 * 1024 * 1024)
|
||||
|
||||
test_passed = 0
|
||||
test_failed = 0
|
||||
@@ -1060,7 +1060,7 @@ def bench_numpy_main() -> int:
|
||||
global arena, pool
|
||||
|
||||
arena = calloc(8 * 1024 * 1024, 1)
|
||||
pool = memhub.MemPool(arena, 8 * 1024 * 1024)
|
||||
pool = new memhub.MemPool(arena, 8 * 1024 * 1024)
|
||||
|
||||
printf("==============================================\n")
|
||||
printf(" numpy Performance Benchmark\n")
|
||||
@@ -1077,7 +1077,7 @@ def test_numpy_main() -> int:
|
||||
global arena, pool
|
||||
|
||||
arena = calloc(2 * 1024 * 1024, 1)
|
||||
pool = memhub.MemPool(arena, 2 * 1024 * 1024)
|
||||
pool = new memhub.MemPool(arena, 2 * 1024 * 1024)
|
||||
|
||||
failed: int = test_numpy_correct()
|
||||
if failed == 0:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from stdint import *
|
||||
import w32.win32console
|
||||
import win32.win32console
|
||||
import t, c
|
||||
from t import CInt, CPtr, CChar, CInt32T, CUInt64T, CFloat64T, CExport, State
|
||||
import viperlib
|
||||
@@ -257,8 +257,8 @@ class ElectricCar(Car):
|
||||
|
||||
|
||||
def main() -> CInt | CExport:
|
||||
w32.win32console.SetConsoleCP(65001)
|
||||
w32.win32console.SetConsoleOutputCP(65001)
|
||||
win32.win32console.SetConsoleCP(65001)
|
||||
win32.win32console.SetConsoleOutputCP(65001)
|
||||
|
||||
testcheck.begin("OopInheritTest: OOP 继承与多态专项测试")
|
||||
|
||||
|
||||
+12
-12
@@ -2,8 +2,8 @@ from stdint import *
|
||||
import t, c
|
||||
import stdio
|
||||
import string
|
||||
import w32.win32console
|
||||
import w32.win32memory
|
||||
import win32.win32console
|
||||
import win32.win32memory
|
||||
import testcheck
|
||||
|
||||
# PointerTest: pointer operations, global declarations, array decay, pointer arithmetic
|
||||
@@ -26,7 +26,7 @@ def test_global_write_no_decl():
|
||||
|
||||
def test_global_ptr():
|
||||
global _g_ptr
|
||||
buf: uint32* = w32.win32memory.VirtualAlloc(None, 256, 0x3000, 0x04)
|
||||
buf: uint32* = win32.win32memory.VirtualAlloc(None, 256, 0x3000, 0x04)
|
||||
if buf:
|
||||
string.memset(buf, 0, 256)
|
||||
_g_ptr = buf
|
||||
@@ -45,7 +45,7 @@ def test_global_ptr_no_decl():
|
||||
# --- Test 2: pointer arithmetic and array indexing ---
|
||||
def test_pointer_arithmetic():
|
||||
"""Verify pointer arithmetic computes offsets correctly."""
|
||||
buf: uint32* = w32.win32memory.VirtualAlloc(None, 256, 0x3000, 0x04)
|
||||
buf: uint32* = win32.win32memory.VirtualAlloc(None, 256, 0x3000, 0x04)
|
||||
if not buf:
|
||||
testcheck.fail("pointer arithmetic: VirtualAlloc returned NULL")
|
||||
return
|
||||
@@ -85,7 +85,7 @@ def test_array_decay():
|
||||
# --- Test 4: pointer type casts (CVoid/CPtr) ---
|
||||
def test_pointer_cast():
|
||||
"""Cast between pointers and integers."""
|
||||
buf: uint32* = w32.win32memory.VirtualAlloc(None, 256, 0x3000, 0x04)
|
||||
buf: uint32* = win32.win32memory.VirtualAlloc(None, 256, 0x3000, 0x04)
|
||||
if not buf:
|
||||
testcheck.fail("pointer cast: VirtualAlloc returned NULL")
|
||||
return
|
||||
@@ -108,7 +108,7 @@ def test_pointer_cast():
|
||||
# --- Test 5: pointer offset (byte offset vs element offset) ---
|
||||
def test_pointer_offset():
|
||||
"""CUInt8T* + N advances N bytes; CUInt32T* + N advances N*4 bytes."""
|
||||
buf: uint8* = w32.win32memory.VirtualAlloc(None, 256, 0x3000, 0x04)
|
||||
buf: uint8* = win32.win32memory.VirtualAlloc(None, 256, 0x3000, 0x04)
|
||||
if not buf:
|
||||
testcheck.fail("pointer offset: VirtualAlloc returned NULL")
|
||||
return
|
||||
@@ -153,8 +153,8 @@ def test_struct_pointer():
|
||||
# --- Test 7: memcpy/memset through pointers ---
|
||||
def test_memcpy_pointers():
|
||||
"""Copy data between pointers with memcpy."""
|
||||
src_buf: uint32* = w32.win32memory.VirtualAlloc(None, 64, 0x3000, 0x04)
|
||||
dst_buf: uint32* = w32.win32memory.VirtualAlloc(None, 64, 0x3000, 0x04)
|
||||
src_buf: uint32* = win32.win32memory.VirtualAlloc(None, 64, 0x3000, 0x04)
|
||||
dst_buf: uint32* = win32.win32memory.VirtualAlloc(None, 64, 0x3000, 0x04)
|
||||
if not src_buf or not dst_buf:
|
||||
testcheck.fail("memcpy: VirtualAlloc returned NULL")
|
||||
return
|
||||
@@ -182,7 +182,7 @@ def fill_array(arr: uint32*, count: int, val: uint32):
|
||||
|
||||
def test_pointer_param():
|
||||
"""Pass a pointer as a function parameter."""
|
||||
buf: uint32* = w32.win32memory.VirtualAlloc(None, 64, 0x3000, 0x04)
|
||||
buf: uint32* = win32.win32memory.VirtualAlloc(None, 64, 0x3000, 0x04)
|
||||
if not buf:
|
||||
testcheck.fail("pointer param: VirtualAlloc returned NULL")
|
||||
return
|
||||
@@ -197,11 +197,11 @@ def test_pointer_param():
|
||||
|
||||
|
||||
def main() -> int | t.CExport:
|
||||
w32.win32console.SetConsoleCP(65001)
|
||||
w32.win32console.SetConsoleOutputCP(65001)
|
||||
win32.win32console.SetConsoleCP(65001)
|
||||
win32.win32console.SetConsoleOutputCP(65001)
|
||||
|
||||
print("你好")
|
||||
l: t.CArray[char, 2] = 0
|
||||
l: t.CArray[char, 2] = None
|
||||
for i in "hello":
|
||||
l[0] = i
|
||||
print(l)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from stdint import *
|
||||
import w32.win32console
|
||||
import win32.win32console
|
||||
import t, c
|
||||
from t import CInt, CExport
|
||||
import stdio
|
||||
@@ -21,8 +21,8 @@ def bump_false(buf: bytes) -> bool:
|
||||
|
||||
|
||||
def main() -> CInt | CExport:
|
||||
w32.win32console.SetConsoleCP(65001)
|
||||
w32.win32console.SetConsoleOutputCP(65001)
|
||||
win32.win32console.SetConsoleCP(65001)
|
||||
win32.win32console.SetConsoleOutputCP(65001)
|
||||
|
||||
testcheck.begin("if 短路机制测试")
|
||||
|
||||
|
||||
@@ -8,12 +8,15 @@ import ast
|
||||
# VoidType alloca; ast.expr (invalid) errors, ast.AST (valid) compiles.
|
||||
# ============================================================
|
||||
class Result:
|
||||
elem_type_node: ast.AST
|
||||
count_node: ast.AST*
|
||||
is_pointer: bool
|
||||
__slots__ = ('elem_type_node', 'count_node', 'is_pointer')
|
||||
|
||||
def __init__(self, elem: ast.AST, count: ast.AST*, flag: bool) -> None:
|
||||
self.elem_type_node: ast.AST = elem
|
||||
self.count_node: ast.AST* = count
|
||||
self.is_pointer: bool = flag
|
||||
self.elem_type_node = elem
|
||||
self.count_node = count
|
||||
self.is_pointer = flag
|
||||
|
||||
def main() -> int:
|
||||
return 0
|
||||
@@ -2,7 +2,7 @@ import t
|
||||
import stdio
|
||||
import string
|
||||
import testcheck
|
||||
import w32.win32memory
|
||||
import win32.win32memory
|
||||
|
||||
def test_strlen():
|
||||
testcheck.section("Test 1: strlen")
|
||||
@@ -12,7 +12,7 @@ def test_strlen():
|
||||
|
||||
def test_strcpy():
|
||||
testcheck.section("Test 2: strcpy")
|
||||
buf: char* = w32.win32memory.VirtualAlloc(None, 64, 12288, 4)
|
||||
buf: char* = win32.win32memory.VirtualAlloc(None, 64, 12288, 4)
|
||||
if uint64(buf) == 0:
|
||||
stdio.printf("SKIP: VirtualAlloc returned NULL\n")
|
||||
return
|
||||
@@ -23,7 +23,7 @@ def test_strcpy():
|
||||
|
||||
def test_strcat():
|
||||
testcheck.section("Test 3: strcat (via memcpy)")
|
||||
buf: char* = w32.win32memory.VirtualAlloc(None, 64, 12288, 4)
|
||||
buf: char* = win32.win32memory.VirtualAlloc(None, 64, 12288, 4)
|
||||
if uint64(buf) == 0:
|
||||
stdio.printf("SKIP: VirtualAlloc returned NULL\n")
|
||||
return
|
||||
@@ -45,7 +45,7 @@ def test_strcmp():
|
||||
|
||||
def test_strncpy():
|
||||
testcheck.section("Test 5: strncpy")
|
||||
buf: char* = w32.win32memory.VirtualAlloc(None, 64, 12288, 4)
|
||||
buf: char* = win32.win32memory.VirtualAlloc(None, 64, 12288, 4)
|
||||
if uint64(buf) == 0:
|
||||
stdio.printf("SKIP: VirtualAlloc returned NULL\n")
|
||||
return
|
||||
@@ -62,7 +62,7 @@ def test_char_access():
|
||||
|
||||
def test_snprintf():
|
||||
testcheck.section("Test 7: snprintf")
|
||||
buf: char* = w32.win32memory.VirtualAlloc(None, 128, 12288, 4)
|
||||
buf: char* = win32.win32memory.VirtualAlloc(None, 128, 12288, 4)
|
||||
if uint64(buf) == 0:
|
||||
stdio.printf("SKIP: VirtualAlloc returned NULL\n")
|
||||
return
|
||||
@@ -71,8 +71,6 @@ def test_snprintf():
|
||||
cmp_result: int = string.strcmp(buf, "value=42 hex=0xff str=test")
|
||||
testcheck.check(cmp_result == 0, "snprintf (result=value=42 hex=0xff str=test)", "snprintf (result mismatch)")
|
||||
|
||||
import w32.win32memory
|
||||
|
||||
def main() -> int:
|
||||
testcheck.begin("StringTest: 字符串操作基准测试")
|
||||
test_strlen()
|
||||
|
||||
@@ -2,6 +2,7 @@ import t
|
||||
import stdio
|
||||
import string
|
||||
import testcheck
|
||||
import win32.win32memory
|
||||
|
||||
# Define structs
|
||||
class Point():
|
||||
@@ -59,7 +60,7 @@ def point_sum(p: Point) -> int:
|
||||
def test_struct_array():
|
||||
testcheck.section("Test 5: struct array")
|
||||
# Allocate a struct array
|
||||
buf: uint8* = w32.win32memory.VirtualAlloc(None, 256, 12288, 4)
|
||||
buf: uint8* = win32.win32memory.VirtualAlloc(None, 256, 12288, 4)
|
||||
if uint64(buf) == 0:
|
||||
stdio.printf("SKIP: VirtualAlloc returned NULL\n")
|
||||
return
|
||||
@@ -73,7 +74,6 @@ def test_struct_array():
|
||||
total: int = pts[0].x + pts[0].y + pts[1].x + pts[1].y
|
||||
testcheck.check(total == 10, "struct array (total=10)", "struct array (total expect 10)")
|
||||
|
||||
import w32.win32memory
|
||||
|
||||
def main() -> int:
|
||||
testcheck.begin("StructTest: 结构体操作基准测试")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from stdint import *
|
||||
import w32.win32console
|
||||
import win32.win32console
|
||||
import t, c
|
||||
from t import CInt, CExport
|
||||
import memhub
|
||||
@@ -19,8 +19,8 @@ define ARENA_SIZE = 1048576
|
||||
|
||||
|
||||
def main() -> CInt | CExport:
|
||||
w32.win32console.SetConsoleCP(65001)
|
||||
w32.win32console.SetConsoleOutputCP(65001)
|
||||
win32.win32console.SetConsoleCP(65001)
|
||||
win32.win32console.SetConsoleOutputCP(65001)
|
||||
|
||||
# Initialize the global MBuddy allocator.
|
||||
arena: bytes = stdlib.malloc(ARENA_SIZE)
|
||||
|
||||
@@ -13,9 +13,9 @@ import shutil
|
||||
import sys
|
||||
import subprocess
|
||||
import string
|
||||
import w32.fileio
|
||||
import w32.win32base
|
||||
import w32.win32process
|
||||
import win32.fileio
|
||||
import win32.win32base
|
||||
import win32.win32process
|
||||
|
||||
|
||||
# Temp file/dir name prefixes used by tests
|
||||
@@ -174,7 +174,7 @@ def run() -> CInt:
|
||||
testcheck.section("shutil 高级文件操作")
|
||||
|
||||
# Create test file
|
||||
f: w32.fileio.File | CPtr = w32.fileio.File(TEST_FILE, w32.fileio.MODE.W)
|
||||
f: win32.fileio.File | CPtr = win32.fileio.File(TEST_FILE, win32.fileio.MODE.W)
|
||||
testcheck.check(not f.closed, "create test file OK", "create test file FAILED")
|
||||
f.write_str("hello shutil")
|
||||
f.close()
|
||||
@@ -203,7 +203,7 @@ def run() -> CInt:
|
||||
testcheck.check(os.mkdir(subdir) == 0, "mkdir subdir OK", "mkdir subdir FAILED")
|
||||
# Create a file inside the subdir
|
||||
subfile: str = os.path.join(subdir, "leaf.txt")
|
||||
sf: w32.fileio.File | CPtr = w32.fileio.File(subfile, w32.fileio.MODE.W)
|
||||
sf: win32.fileio.File | CPtr = win32.fileio.File(subfile, win32.fileio.MODE.W)
|
||||
sf.write_str("leaf")
|
||||
sf.close()
|
||||
testcheck.check(os_backend.os_exists(subfile), "create subfile OK", "create subfile FAILED")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from stdint import *
|
||||
import w32.win32console
|
||||
import win32.win32console
|
||||
import t, c
|
||||
import testcheck
|
||||
|
||||
@@ -35,8 +35,8 @@ def raise_timeout():
|
||||
|
||||
|
||||
def main() -> int | t.CExport:
|
||||
w32.win32console.SetConsoleCP(65001)
|
||||
w32.win32console.SetConsoleOutputCP(65001)
|
||||
win32.win32console.SetConsoleCP(65001)
|
||||
win32.win32console.SetConsoleOutputCP(65001)
|
||||
|
||||
testcheck.begin("TestFBProject: 异常处理与LLVMIR测试")
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ from stdint import *
|
||||
import t, c
|
||||
import stdio
|
||||
import string
|
||||
import w32.win32console
|
||||
import w32.win32memory
|
||||
import win32.win32console
|
||||
import win32.win32memory
|
||||
import testcheck
|
||||
|
||||
# TypeCastTest: type casts, zext/sext/trunc behavior,
|
||||
@@ -116,7 +116,7 @@ def test_comparison_types():
|
||||
|
||||
# --- Test 12: pointer/integer casts ---
|
||||
def test_ptr_int_cast():
|
||||
buf: uint32* = w32.win32memory.VirtualAlloc(None, 64, 0x3000, 0x04)
|
||||
buf: uint32* = win32.win32memory.VirtualAlloc(None, 64, 0x3000, 0x04)
|
||||
if not buf:
|
||||
testcheck.fail("VirtualAlloc returned NULL")
|
||||
return
|
||||
@@ -159,8 +159,8 @@ def test_ternary():
|
||||
|
||||
|
||||
def main() -> int | t.CExport:
|
||||
w32.win32console.SetConsoleCP(65001)
|
||||
w32.win32console.SetConsoleOutputCP(65001)
|
||||
win32.win32console.SetConsoleCP(65001)
|
||||
win32.win32console.SetConsoleOutputCP(65001)
|
||||
|
||||
testcheck.begin("TypeCastTest: 类型转换与运算基准测试")
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import stdio
|
||||
import testcheck
|
||||
import string
|
||||
import viperlib
|
||||
import w32.win32console
|
||||
import win32.win32console
|
||||
|
||||
# ============================================================
|
||||
# VariadicTest - check snprintf/printf variadic argument passing
|
||||
@@ -163,8 +163,8 @@ def test_snprintf_u8_edge():
|
||||
|
||||
|
||||
def main() -> int | t.CExport:
|
||||
w32.win32console.SetConsoleCP(65001)
|
||||
w32.win32console.SetConsoleOutputCP(65001)
|
||||
win32.win32console.SetConsoleCP(65001)
|
||||
win32.win32console.SetConsoleOutputCP(65001)
|
||||
|
||||
testcheck.begin("VariadicTest: snprintf/printf variadic 参数测试")
|
||||
|
||||
|
||||
Reference in new issue
Block a user