import Testing @testable import PureXML /// `block` on an element declaration forbids substituting a type derived from /// the declared type by a listed method via `xsi:type`, distinct from `block` /// on the type itself (#147, XSTS elemT set). The element-level block was parsed /// but never enforced, so blocked substitutions were wrongly accepted. @Suite("Element-level block on xsi:type substitution") struct SchemaElementBlockTests { private func schema(block: String) throws -> PureXML.Schema.Document { let attribute = block.isEmpty ? "" : " block=\"\(block)\"" return try PureXML.Schema.Document(""" """) } private let instance = #"x"# @Test("block='restriction' on an element rejects a restriction xsi:type") func test_elementBlockRejectsRestriction() throws { #expect(try !schema(block: "restriction").validate(instance).isEmpty) } @Test("an element without block accepts the same restriction xsi:type") func test_noBlockAcceptsRestriction() throws { #expect(try schema(block: "").validate(instance).isEmpty) } @Test("block='extension' does not block a restriction substitution") func test_unrelatedBlockDoesNotReject() throws { #expect(try schema(block: "extension").validate(instance).isEmpty) } }