chore(test): 初始化回归测试仓(新增 .gitignore,TestsOverview.md 改为 README.md)

把 Test/ 纳入 https://git.gvsds.com/GVSDS/Viper_RegressionTesting 。

1) 新增 .gitignore —— 只保留测试源码,剔除全部构建产物:
   目录   **/output*/(output / output_opt / output_orig / output_verify / output_dbg)、
          **/temp*/(temp / temp_opt)、**/.tpv_build/
   二进制 *.exe *.obj *.o *.out *.a *.lib *.dll
   中间物 *.ll *.vpi *.pyi *.deps.txt *.deps.json *.doc.json *_sha1_map.txt
          _pyi_cache_v1.pkl _pyi_cache_v1.sig.json _shared_sym.json _phase1_manifest.json
   其它   build_all.txt(构建日志)、*.log、__pycache__/、*.bak、IDE 目录
   保留   App/*.vp、project.json / project_opt.json / project.vpj、README.md、两个 .py
   实测 `git add -A --dry-run`:196 个文件,无任何构建产物混入。

2) TestsOverview.md → README.md(作为仓库首页文档)。

3) SequentialRegressionTest.py:7 处 TestsOverview.md 引用同步改为 README.md
   (文档串、OVERVIEW 路径、read_test_order 文档与报错文案、argparse description、
   启动横幅);同时修正入口路径 PROJECTRANS —— 旧值 <root>/Projectrans.py 已不存在,
   改为 <root>/TransPyC/Projectrans.py(与 regression_test.py:45-48 记录一致),
   否则本脚本会以 "can't open file" 全量失败。
   regression_test.py 无需改动:它按目录扫描 project.json 找项目,不引用该文档。
This commit is contained in:
TermiNexus committed 2026-09-29 15:14:59 +08:00
commit 3c6fb1d246
196 files changed
+24775

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
import t, c
POSMAX: t.CDefine = 100
MAX_RETRY: t.CDefine = 5
BUFFER_SIZE: t.CDefine = 256
PI: t.CDefine = 3.14159
EULER: t.CDefine = 2.71828
TRUE: t.CDefine = 1
FALSE: t.CDefine = 0
NULL: t.CDefine = 0
MATH_OFFSET: t.CDefine = 10
MATH_SCALE: t.CDefine = 2
THRESHOLD: t.CDefine = 50
LOOP_LIMIT: t.CDefine = 20
SHIFT_AMOUNT: t.CDefine = 2
MASK_VALUE: t.CDefine = 0xFF
BIT_RANGE: t.CDefine = 4
EXPONENT_BASE: t.CDefine = 3
MODULO_DIVISOR: t.CDefine = 7
SCALE_SHIFT: t.CDefine = 4
HALF_SCALE: t.CDefine = 0.5
+79
View File
@@ -0,0 +1,79 @@
import stdio
import t, c
import config
import test
import testcheck
def main() -> t.CInt:
testcheck.begin("LoopMathTest: While/数学/跨模块宏测试")
testcheck.section("Cross-module macros")
stdio.printf(" POSMAX: %d\n", config.POSMAX)
stdio.printf(" MATH_SCALE: %d\n", config.MATH_SCALE)
stdio.printf(" THRESHOLD: %d\n", config.THRESHOLD)
stdio.printf(" SHIFT_AMOUNT: %d\n", config.SHIFT_AMOUNT)
stdio.printf(" MASK_VALUE: 0x%x\n", config.MASK_VALUE)
testcheck.ok("config macros accessible")
testcheck.section("While Loop Test")
test.AboutSizeTWhileTest(10)
testcheck.ok("While Loop Test (10)")
testcheck.section("Math Basic Test (20, 6)")
test.MathBasicTest(20, 6)
testcheck.ok("Math Basic Test (20, 6)")
testcheck.section("Math Advanced Test (value=15)")
test.MathAdvancedTest(15)
testcheck.ok("Math Advanced Test (value=15)")
testcheck.section("While with Elif-Else Test (-2 to 12)")
test.WhileWithElifElseTest(-2, 12)
testcheck.ok("While with Elif-Else Test (-2 to 12)")
testcheck.section("Nested While with Macros Test")
test.NestedWhileWithMacrosTest(3, 4)
testcheck.ok("Nested While with Macros Test (3, 4)")
testcheck.section("Complex Condition Test (1, 2, 3)")
test.ComplexConditionTest(1, 2, 3)
testcheck.ok("Complex Condition Test (1, 2, 3)")
testcheck.section("Retry Loop Test (8)")
test.RetryLoopTest(8)
testcheck.ok("Retry Loop Test (8)")
testcheck.section("Bitwise Operations Test (0b1101101)")
test.BitwiseOperationsTest(109)
testcheck.ok("Bitwise Operations Test (109)")
testcheck.section("Compound Assignment Math Test (15, 4)")
test.CompoundAssignmentMathTest(15, 4)
testcheck.ok("Compound Assignment Math Test (15, 4)")
testcheck.section("Power and Modulo Test (2, 8)")
test.PowerAndModuloTest(2, 8)
testcheck.ok("Power and Modulo Test (2, 8)")
testcheck.section("Mixed Arithmetic Test (5, 3, 4)")
test.MixedArithmeticTest(5, 3, 4)
testcheck.ok("Mixed Arithmetic Test (5, 3, 4)")
testcheck.section("Math with While Loop Test (start=1, count=5)")
test.MathWithWhileLoopTest(1, 5)
testcheck.ok("Math with While Loop Test (1, 5)")
testcheck.section("Complex Nested Math Test (7, 3)")
test.ComplexNestedMathTest(7, 3)
testcheck.ok("Complex Nested Math Test (7, 3)")
testcheck.section("Conditional Math Chain Test (value=10)")
test.ConditionalMathChainTest(10)
testcheck.ok("Conditional Math Chain Test (value=10)")
testcheck.section("Bit Manipulation Math Test (0xABCD)")
test.BitManipulationMathTest(0xABCD)
testcheck.ok("Bit Manipulation Math Test (0xABCD)")
return testcheck.end()
+298
View File
@@ -0,0 +1,298 @@
import config
import t, c
def AboutSizeTWhileTest(length: t.CSizeT):
pos: t.CSizeT = 0
while pos < length:
print("Pos: ", pos)
if pos > config.POSMAX: break
pos += 1
while pos < length:
if pos > config.POSMAX:
print("Pos: ", pos)
pos += 1
else:
print("Pos: ", pos)
pos += 1
if pos > config.POSMAX: break
else:
pos += 1
print("Pos: ", pos)
while pos < length:
print("Pos: ", pos)
pos += 1
def MathBasicTest(x: t.CInt, y: t.CInt) -> t.CInt:
result: t.CInt = 0
result = x + y
print("Add: ", result)
result = x - y
print("Sub: ", result)
result = x * y
print("Mul: ", result)
if y != 0:
result = x / y
print("Div: ", result)
result = x % y if y != 0 else 0
print("Mod: ", result)
return result
def MathAdvancedTest(value: t.CInt) -> t.CInt:
counter: t.CInt = 0
scaled: t.CInt = 0
offset: t.CInt = 0
scaled = value * config.MATH_SCALE
print("Scaled: ", scaled)
offset = scaled + config.MATH_OFFSET
print("Offset: ", offset)
threshold: t.CInt = config.THRESHOLD
if offset > threshold:
print("Above threshold")
counter = 1
elif offset == threshold:
print("At threshold")
counter = 0
else:
print("Below threshold")
counter = -1
return counter
def WhileWithElifElseTest(start: t.CInt, end: t.CInt):
idx: t.CInt = start
while idx < end:
if idx < 0:
print("Negative: ", idx)
elif idx == 0:
print("Zero: ", idx)
elif idx > 0 and idx < 5:
print("Small positive: ", idx)
elif idx >= 5 and idx < 10:
print("Medium positive: ", idx)
else:
print("Large: ", idx)
idx += 1
def NestedWhileWithMacrosTest(outer_limit: t.CInt, inner_limit: t.CInt):
outer: t.CInt = 0
inner: t.CInt = 0
total_ops: t.CInt = 0
while outer < outer_limit:
inner = 0
while inner < inner_limit:
if inner == config.TRUE:
print("Inner loop break condition at: ", inner)
total_ops += 1
inner += 1
outer += 1
print("Total operations: ", total_ops)
def ComplexConditionTest(a: t.CInt, b: t.CInt, c_val: t.CInt):
x: t.CInt = a
y: t.CInt = b
z: t.CInt = c_val
while x < config.LOOP_LIMIT:
if x > 0 and y > 0 and z > 0:
print("All positive: ", x, y, z)
elif x <= 0 and y <= 0 and z <= 0:
print("All non-positive: ", x, y, z)
else:
if x > 0:
print("X positive")
elif y > 0:
print("Y positive")
else:
print("Z positive")
x += 1
y += 1
z += 1
def RetryLoopTest(retry_count: t.CInt) -> t.CInt:
attempt: t.CInt = 0
success: t.CInt = 0
while attempt < retry_count:
if attempt < config.MAX_RETRY:
print("Attempt: ", attempt, " less than max")
success = attempt * 2
elif attempt == config.MAX_RETRY:
print("At max retry")
success = -1
else:
print("Beyond max retry")
success = -2
attempt += 1
return success
def BitwiseOperationsTest(value: t.CInt) -> t.CInt:
shifted: t.CInt = 0
masked: t.CInt = 0
xored: t.CInt = 0
anded: t.CInt = 0
ored: t.CInt = 0
shifted = value << config.SHIFT_AMOUNT
print("Left shift: ", shifted)
shifted = value >> config.SHIFT_AMOUNT
print("Right shift: ", shifted)
masked = value & config.MASK_VALUE
print("Bitwise AND mask: ", masked)
xored = value ^ config.MASK_VALUE
print("Bitwise XOR: ", xored)
anded = value & (config.MASK_VALUE >> config.SHIFT_AMOUNT)
print("Bitwise AND shifted mask: ", anded)
ored = value | config.SHIFT_AMOUNT
print("Bitwise OR shift: ", ored)
return masked
def CompoundAssignmentMathTest(a: t.CInt, b: t.CInt) -> t.CInt:
x: t.CInt = a
y: t.CInt = b
result: t.CInt = 0
x += y
print("x += y: ", x)
x -= y
print("x -= y: ", x)
x *= y
print("x *= y: ", x)
x = a
y = b
if b != 0:
x /= b
print("x /= y: ", x)
x = a
if b != 0:
x %= b
print("x %%= y: ", x)
x = a
x <<= config.SHIFT_AMOUNT
print("x <<= shift: ", x)
x >>= config.SHIFT_AMOUNT
print("x >>= shift: ", x)
x &= config.MASK_VALUE
print("x &= mask: ", x)
x |= config.SHIFT_AMOUNT
print("x |= shift: ", x)
result = (a + b) * config.MATH_SCALE - config.MATH_OFFSET
print("Compound: (a+b)*scale-offset: ", result)
result = (a * b) + (config.MATH_OFFSET / 2)
print("Compound: a*b+offset/2: ", result)
return result
def PowerAndModuloTest(base: t.CInt, exponent: t.CInt) -> t.CInt:
result: t.CInt = 1
temp: t.CInt = 0
i: t.CInt = 0
while i < exponent:
result *= base
i += 1
print("Power: ", result)
temp = result % config.MODULO_DIVISOR
print("Power mod: ", temp)
temp = (base * config.EXPONENT_BASE) % config.MODULO_DIVISOR
print("base*exp %% divisor: ", temp)
temp = ((base + config.MATH_OFFSET) * config.MATH_SCALE) % config.MODULO_DIVISOR
print("(base+offset)*scale %% divisor: ", temp)
return result
def MixedArithmeticTest(x: t.CInt, y: t.CInt, z: t.CInt) -> t.CInt:
result: t.CInt = 0
result = (x + y) * z
print("(x+y)*z: ", result)
result = x + (y * z)
print("x+(y*z): ", result)
result = ((x + y) * config.MATH_SCALE) - config.MATH_OFFSET
print("((x+y)*scale)-offset: ", result)
result = (x * config.MATH_SCALE) + (y * config.MATH_SCALE)
print("x*scale + y*scale: ", result)
result = ((x % config.MODULO_DIVISOR) + (y % config.MODULO_DIVISOR)) * config.MATH_SCALE
print("(x%%mod + y%%mod)*scale: ", result)
temp: t.CInt = 0
temp = x | y & z
print("x | y & z: ", temp)
temp = (x | y) & z
print("(x | y) & z: ", temp)
temp = x ^ y ^ z
print("x ^ y ^ z: ", temp)
return result
def MathWithWhileLoopTest(start: t.CInt, count: t.CInt) -> t.CInt:
idx: t.CInt = 0
accumulator: t.CInt = 0
multiplier: t.CInt = config.MATH_SCALE
while idx < count:
temp: t.CInt = (start + idx) * multiplier
temp = temp + config.MATH_OFFSET
if temp > config.THRESHOLD:
temp = config.THRESHOLD
accumulator += temp
multiplier += 1
idx += 1
print("Accumulator: ", accumulator)
return accumulator
def ComplexNestedMathTest(a: t.CInt, b: t.CInt) -> t.CInt:
layer1: t.CInt = 0
layer2: t.CInt = 0
layer3: t.CInt = 0
i: t.CInt = 0
layer1 = (a + b) * config.MATH_SCALE
print("Layer1: ", layer1)
while i < config.BIT_RANGE:
layer2 += layer1 >> 1
i += 1
print("Layer2: ", layer2)
layer3 = layer1 + layer2 - config.MATH_OFFSET
print("Layer3: ", layer3)
layer3 = layer3 * config.MATH_SCALE / 2 if config.MATH_SCALE != 0 else layer3
print("Layer3 scaled: ", layer3)
return layer3
def ConditionalMathChainTest(value: t.CInt) -> t.CInt:
result: t.CInt = 0
step: t.CInt = 0
while step < config.LOOP_LIMIT:
if step < 5:
result += step * config.MATH_SCALE
print("step<5: ", result)
elif step < 10:
result -= step - config.MATH_OFFSET
print("step<10: ", result)
elif step < 15:
result += (step * config.MATH_OFFSET) / config.MATH_SCALE
print("step<15: ", result)
else:
result = result * config.EXPONENT_BASE % config.MODULO_DIVISOR
print("step>=15: ", result)
step += 1
return result
def BitManipulationMathTest(value: t.CInt) -> t.CInt:
original: t.CInt = value
nibble: t.CInt = 0
result: t.CInt = 0
result = (value << config.SHIFT_AMOUNT) | (value >> (8 - config.SHIFT_AMOUNT))
print("Rotate left: ", result)
result = (value >> config.SHIFT_AMOUNT) | (value << (8 - config.SHIFT_AMOUNT))
print("Rotate right: ", result)
nibble = value & 0xF
print("Lower nibble: ", nibble)
nibble = (value >> config.BIT_RANGE) & 0xF
print("Upper nibble: ", nibble)
result = ((value & config.MASK_VALUE) + config.MATH_OFFSET) * config.MATH_SCALE
print("Masked and scaled: ", result)
result = ((original << config.SHIFT_AMOUNT) ^ original) & config.MASK_VALUE
print("XOR shifted: ", result)
return result