Files
gplan-2/game/tests/unit/presentation/seal_mark_params_test.gd

53 lines
2.7 KiB
GDScript
Raw Permalink 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.
# tests/unit/presentation/seal_mark_params_test.gd — 封印印记参数化绘制守门(卡④ R1–R4)
# 断言面:五常量取值逐项相等(ui_kit ↔ art-bible §8.2 对照);着色器文件存在且七个 uniform 名在文;
# 迷雾门控(seal_on × fog_state → 封印子件可见性)〔seal批 V1–V4〕。
# 运行:godot --headless --path game --script res://tests/unit/presentation/seal_mark_params_test.gd
extends SceneTree
const Kit := preload("res://tests/unit/test_kit.gd")
const SEAL_SHADER := "res://presentation/views/seal_mark.gdshader"
const CELL_UNIT := preload("res://presentation/views/board_cell_unit.gd")
func _init() -> void:
_test_param_values()
_test_shader_uniforms()
_test_fog_gate()
quit(Kit.finish("seal_mark_params_test"))
# R1–R3/R7 前置:五常量取值逐项相等(art-bible §8.2 定值)
func _test_param_values() -> void:
Kit.check("SEAL_RING_FRAC = 0.82〔seal批 V1〕", UiKit.SEAL_RING_FRAC == 0.82)
Kit.check("SEAL_WALL_FRAC = 0.11〔seal批 V2〕", UiKit.SEAL_WALL_FRAC == 0.11)
Kit.check("SEAL_ARM_FRAC = 0.156〔seal批 V2〕", UiKit.SEAL_ARM_FRAC == 0.156)
Kit.check("SEAL_HALO_ALPHA = 0.50〔seal批 V3〕", UiKit.SEAL_HALO_ALPHA == 0.50)
Kit.check("SEAL_HALO_GAMMA = 1.6〔seal批 V3〕", UiKit.SEAL_HALO_GAMMA == 1.6)
# R1–R3/R7:着色器存在+七个 uniform 名在文(参数注入面契约)
func _test_shader_uniforms() -> void:
var src := FileAccess.get_file_as_string(SEAL_SHADER)
Kit.check("着色器文件存在且非空:%s〔seal批 V1〕" % SEAL_SHADER, src.length() > 0)
if src.length() == 0:
return
for uniform in ["cell_px", "ring_frac", "wall_frac", "arm_frac", "halo_frac", "halo_alpha", "halo_gamma", "mark_col"]:
Kit.check("着色器 uniform 在文:%s〔seal批 V1〕" % uniform, src.contains(uniform))
Kit.check("着色器含光圈半径夹取行(r ≤ cell_px/2——光圈不出格)〔seal批 V3〕",
src.contains("min(r, cell_px * 0.5)"))
# R4 迷雾门控:seal_on × fog_state → 封印子件可见性(内部字段直查=受控例外——子件可见性无公开可观测面,
# 卡面 R4 断言即 prescribe 子件 visible 直查;对照表该行注记理由)
func _test_fog_gate() -> void:
var u: Node2D = CELL_UNIT.new()
u.seal_on = true
Kit.check("seal_on 即挂封印子件〔seal批 V4〕", u._seal_layer != null)
u.fog_state = 1
Kit.check("雾态(fog_state=1)封印子件不可见〔seal批 V4〕", u._seal_layer.visible == false)
u.fog_state = 0
Kit.check("非雾态(fog_state=0)封印子件可见〔seal批 V4〕", u._seal_layer.visible == true)
u.seal_on = false
Kit.check("撤 seal_on 即撤子件〔seal批 V4〕", u._seal_layer == null)
u.free()