snapshot before regression test
This commit is contained in:
20
TransPyV/Test/NegativeTest/App/defs.py
Normal file
20
TransPyV/Test/NegativeTest/App/defs.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import stdio
|
||||
import t, c
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 负向测试定义模块:定义 SecretClass
|
||||
#
|
||||
# 此文件定义 SecretClass,但 main.py 不 import 它。
|
||||
# 严格模式下 main.py 中的 SecretClass() 构造应编译失败。
|
||||
# ============================================================
|
||||
|
||||
|
||||
class SecretClass:
|
||||
val: t.CInt
|
||||
|
||||
def __init__(self, v: t.CInt):
|
||||
self.val = v
|
||||
|
||||
def GetVal(self) -> t.CInt:
|
||||
return self.val
|
||||
21
TransPyV/Test/NegativeTest/App/main.py
Normal file
21
TransPyV/Test/NegativeTest/App/main.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import stdio
|
||||
import t, c
|
||||
# 故意不 import defs.SecretClass — 严格模式下应编译失败
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 负向测试主入口
|
||||
#
|
||||
# 此文件故意不 import SecretClass,但尝试使用 SecretClass()。
|
||||
# 命名空间隔离严格模式下,SecretClass 不可见,
|
||||
# 构造器路径被跳过,生成 call i32 @SecretClass(...),
|
||||
# llc 报错 "use of undefined value '@SecretClass'"。
|
||||
#
|
||||
# 预期:TransPyV 编译失败(exit code != 0)
|
||||
# ============================================================
|
||||
def main() -> int:
|
||||
# SecretClass 未导入,严格模式下不可见
|
||||
s: SecretClass = SecretClass(42)
|
||||
v: int = s.GetVal()
|
||||
stdio.printf("negtest: v=%d (should not reach here)\n", v)
|
||||
return 0
|
||||
29
TransPyV/Test/NegativeTest/project.vpj
Normal file
29
TransPyV/Test/NegativeTest/project.vpj
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/TermiNexus/TransPyC/main/schemas/project-schema.json",
|
||||
"name": "NegativeTest",
|
||||
"version": "1.0.0",
|
||||
"source_dir": "./App",
|
||||
"temp_dir": "./temp",
|
||||
"output_dir": "./output",
|
||||
"compiler": {
|
||||
"cmd": "llc",
|
||||
"flags": ["-filetype=obj", "-relocation-model=pic"]
|
||||
},
|
||||
"linker": {
|
||||
"cmd": "clang++",
|
||||
"flags": ["-lmsvcrt", "-lucrt", "-lpthread", "-lmingwex", "-lkernel32", "-Wl,--allow-multiple-definition"],
|
||||
"output": "neg_app.exe"
|
||||
},
|
||||
"includes": [
|
||||
"../../includes"
|
||||
],
|
||||
"target": {
|
||||
"triple": "x86_64-pc-windows-gnu",
|
||||
"datalayout": "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
},
|
||||
"options": {
|
||||
"slice_level": 3,
|
||||
"target": "llvm",
|
||||
"strict_mode": true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user