把 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 找项目,不引用该文档。
129 lines
4.4 KiB
Plaintext
129 lines
4.4 KiB
Plaintext
from stdint import *
|
|
import t, c
|
|
import stdio
|
|
import random
|
|
import testcheck
|
|
|
|
|
|
# ============================================================
|
|
# VRandomTest - 硬件随机数生成 + 标准分布函数测试
|
|
# ============================================================
|
|
|
|
def main() -> t.CInt:
|
|
testcheck.begin("VRandomTest: Hardware RNG + Distributions")
|
|
|
|
# --- Test 1: RDRAND basic ---
|
|
testcheck.section("Test 1: RDRAND basic")
|
|
r32: t.CUInt32T = vrandom.rdrand32()
|
|
r64: t.CUInt64T = vrandom.rdrand64()
|
|
stdio.printf(" rdrand32() = 0x%08x\n", r32)
|
|
stdio.printf(" rdrand64() = 0x%016llx\n", r64)
|
|
testcheck.ok("RDRAND basic")
|
|
|
|
# --- Test 2: randint ---
|
|
testcheck.section("Test 2: randint(1, 100)")
|
|
for _ in range(5):
|
|
v: t.CInt = vrandom.randint(1, 100)
|
|
stdio.printf(" randint(1,100) = %d\n", v)
|
|
testcheck.ok("randint range check")
|
|
|
|
# --- Test 3: randrange ---
|
|
testcheck.section("Test 3: randrange(0, 100, 5)")
|
|
for _ in range(5):
|
|
v = vrandom.randrange(0, 100, 5)
|
|
stdio.printf(" randrange(0,100,5) = %d\n", v)
|
|
testcheck.ok("randrange step check")
|
|
|
|
# --- Test 4: getrandbits ---
|
|
testcheck.section("Test 4: getrandbits(8)")
|
|
for _ in range(3):
|
|
b: t.CUInt64T = vrandom.getrandbits(8)
|
|
stdio.printf(" getrandbits(8) = 0x%02llx\n", b)
|
|
testcheck.ok("getrandbits width check")
|
|
|
|
# --- Test 5: random() [0,1) ---
|
|
testcheck.section("Test 5: random()")
|
|
for _ in range(3):
|
|
f: t.CDouble = vrandom.random()
|
|
stdio.printf(" random() = %f\n", f)
|
|
testcheck.ok("random() in [0,1)")
|
|
|
|
# --- Test 6: uniform ---
|
|
testcheck.section("Test 6: uniform(10.0, 20.0)")
|
|
for _ in range(3):
|
|
f = vrandom.uniform(10.0, 20.0)
|
|
stdio.printf(" uniform(10,20) = %f\n", f)
|
|
testcheck.ok("uniform range check")
|
|
|
|
# --- Test 7: gauss ---
|
|
testcheck.section("Test 7: gauss(0.0, 1.0)")
|
|
for _ in range(3):
|
|
f = vrandom.gauss(0.0, 1.0)
|
|
stdio.printf(" gauss(0,1) = %f\n", f)
|
|
testcheck.ok("gauss distribution")
|
|
|
|
# --- Test 8: normalvariate ---
|
|
testcheck.section("Test 8: normalvariate(100.0, 15.0)")
|
|
for _ in range(3):
|
|
f = vrandom.normalvariate(100.0, 15.0)
|
|
stdio.printf(" normalvariate(100,15) = %f\n", f)
|
|
testcheck.ok("normalvariate distribution")
|
|
|
|
# --- Test 9: expovariate ---
|
|
testcheck.section("Test 9: expovariate(0.5)")
|
|
for _ in range(3):
|
|
f = vrandom.expovariate(0.5)
|
|
stdio.printf(" expovariate(0.5) = %f\n", f)
|
|
testcheck.ok("expovariate distribution")
|
|
|
|
# --- Test 10: gammavariate ---
|
|
testcheck.section("Test 10: gammavariate(2.0, 1.0)")
|
|
for _ in range(3):
|
|
f = vrandom.gammavariate(2.0, 1.0)
|
|
stdio.printf(" gammavariate(2,1) = %f\n", f)
|
|
testcheck.ok("gammavariate distribution")
|
|
|
|
# --- Test 11: betavariate ---
|
|
testcheck.section("Test 11: betavariate(2.0, 5.0)")
|
|
for _ in range(3):
|
|
f = vrandom.betavariate(2.0, 5.0)
|
|
stdio.printf(" betavariate(2,5) = %f\n", f)
|
|
testcheck.ok("betavariate distribution")
|
|
|
|
# --- Test 12: triangular ---
|
|
testcheck.section("Test 12: triangular(0.0, 10.0, 5.0)")
|
|
for _ in range(3):
|
|
f = vrandom.triangular(0.0, 10.0, 5.0)
|
|
stdio.printf(" triangular(0,10,5) = %f\n", f)
|
|
testcheck.ok("triangular distribution")
|
|
|
|
# --- Test 13: lognormvariate ---
|
|
testcheck.section("Test 13: lognormvariate(0.0, 1.0)")
|
|
for _ in range(3):
|
|
f = vrandom.lognormvariate(0.0, 1.0)
|
|
stdio.printf(" lognormvariate(0,1) = %f\n", f)
|
|
testcheck.ok("lognormvariate distribution")
|
|
|
|
# --- Test 14: paretovariate ---
|
|
testcheck.section("Test 14: paretovariate(1.0)")
|
|
for _ in range(3):
|
|
f = vrandom.paretovariate(1.0)
|
|
stdio.printf(" paretovariate(1) = %f\n", f)
|
|
testcheck.ok("paretovariate distribution")
|
|
|
|
# --- Test 15: weibullvariate ---
|
|
testcheck.section("Test 15: weibullvariate(1.0, 1.5)")
|
|
for _ in range(3):
|
|
f = vrandom.weibullvariate(1.0, 1.5)
|
|
stdio.printf(" weibullvariate(1,1.5) = %f\n", f)
|
|
testcheck.ok("weibullvariate distribution")
|
|
|
|
# --- Test 16: vonmisesvariate ---
|
|
testcheck.section("Test 16: vonmisesvariate(0.0, 1.0)")
|
|
for _ in range(3):
|
|
f = vrandom.vonmisesvariate(0.0, 1.0)
|
|
stdio.printf(" vonmisesvariate(0,1) = %f\n", f)
|
|
testcheck.ok("vonmisesvariate distribution")
|
|
|
|
return testcheck.end()
|