- adjustStation — 누른 점이 꺾임이면 pivotAxes 로 좌우 다음 꺾임(없으면 시점 · 종점)을 축으로 사이 측점을 새 직선 위로 · 사이 R 키 지움 · 직선 안쪽 · 처음 계획선은 옛 값 그대로 - 새 logic/B05_Profile_UI_Profile_Pivot.ts — 타입만 import(순환 없음) - 시험 test_355_1 · helper_355_1 세 경우 · test_213_1/2 tsc 산출 ESM import 에 .js 붙임 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013QyNXY2TUKXCFMwAca2APG
73 lines
2.4 KiB
Python
73 lines
2.4 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]
|
|
|
|
|
|
def test_직선_안쪽은_옛_값(out):
|
|
assert out["inside"]["same"]
|
|
assert out["inside"]["planRise"] == pytest.approx(0.1, abs=1e-4)
|
|
|
|
|
|
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"
|
|
)
|