@testable import PureYAML import Testing @Suite("Undefined tag handles are parse errors") struct TagHandleDiagnosticTests { @Test("An undeclared named tag handle is rejected at parse time") func test_undeclaredHandleRejected() { // The ported engine is strict: a tag shorthand whose handle was never declared by a // `%TAG` directive fails the parse, so the old permissive-parse scanner pre-pass // (`Scanner.tagHandleIssues`) has no successor and no gap to fill. #expect(throws: (any Error).self) { _ = try PureYAML.parse("key: !foo!bar\n") } } @Test("The validation report carries the undefined handle as a parse diagnostic") func test_reportCarriesUndefinedHandle() { let report = PureYAML.validationReport("key: !foo!bar\n") let parseErrors = report.diagnostics.filter { $0.kind == .parse && $0.severity == .error } #expect(parseErrors.count == 1) #expect(parseErrors.first?.reason.contains("undefined tag handle") == true) } }