feat: Elementvalidierung mit Pruefdialog

- RoutineValidator und ValidationIssue gegen Katalog und Level-Regeln
- Prueft Kuerzel/Typ/Level, Feature-Auswahl, Level-Abgleich sowie
  ChSq- und Sprung-Sonderfaelle
- Programmweite once_per_program-Features als Warnung
- Pruefen-Button und Dialog in der Statusleiste, nicht blockierend
- 28 Validierungs-Assertions, Whiteboard-Tests auf 233 erweitert (866 gesamt)
- Doku: isu-rules, Findings, Architektur und Roadmap aktualisiert
This commit is contained in:
torsten 2026-10-31 09:56:05 +01:00
parent 0613ffca3e
commit 223a072f5d
17 changed files with 1017 additions and 15 deletions

View file

@ -502,6 +502,14 @@ theme_override_font_sizes/font_size = 15
text = "Abschnitt 1 · 0 Segmente"
vertical_alignment = 1
[node name="ValidationButton" type="Button" parent="Layout/StatusBar/StatusBarContent"]
unique_name_in_owner = true
custom_minimum_size = Vector2(120, 56)
layout_mode = 2
theme_override_font_sizes/font_size = 15
text = "Prüfen"
tooltip_text = "Elemente gegen Katalog und Level-Regeln prüfen"
[node name="DeleteSegmentButton" type="Button" parent="Layout/StatusBar/StatusBarContent"]
unique_name_in_owner = true
custom_minimum_size = Vector2(160, 56)
@ -932,3 +940,19 @@ text = "Ziel: user://exports"
unique_name_in_owner = true
hide_on_item_selection = false
hide_on_checkable_item_selection = false
[node name="ValidationDialog" type="AcceptDialog" parent="."]
unique_name_in_owner = true
title = "Kür prüfen"
size = Vector2i(720, 520)
ok_button_text = "Schließen"
[node name="ValidationText" type="RichTextLabel" parent="ValidationDialog"]
unique_name_in_owner = true
offset_left = 12.0
offset_top = 12.0
offset_right = 708.0
offset_bottom = 456.0
bbcode_enabled = true
scroll_active = true
selection_enabled = true

View file

@ -86,6 +86,16 @@ func get_level4_features(type: PathSegment.ElementType) -> PackedStringArray:
return _level4_by_type[type].duplicate()
## Fixed level for elements that are not feature-based (ChSq), or -1.
func get_fixed_level(type: PathSegment.ElementType, code: String) -> int:
if type != PathSegment.ElementType.SEQUENCE:
return -1
var key := _normalize(code)
if not _fixed_levels.has(key):
return -1
return _fixed_levels[key]
func get_thresholds() -> Array[Dictionary]:
var copy: Array[Dictionary] = []
copy.assign(_thresholds)

View file

