Files
Aislo/resources/tester/test_355_1_pivot_tilt.py
T
eomsangdonandClaude Opus 5.5 84ead5a561 feat(B05 종단): ▲▼ 직선 안 측점 · 꼭짓점 아닌 자리 = 그 점 새 꺾임 · 좌우 다음 R 점 축 (368-1)
- pivotAxes 직선 안쪽 null 지움 · 꼭짓점 아닌 자리는 품은 마디로 축 찾기
- 시험 helper_355_1 ③ 직선 안 80 바꿈 · ④ 꼭짓점 아닌 70 더함

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013QyNXY2TUKXCFMwAca2APG
2026-10-17 11:46:18 +09:00

81 lines
2.9 KiB
Python

# -*- coding: utf-8 -*-
"""355-1 B05 종단 ▲▼ — 누른 점이 꺾임이면 이웃 꺾임을 축으로 사이 직선이 따라 돎(요구 235-15).
계산(`B05_Profile/logic/B05_Profile_UI_Profile_Alignment.ts` adjustStation ·
`_Pivot.ts` pivotAxes)은 Node 헬퍼(`helper_355_1_pivot_tilt.cjs`)가 트랜스파일해 돌리고,
부르는 곳 셋(▲▼ 버튼 · 표 값 입력 · 방향키)이 같은 함수인지는 소스로 본다.
"""
import json
import os
import subprocess
from pathlib import Path
import pytest
HERE = Path(__file__).resolve().parent
ROOT = HERE.parent.parent
def _read(relative: str) -> str:
return (ROOT / relative).read_text(encoding="utf-8")
@pytest.fixture(scope="module")
def out():
proc = subprocess.run(
["node", os.path.join(HERE, "helper_355_1_pivot_tilt.cjs")],
capture_output=True,
text=True,
encoding="utf-8",
timeout=60,
)
assert proc.returncode == 0, proc.stderr
return json.loads(proc.stdout)
def test_처음_계획선은_옛_값(out):
initial = out["initial"]
assert initial["sameUp"] and initial["sameDown"]
assert initial["upKeys"] == ["100.000"]
assert initial["radiiKeys"] == []
def test_꺾임_누르면_사이_측점이_한_직선(out):
kink = out["kink"]
assert kink["planRise"] == pytest.approx(0.1, abs=1e-4)
assert kink["axisMove"] == [0, 0]
assert kink["outsideMove"] == [0, 0]
assert all(abs(value) < 1e-6 for value in kink["innerResidual"])
# 축에서 멀수록 더 오름(40 → 60 → 80 → 100 · 160 → 140 → 120 → 100)
moved = kink["innerMoved"]
assert 0 < moved[0] < moved[1] < kink["pivotRise"]
assert 0 < moved[3] < moved[2] < kink["pivotRise"]
# 옛 길은 사이 측점이 그대로라 P±1 에서 꺾였음
assert kink["oldWouldBreak"] == [0, 0]
@pytest.mark.parametrize("case", ["inside", "between"])
def test_직선_안_점은_새_꺾임_축은_좌우_다음_꺾임(out, case):
# 368-1: 직선 안 측점(80) · 꼭짓점 아닌 자리(70) 모두 그 점에 R · 축 40 · 100
got = out[case]
assert got["planRise"] == pytest.approx(0.1, abs=1e-4)
assert got["axisMove"] == [0, 0]
assert got["outsideMove"] == [0, 0, 0, 0]
assert all(abs(value) < 1e-6 for value in got["innerResidual"])
assert all(value > 0 for value in got["innerMoved"])
assert got["curveAtPress"] and not got["pressRadiusKey"]
assert got["innerRadiusKeys"] == []
def test_부르는_곳_셋이_같은_함수():
assert "adjustStation(base, store.edits(), chainage, delta)" in _read(
"B05_Profile/B05_Profile_UI_Profile_Render.ts"
)
assert "ctx.applyEdits(adjustStation(base, ctx.edits(), chainage, delta))" in _read(
"B05_Profile/B05_Profile_UI_Profile_Panel_Tools.ts"
)
assert "pivotAxes(current, chainageM)" in _read(
"B05_Profile/logic/B05_Profile_UI_Profile_Alignment.ts"
)