Files
Aislo/resources/tester/test_est_global_vars.py
T
eomsangdonandClaude Opus 5.5 b97ecf47de feat(est-test): 단가산출 전역변수·새내역서 파일로저장·산출서 삽입과 선택 삭제
- 전역변수:  표지 대입 변수를 호표 넘어 유지, 지정·해제, 목록·이동
- 새내역서 파일로저장: 당초값·신규 표시·당초 사본 지운 새 작업 따로 저장
- 수량산출서 삽입(공종명칭·규격)·선택공종 삭제

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 13:43:43 +09:00

46 lines
2.3 KiB
Python
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.
"""EST 테스트 앱 단가산출 전역변수(원본 \x05 표지 — 호표를 넘어 값 유지, 지정·해제, 목록)."""
import json
import subprocess
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
def test_global_variable_crosses_groups_and_toggle():
code = r"""
const fs = require('fs'), vm = require('vm');
const ctx = vm.createContext({ structuredClone });
for (const f of ['native-math.js', 'native-formula.js', 'native-text.js', 'native-global-vars.js'])
vm.runInContext(fs.readFileSync('tools/est-test/' + f, 'utf8'), ctx, { filename: f });
const T = vm.runInContext('EstText', ctx), G = vm.runInContext('EstGlobalVars', ctx);
const rows = [
{ Index: 1, Code: 'D1', LineData: '호표1' },
{ Index: 0, SCheck: 0, LineData: '\x05Q\x05 = 2 × 3 = \x126\x12' },
{ Index: 1, Code: 'D2', LineData: '호표2' },
{ Index: 0, SCheck: -1, LineData: '노무 = Q × 10 = \x120\x12' },
{ Index: 1, Code: 'D3', LineData: '호표3' },
{ Index: 0, SCheck: 0, LineData: 'R = 1 = \x121\x12' },
{ Index: 1, Code: 'D4', LineData: '호표4' },
{ Index: 0, SCheck: -1, LineData: '노무 = R × 10 = \x120\x12' },
];
const r = T.calculate(rows, {});
let bad = ''; try { G.toggle('가 = 3', 0); } catch (e) { bad = e.message.slice(0, 12); }
process.stdout.write(JSON.stringify({
used: r.rows[3].LineData.match(/\x12([^\x12]+)\x12/)[1], kept: r.rows[1].LineData.startsWith('\x05Q\x05'),
local: r.errors.length, globals: r.globals,
on: G.toggle('Q = 2', 0), off: G.toggle('⟦전역⟧Q⟦전역⟧ = 2', 5), bad,
clean: T.clean('\x05Q\x05 = 1'), shown: T.display('\x05V1\x05'), back: T.encode('⟦전역⟧V1⟦전역⟧') === '\x05V1\x05',
}));
"""
out = json.loads(subprocess.check_output(["node", "-e", code], cwd=ROOT).decode("utf-8"))
assert out["used"] == "60"
assert out["kept"] is True
assert out["local"] == 1 # R 은 전역이 아니라 D4 에서 못 찾음
assert out["globals"] == [{"name": "Q", "value": 6, "index": 1}]
assert out["on"] == "⟦전역⟧Q⟦전역⟧ = 2"
assert out["off"] == "Q = 2"
assert out["bad"] == "선택한 변수는 전역변수"
assert out["clean"] == "Q = 1"
assert out["shown"] == "⟦전역⟧V1⟦전역⟧" and out["back"] is True