@ -0,0 +1,296 @@
class_name RoutineValidator
extends RefCounted
## Validates the element data of a routine against the season's catalog and
## level rules. It does not validate paths or section bookkeeping (the model
## does that) and it does not know program types, element counts, jump
## combinations or repetition limits yet.
var _catalog: ElementCatalog
var _rules: ElementLevelRules
func _init(catalog: ElementCatalog, rules: ElementLevelRules) -> void:
_catalog = catalog
_rules = rules
## Returns all findings in section order. An empty array means the element
## data is consistent with the loaded rule set.
func validate(routine: Routine) -> Array[ValidationIssue]:
var issues: Array[ValidationIssue] = []
if routine == null:
issues.append(_issue(ValidationIssue.Severity.ERROR, "Keine Kür geladen."))
return issues
if _catalog == null or _rules == null:
issues.append(
_issue(
ValidationIssue.Severity.ERROR,
"Regelwerk ist nicht geladen; Prüfung nicht möglich."
)
)
return issues
var seen_once: Dictionary[String, String] = {}
for section: RoutineSection in routine.sections:
if section == null:
continue
for segment: PathSegment in section.segments:
if segment == null or not segment.is_element():
continue
_validate_segment(segment, section.section_id, issues)
_collect_program_features(
segment,
section.section_id,
seen_once,
issues
)
return issues
func _validate_segment(
segment: PathSegment,
section_id: String,
issues: Array[ValidationIssue]
) -> void:
var code := segment.element_code.strip_edges()
if code.is_empty():
issues.append(
_issue(
ValidationIssue.Severity.WARNING,
"Element ohne Kürzel; Base Value und Level sind nicht prüfbar.",
section_id,
segment.segment_id
)
)
return
var definition := _catalog.find(code)
if definition == null:
issues.append(
_issue(
ValidationIssue.Severity.ERROR,
"Kürzel „%s“ ist nicht im Katalog %s."
% [code, _catalog.season],
section_id,
segment.segment_id
)
)
elif definition.element_type != segment.element_type:
issues.append(
_issue(
ValidationIssue.Severity.ERROR,
"Kürzel „%s“ gehört zu %s, nicht zu %s."
% [
code,
PathSegment.element_type_name(definition.element_type),
PathSegment.element_type_name(segment.element_type),
],
section_id,
segment.segment_id
)
)
var fixed_level := _rules.get_fixed_level(segment.element_type, code)
if fixed_level >= 0:
if segment.element_level != fixed_level:
issues.append(
_issue(
ValidationIssue.Severity.ERROR,
"„%s“ ist fest %s (gewählt: %s)."
% [
code,
ElementDefinition.level_label(fixed_level),
ElementDefinition.level_label(segment.element_level),
],
section_id,
segment.segment_id
)
)
elif (
definition != null
and definition.element_type == segment.element_type
):
if definition.is_leveled():
if not definition.has_level(segment.element_level):
issues.append(
_issue(
ValidationIssue.Severity.ERROR,
"%s ist für „%s“ nicht verfügbar."
% [
ElementDefinition.level_label(segment.element_level),
code,
],
section_id,
segment.segment_id
)
)
elif segment.element_level != 0:
issues.append(
_issue(
ValidationIssue.Severity.WARNING,
"„%s“ hat Level %d; Sprünge sind nicht levelbar."
% [code, segment.element_level],
section_id,
segment.segment_id
)
)
_validate_features(segment, code, section_id, issues)
func _validate_features(
segment: PathSegment,
code: String,
section_id: String,
issues: Array[ValidationIssue]
) -> void:
if segment.element_type == PathSegment.ElementType.JUMP:
if not segment.element_features.is_empty():
issues.append(
_issue(
ValidationIssue.Severity.WARNING,
"„%s“ hat %d Level-Features; Sprünge sind nicht levelbar."
% [code, segment.element_features.size()],
section_id,
segment.segment_id
)
)
return
var counts: Dictionary[String, int] = {}
for raw: String in segment.element_features:
var feature_code := raw.strip_edges()
if feature_code.is_empty():
issues.append(
_issue(
ValidationIssue.Severity.ERROR,
"Leerer Feature-Code bei „%s“." % code,
section_id,
segment.segment_id
)
)
continue
var feature := _rules.get_feature(segment.element_type, feature_code)
if feature == null:
issues.append(
_issue(
ValidationIssue.Severity.ERROR,
"Unbekanntes Feature „%s“ für „%s“." % [raw, code],
section_id,
segment.segment_id
)
)
continue
var used: int = counts.get(feature_code, 0)
if used >= feature.max_per_element:
issues.append(
_issue(
ValidationIssue.Severity.ERROR,
"Feature „%s“ ist bei „%s“ zu oft gewählt (max. %d)."
% [feature.display_name, code, feature.max_per_element],
section_id,
segment.segment_id
)
)
continue
counts[feature_code] = used + 1
if segment.element_features.is_empty():
return
for required: String in _rules.get_required_features(segment.element_type):
if counts.has(required):
continue
var required_feature := _rules.get_feature(
segment.element_type,
required
)
var required_name := (
required_feature.display_name if required_feature != null else required
)
issues.append(
_issue(
ValidationIssue.Severity.WARNING,
"Pflichtfeature fehlt bei „%s“: %s."
% [code, required_name],
section_id,
segment.segment_id
)
)
var result := _rules.calculate_level(
segment.element_type,
code,
segment.element_features
)
if not result.missing_required.is_empty():
return
if not result.ignored_features.is_empty():
return
if result.level != segment.element_level:
issues.append(
_issue(
ValidationIssue.Severity.WARNING,
"Features ergeben bei „%s“ %s, gewählt ist %s."
% [
code,
ElementDefinition.level_label(result.level),
ElementDefinition.level_label(segment.element_level),
],
section_id,
segment.segment_id
)
)
## Features marked as once-per-program may only count in the first element
## that uses them. The technical rule additionally depends on categories and
## positions; the data flag is the simplified part that can be checked today.
func _collect_program_features(
segment: PathSegment,
section_id: String,
seen_once: Dictionary[String, String],
issues: Array[ValidationIssue]
) -> void:
for raw: String in segment.element_features:
var feature := _rules.get_feature(
segment.element_type,
raw.strip_edges()
)
if feature == null or not feature.once_per_program:
continue
var key := feature.code.to_lower()
if seen_once.has(key):
issues.append(
_issue(
ValidationIssue.Severity.WARNING,
"Feature „%s“ zählt nur einmal pro Programm (zuerst in Segment „%s“)."
% [feature.display_name, seen_once[key]],
section_id,
segment.segment_id
)
)
continue
seen_once[key] = segment.segment_id
static func count_severity(
issues: Array[ValidationIssue],
severity: int
) -> int:
var count := 0
for issue: ValidationIssue in issues:
if issue.severity == severity:
count += 1
return count
func _issue(
severity: ValidationIssue.Severity,
message: String,
section_id: String = "",
segment_id: String = ""
) -> ValidationIssue:
return ValidationIssue.new(severity, message, section_id, segment_id)

