把 81 个 .vp 文件的中文 # 注释与三引号文档串改写为简洁英文,每个连续注释块 <=2 行;运行时中文字符串字面量(testcheck.begin/print 等用户可见消息)保持原样。骨架比对 HEAD 与工作区 112 文件漂移 0,全量 77/77 顺序回归通过。
36 lines
1.2 KiB
Plaintext
36 lines
1.2 KiB
Plaintext
import t
|
|
import stdio
|
|
import testcheck
|
|
|
|
|
|
# Extern2Test - minimal repro: ExternalDecl/StateDecl redefinition
|
|
# Three declarations plus main; each must emit exactly one declare.
|
|
|
|
|
|
# Test 1: t.CExtern | t.CExport - external declaration (pass body)
|
|
# Translator must emit declare, not define.
|
|
def ExternalDecl(x: int) -> int | t.CExtern | t.CExport: pass
|
|
|
|
|
|
# Test 2: t.State - state declaration (same as CExtern | CExport)
|
|
def StateDecl(x: int) -> int | t.State: pass
|
|
|
|
|
|
# Test 3: t.State returning void
|
|
def StateVoidDecl() -> t.State: pass
|
|
|
|
|
|
def test_extern_decl():
|
|
"""Verify the three extern declarations emit declare only once."""
|
|
testcheck.section("Extern/State declarations (no duplicate)")
|
|
# External declarations are not called; the linker resolves the symbols.
|
|
testcheck.check(True, "ExternalDecl declared (not called)", "expect declared once")
|
|
testcheck.check(True, "StateDecl declared (not called)", "expect declared once")
|
|
testcheck.check(True, "StateVoidDecl declared (not called)", "expect declared once")
|
|
|
|
|
|
def main() -> int:
|
|
testcheck.begin("Extern2Test: minimal repro - extern redefinition")
|
|
test_extern_decl()
|
|
return testcheck.end()
|