Files
Viper_RegressionTesting/G7/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

46 lines
1.4 KiB
Plaintext

import t
import stdio
import testcheck
import stdlib
import memhub
from conflict_node import Value
# G7: global variable 'Value' collides with class 'Value'
# Variable registration overrides the struct symbol, so struct body setup is skipped.
Value: t.CPtr = None
def test_value_struct_fields():
"""Verify the Value struct has 6 fields (Next + 5 own)."""
testcheck.section("Value struct field access (6 fields expected)")
arena: bytes = stdlib.malloc(4096)
if arena is None:
testcheck.check(False, "malloc arena", "FAIL")
return
pool: memhub.MemBuddy* = memhub.MemBuddy(arena, 4096)
node: Value* = pool.alloc(48)
if node is None:
testcheck.check(False, "alloc Value", "FAIL")
return
# Field 0: Next (inherited from GSListNode)
node.Next = None
# Fields 1-5: own fields
node.Ty = None
node.Name = None
node.IsConst = 1
node.IntVal = 42
node.FloatVal = 3.14
# Read back and verify
v: 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")
c: int = node.IsConst
testcheck.check(c == 1, "Value.IsConst = 1", "expect 1")
def main() -> int:
testcheck.begin("G7: Minimal repro - class name 'Value' conflicts with variable")
test_value_struct_fields()
return testcheck.end()