View file

@ -0,0 +1 @@
uid://cqkqfkkh0blq4

View file

@ -0,0 +1,37 @@
class_name ValidationIssue
extends RefCounted
## One finding from [RoutineValidator]. Messages are user-facing German; the
## section and segment IDs allow the UI to point at the source.
enum Severity {
INFO,
WARNING,
ERROR,
}
var severity: Severity = Severity.INFO
var message: String = ""
var section_id: String = ""
var segment_id: String = ""
func _init(
p_severity: Severity = Severity.INFO,
p_message: String = "",
p_section_id: String = "",
p_segment_id: String = ""
) -> void:
severity = p_severity
message = p_message
section_id = p_section_id
segment_id = p_segment_id
func severity_label() -> String:
match severity:
Severity.ERROR:
return "Fehler"
Severity.WARNING:
return "Warnung"
return "Hinweis"

View file

@ -0,0 +1 @@
uid://jct14gm67ytr

View file

@ -51,6 +51,7 @@ const EXPORTS_DIR := "user://exports"
const EXPORT_SHEET_SCENE := preload("res://scenes/export/export_sheet.tscn")
const ELEMENT_CATALOG_SCRIPT := preload("res://src/core/rules/element_catalog.gd")
const ELEMENT_LEVEL_RULES_SCRIPT := preload("res://src/core/rules/element_level_rules.gd")
const ROUTINE_VALIDATOR_SCRIPT := preload("res://src/core/rules/routine_validator.gd")
const FEATURE_MENU_RESET_ID := 1000000
const EXPORT_IMAGE_SIZE := Vector2i(2560, 1600)
const AUTOSAVE_PATH := "user://autosave.tres"
@ -116,6 +117,9 @@ const COMPACT_LAYOUT_WIDTH := 1280.0
@onready var element_features_button: Button = %ElementFeaturesButton
@onready var element_feature_hint: Label = %ElementFeatureHint
@onready var element_feature_menu: PopupMenu = %ElementFeatureMenu
@onready var validation_button: Button = %ValidationButton
@onready var validation_dialog: AcceptDialog = %ValidationDialog
@onready var validation_text: RichTextLabel = %ValidationText
@onready var element_duration_spin: SpinBox = %ElementDurationSpin
@onready var segment_label_dialog: ConfirmationDialog = %SegmentLabelDialog
@onready var segment_label_edit: LineEdit = %SegmentLabelEdit
@ -257,6 +261,7 @@ func _ready() -> void:
segment_label_edit.text_submitted.connect(_on_label_submitted)
element_button.pressed.connect(_open_element_dialog)
element_dialog.confirmed.connect(_on_element_confirmed)
validation_button.pressed.connect(open_validation_dialog)
element_type_option.item_selected.connect(_on_element_type_selected)
resized.connect(_apply_responsive_layout)
@ -423,6 +428,98 @@ func get_level_rules() -> ElementLevelRules:
return _level_rules
## Cross-checks all element segments against the catalog and level rules.
## Paths and section bookkeeping are validated by the model itself.
func validate_routine() -> Array[ValidationIssue]:
var validator: RoutineValidator = ROUTINE_VALIDATOR_SCRIPT.new(
_element_catalog,
_level_rules
)
return validator.validate(_routine)
## Opens the validation dialog with the current findings.
func open_validation_dialog() -> void:
var issues := validate_routine()
var errors := RoutineValidator.count_severity(
issues,
ValidationIssue.Severity.ERROR
)
var warnings := RoutineValidator.count_severity(
issues,
ValidationIssue.Severity.WARNING
)
var lines := PackedStringArray()
if issues.is_empty():
lines.append(
"[b]Keine Befunde.[/b] Alle Elemente passen zu Katalog und Level-Regeln."
)
else:
lines.append(
"[b]%d Fehler, %d Warnungen[/b]" % [errors, warnings]
)
lines.append("")
for issue: ValidationIssue in issues:
var color := "#ef4444" if issue.severity == ValidationIssue.Severity.ERROR else "#f59e0b"
lines.append(
"[color=%s]●[/color] [b]%s[/b]%s: %s"
% [
color,
issue.severity_label(),
_validation_location(issue),
_escape_bbcode(issue.message),
]
)
validation_text.text = "\n".join(lines)
var target := Vector2i(720, 520)
var viewport_size := Vector2i(get_viewport_rect().size)
if viewport_size.x > 0:
target.x = mini(target.x, viewport_size.x)
if viewport_size.y > 0:
target.y = mini(target.y, viewport_size.y)
validation_dialog.popup_centered(target)
func _validation_location(issue: ValidationIssue) -> String:
var parts := PackedStringArray()
if not issue.section_id.is_empty():
var section := _routine.get_section_by_id(issue.section_id)
parts.append(
"Abschnitt „%s“"
% (section.title if section != null else issue.section_id)
)
if not issue.segment_id.is_empty():
var segment := _find_routine_segment(issue.segment_id)
if segment != null and segment.is_element():
var label := segment.element_code.strip_edges()
if label.is_empty():
label = PathSegment.element_type_name(segment.element_type)
parts.append("Element „%s“" % label)
else:
parts.append(issue.segment_id)
if parts.is_empty():
return ""
return " (%s)" % " · ".join(parts)
func _find_routine_segment(segment_id: String) -> PathSegment:
if _routine == null or segment_id.is_empty():
return null
for section: RoutineSection in _routine.sections:
if section == null:
continue
var segment := section.get_segment_by_id(segment_id)
if segment != null:
return segment
return null
static func _escape_bbcode(text: String) -> String:
return text.replace("[", "[lb]")
func get_selected_element_features() -> PackedStringArray:
var segment := get_selected_segment()
if segment == null:

