test: cover between/hostvar/gcov-merge, class conditions, schema drop-tables, gixsql fixes
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
"""SQLCA 字节序对齐测试(T1)。
|
||||
|
||||
gixsql 以 native 小端 int 写入 SQLCA.SQLCODE。GnuCOBOL 的 COMP 按大端存储,
|
||||
导致非零 SQLCODE 被错读(如 -1555 → -302383105)。必须改用 COMP-5(native),
|
||||
否则 `IF SQLCODE = -803` 类具体值判断永远无法匹配。
|
||||
"""
|
||||
|
||||
import sys, os
|
||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")))
|
||||
from cobol_testgen.read import resolve_sql_includes, _BUILTIN_SQLCA
|
||||
from runners.gixsql_runner import GixsqlCobolRunner
|
||||
|
||||
|
||||
def test_builtin_sqlca_uses_comp5_for_numeric_fields():
|
||||
"""内置 SQLCA 的 SQLCABC/SQLCODE 必须用 COMP-5(native 字节序)"""
|
||||
assert "SQLCABC PIC S9(9) COMP-5" in _BUILTIN_SQLCA
|
||||
assert "SQLCODE PIC S9(9) COMP-5" in _BUILTIN_SQLCA
|
||||
assert "SQLERRML PIC S9(4) COMP-5" in _BUILTIN_SQLCA
|
||||
assert "PIC S9(9) COMP-5" in _BUILTIN_SQLCA
|
||||
|
||||
|
||||
def test_resolve_sql_includes_injects_comp5_sqlca():
|
||||
"""EXEC SQL INCLUDE SQLCA 解析后注入的 SQLCA 用 COMP-5"""
|
||||
src = " EXEC SQL INCLUDE SQLCA END-EXEC.\n"
|
||||
out = resolve_sql_includes(src, ".")
|
||||
assert "SQLCODE PIC S9(9) COMP-5" in out
|
||||
|
||||
|
||||
def test_runner_inline_sqlca_uses_comp5():
|
||||
"""gixsql_runner 内联 SQLCA 的数值字段用 COMP-5"""
|
||||
r = GixsqlCobolRunner(gixpp_path="gixpp", lib_path="lib")
|
||||
r._copybook_dirs = []
|
||||
# _expand_all_copies 内联 SQLCA 分支(copybook 不存在时)
|
||||
text = " COPY SQLCA.\n"
|
||||
out = r._expand_all_copies(text, [])
|
||||
assert "SQLCODE PIC S9(9) COMP-5" in out
|
||||
assert "SQLCABC PIC S9(9) COMP-5" in out
|
||||
assert "SQLERRD PIC S9(9) COMP-5 OCCURS 6" in out
|
||||
Reference in New Issue
Block a user