Files
Viper_RegressionTesting/FormatStringTest/App/main.vp
T
TermiNexus ee6461be46 chore(comments): Test 仓注释英文化(R11)
把 81 个 .vp 文件的中文 # 注释与三引号文档串改写为简洁英文,每个连续注释块 <=2 行;运行时中文字符串字面量(testcheck.begin/print 等用户可见消息)保持原样。骨架比对 HEAD 与工作区 112 文件漂移 0,全量 77/77 顺序回归通过。
2026-10-05 22:43:38 +08:00

51 lines
1.4 KiB
Plaintext

from stdint import *
import t, c
import ctraits
import stdio
import testcheck
# FormatStringTest - format string regression test
export def main() -> int:
testcheck.begin("FormatStringTest: Format String Regression")
b: str = "hello world"
for i in b:
stdio.printf("%c\n", i)
b += 1
print(b-11)
l: t.CArray[u64] = [0, 43, 2, 3, 4]
l[0] = 1000
for i in l:
stdio.printf("%llu\n", i)
print("Value: ", f"0x{ULONGLONG(0x11)}")
print("ULL Hex: ", f"0x{ULONGLONG(0x11):016X}")
print("LL Hex: ", f"{LONGLONG(0x11):016X}")
print("ULL Dec: ", f"{ULONGLONG(42):d}")
print("LL Dec: ", f"{LONGLONG(42):d}")
print("Hex: ", f"{0x11:016X}")
print("Dec: ", f"{42:d}")
print("Float: ", f"{3.14159:.2f}")
# f-string assignment: must build a string, not printf directly
s: str = f"Value=0x{ULONGLONG(42)}, Hex=0x{ULONGLONG(0x11):016X}"
print("Assigned: ", s)
# ctraits.isptr compile-time type check.
# &s is i8** (char**); implicit pointer casts require matching depth, so annotate str*.
ptr_var: str* = &s
val_var: int = 42
if c.CIf(ctraits.isptr(ptr_var)):
print("ptr_var is pointer")
if c.CIf(not ctraits.isptr(val_var)):
print("val_var is not pointer")
testcheck.section("placeholder")
testcheck.ok("testcheck framework ready")
testcheck.info("placeholder test")
return testcheck.end()