View file

@ -27,6 +27,9 @@ $GODOT --headless --path rinkplanner --script res://tests/run_rules_tests.gd
# Run ISU level-feature tests
$GODOT --headless --path rinkplanner --script res://tests/run_level_tests.gd
# Run routine element-validation tests
$GODOT --headless --path rinkplanner --script res://tests/run_validation_tests.gd
# Run canvas transform/geometry tests
$GODOT --headless --path rinkplanner --script res://tests/run_canvas_tests.gd

View file

@ -89,6 +89,8 @@ func _capture() -> void:
PackedStringArray(["difficult_variation", "difficult_exit"])
)
controller.element_button.pressed.emit()
elif args.size() > 3 and args[3] == "validate":
controller.open_validation_dialog()
elif args.size() > 3 and args[3] == "spin":
var elapsed := 0.0
for segment: PathSegment in controller.get_active_section().segments:

View file

@ -0,0 +1,356 @@
extends SceneTree
## Headless tests for routine element validation.
##
## Run with:
## godot --headless --path rinkplanner --script res://tests/run_validation_tests.gd
const ElementCatalogScript := preload("res://src/core/rules/element_catalog.gd")
const ElementLevelRulesScript := preload("res://src/core/rules/element_level_rules.gd")
const RoutineValidatorScript := preload("res://src/core/rules/routine_validator.gd")
const ValidationIssueScript := preload("res://src/core/rules/validation_issue.gd")
const RoutineModel := preload("res://src/core/model/routine.gd")
const RoutineSectionModel := preload("res://src/core/model/routine_section.gd")
const PathSegmentModel := preload("res://src/core/model/path_segment.gd")
var _assertions: int = 0
var _failures: PackedStringArray = PackedStringArray()
var _catalog: ElementCatalog
var _rules: ElementLevelRules
var _validator: RoutineValidator
func _init() -> void:
_catalog = ElementCatalogScript.load_default()
_rules = ElementLevelRulesScript.load_default()
_validator = RoutineValidatorScript.new(_catalog, _rules)
_test_clean_routine()
_test_unknown_code()
_test_type_mismatch()
_test_unavailable_level()
_test_jump_level_and_features()
_test_fixed_level()
_test_missing_code()
_test_feature_selection()
_test_level_mismatch()
_test_program_once_features()
_test_missing_rules()
_finish()
func _test_clean_routine() -> void:
var routine := _make_routine()
var section := routine.sections[0]
_add_marker(
section,
"spin",
PathSegment.ElementType.SPIN,
"CCoSp",
4,
PackedStringArray(
[
"difficult_variation",
"difficult_variation",
"difficult_exit",
"change_of_edge",
]
)
)
_add_marker(
section,
"sequence",
PathSegment.ElementType.SEQUENCE,
"StSq",
4,
PackedStringArray(
[
"variety_of_turns",
"both_rotations",
"body_movements",
"turn_combinations",
]
)
)
var issues := _validator.validate(routine)
_check(issues.is_empty(), "a consistent routine has no findings (%s)" % _messages(issues))
func _test_unknown_code() -> void:
var issues := _validate_one(
PathSegment.ElementType.SPIN,
"3X",
0,
PackedStringArray()
)
_check(_count(issues, ValidationIssueScript.Severity.ERROR) == 1, "unknown code is an error")
_check(_has_message(issues, "nicht im Katalog"), "unknown code message")
func _test_type_mismatch() -> void:
var issues := _validate_one(
PathSegment.ElementType.SPIN,
"3Lz",
0,
PackedStringArray()
)
_check(_count(issues, ValidationIssueScript.Severity.ERROR) == 1, "type mismatch is an error")
_check(_has_message(issues, "gehört zu Sprung"), "type mismatch message")
func _test_unavailable_level() -> void:
var routine := _make_routine()
var segment := _add_marker(
routine.sections[0],
"spin",
PathSegment.ElementType.SPIN,
"CCoSp",
0,
PackedStringArray()
)
segment.element_level = 7
var issues := _validator.validate(routine)
_check(
_count(issues, ValidationIssueScript.Severity.ERROR) == 1,
"an unavailable level is an error"
)
_check(_has_message(issues, "nicht verfügbar"), "unavailable level message")
func _test_jump_level_and_features() -> void:
var routine := _make_routine()
var segment := _add_marker(
routine.sections[0],
"jump",
PathSegment.ElementType.JUMP,
"3Lz",
2,
PackedStringArray(["difficult_exit"])
)
var issues := _validator.validate(routine)
_check(
_count(issues, ValidationIssueScript.Severity.WARNING) == 2,
"jump level and features are two warnings"
)
_check(_has_message(issues, "nicht levelbar"), "jump level warning")
_check(_has_message(issues, "Level-Features"), "jump feature warning")
_check(segment.element_level == 2, "the validator does not mutate the segment")
func _test_fixed_level() -> void:
var issues := _validate_one(
PathSegment.ElementType.SEQUENCE,
"ChSq",
2,
PackedStringArray()
)
_check(
_count(issues, ValidationIssueScript.Severity.ERROR) == 1,
"a wrong fixed level is an error"
)
_check(_has_message(issues, "fest"), "fixed level message")
var valid := _validate_one(
PathSegment.ElementType.SEQUENCE,
"ChSq",
1,
PackedStringArray()
)
_check(valid.is_empty(), "ChSq at Level 1 is valid")
func _test_missing_code() -> void:
var issues := _validate_one(
PathSegment.ElementType.SPIN,
"",
0,
PackedStringArray()
)
_check(
_count(issues, ValidationIssueScript.Severity.WARNING) == 1,
"a missing code is a warning"
)
_check(_has_message(issues, "ohne Kürzel"), "missing code message")
func _test_feature_selection() -> void:
var unknown := _validate_one(
PathSegment.ElementType.SPIN,
"CCoSp",
0,
PackedStringArray(["nope"])
)
_check(
_count(unknown, ValidationIssueScript.Severity.ERROR) == 1,
"an unknown feature is an error"
)
_check(_has_message(unknown, "Unbekanntes Feature"), "unknown feature message")
var too_many := _validate_one(
PathSegment.ElementType.SPIN,
"CCoSp",
0,
PackedStringArray(
["difficult_variation", "difficult_variation", "difficult_variation"]
)
)
_check(
_count(too_many, ValidationIssueScript.Severity.ERROR) == 1,
"too many difficult variations is an error"
)
_check(_has_message(too_many, "zu oft"), "over-limit feature message")
var missing := _validate_one(
PathSegment.ElementType.SEQUENCE,
"StSq",
1,
PackedStringArray(["body_movements"])
)
_check(
_count(missing, ValidationIssueScript.Severity.WARNING) == 1,
"a missing compulsory sequence feature is a warning"
)
_check(_has_message(missing, "Pflichtfeature fehlt"), "compulsory feature message")
func _test_level_mismatch() -> void:
var issues := _validate_one(
PathSegment.ElementType.SPIN,
"CCoSp",
4,
PackedStringArray(["difficult_variation", "difficult_exit"])
)
_check(
_count(issues, ValidationIssueScript.Severity.WARNING) == 1,
"a feature/level mismatch is a warning"
)
_check(_has_message(issues, "Features ergeben"), "level mismatch message")
func _test_program_once_features() -> void:
var routine := _make_routine()
var section := routine.sections[0]
_add_marker(
section,
"spin-a",
PathSegment.ElementType.SPIN,
"CCoSp",
1,
PackedStringArray(["difficult_exit"])
)
_add_marker(
section,
"spin-b",
PathSegment.ElementType.SPIN,
"CCoSp",
1,
PackedStringArray(["difficult_exit"])
)
var issues := _validator.validate(routine)
_check(
_count(issues, ValidationIssueScript.Severity.WARNING) == 1,
"repeated once-per-program features warn once per repeated occurrence"
)
_check(_has_message(issues, "nur einmal pro Programm"), "once-per-program message")
_check(
_has_message(issues, "zuerst in Segment „spin-a“"),
"once-per-program message names the first segment"
)
func _test_missing_rules() -> void:
var broken := RoutineValidatorScript.new(null, null)
var routine := _make_routine()
_add_marker(
routine.sections[0],
"spin",
PathSegment.ElementType.SPIN,
"CCoSp",
0,
PackedStringArray()
)
var issues := broken.validate(routine)
_check(
_count(issues, ValidationIssueScript.Severity.ERROR) == 1,
"a missing rule set is an error"
)
func _validate_one(
type: PathSegment.ElementType,
code: String,
level: int,
features: PackedStringArray
) -> Array[ValidationIssue]:
var routine := _make_routine()
_add_marker(routine.sections[0], "segment", type, code, level, features)
return _validator.validate(routine)
func _make_routine() -> Routine:
var routine: Routine = RoutineModel.new()
routine.routine_id = "validation-test"
routine.title = "Validation"
var section: RoutineSection = RoutineSectionModel.new()
section.section_id = "section-001"
section.title = "Abschnitt 1"
section.sequence_order = 0
var sections: Array[RoutineSection] = [section]
routine.sections = sections
return routine
func _add_marker(
section: RoutineSection,
segment_id: String,
type: PathSegment.ElementType,
code: String,
level: int,
features: PackedStringArray
) -> PathSegment:
var segment: PathSegment = PathSegmentModel.new()
segment.segment_id = segment_id
var curve := Curve2D.new()
curve.add_point(Vector2.ZERO)
segment.curve = curve
segment.set_element(type, code, level)
segment.set_element_features(features)
section.segments.append(segment)
return segment
func _count(issues: Array[ValidationIssue], severity: int) -> int:
return RoutineValidatorScript.count_severity(issues, severity)
func _has_message(issues: Array[ValidationIssue], fragment: String) -> bool:
for issue: ValidationIssue in issues:
if issue.message.contains(fragment):
return true
return false
func _messages(issues: Array[ValidationIssue]) -> String:
var parts := PackedStringArray()
for issue: ValidationIssue in issues:
parts.append(issue.message)
return "; ".join(parts)
func _check(condition: bool, message: String) -> void:
_assertions += 1
if not condition:
_failures.append(message)
func _finish() -> void:
if _failures.is_empty():
print("PASS: %d assertions" % _assertions)
quit(0)
return
for failure: String in _failures:
printerr("FAIL: %s" % failure)
printerr("%d of %d assertions failed" % [_failures.size(), _assertions])
quit(1)

View file

@ -0,0 +1 @@
uid://bdfvwb07656pb

View file

@ -1103,6 +1103,43 @@ func _run() -> void:
)
DirAccess.remove_absolute(save_as_path)
# Validation dialog.
controller.new_routine()
controller.add_element_marker(
Vector2(0.0, 0.0),
PathSegment.ElementType.SPIN,
"3X",
0
)
var issues := controller.validate_routine()
_check(issues.size() == 1, "validation reports one finding")
_check(
issues.size() > 0
and issues[0].severity == ValidationIssue.Severity.ERROR,
"an unknown element code is reported as an error"
)
controller.message_dialog.hide()
controller.open_validation_dialog()
_check(controller.validation_dialog.visible, "validation button opens the dialog")
_check(
controller.validation_text.text.contains("nicht im Katalog"),
"validation dialog shows the catalog finding"
)
controller.validation_dialog.hide()
controller.new_routine()
controller.add_element_marker(
Vector2(0.0, 0.0),
PathSegment.ElementType.SPIN,
"CCoSp",
4
)
var clean_issues := controller.validate_routine()
_check(
clean_issues.is_empty(),
"a consistent routine has no validation findings"
)
scene.queue_free()
await process_frame
_finish()