Files
Viper_RegressionTesting/CharTest/App/main.vp
T
TermiNexus f5da836fbb chore(test): 迁移测试夹具到新语法
机械规则 R2/R3/R4/R6/R7/R8/R13 + R16 保守子集,共 86 文件 2127 行。R1(T | t.CPtr)与 R12(while 下标循环)未做,仍列为待办。全量 77/77 顺序回归通过。
2026-10-05 19:59:02 +08:00

32 lines
850 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import t, c
from stdint import *
import stdio
def bump(v: char) -> char:
return char(v + 1)
def main() -> int | t.CExport:
# 1) char 注解:char = t.CChar = i8(标量内置类型,非指针)
ch: char = 65
stdio.printf("1 char annot: %d (expect 65)\n", int(ch))
# 2) char() 强转 int→char:300 trunc 到 i8 → 44
big: char = char(300)
stdio.printf("2 char cast trunc: %d (expect 44)\n", int(big))
# 3) 函数返回 char(i8 存储)
nx: char = bump(ch)
stdio.printf("3 char return: %d (expect 66)\n", int(nx))
# 4) 单字符字面量 'Z' 赋给 char(90)
lit: char = 'Z'
stdio.printf("4 char literal: %d (expect 90)\n", int(lit))
# 5) char 参与算术(i8 与 int 混合提升)
s: int = ch + 1
stdio.printf("5 char arith: %d (expect 66)\n", s)
return 0