@testable import PureXML
import Testing
/// `block="substitution"` on a substitution-group head forbids any member from
/// standing in for it, regardless of the member's type derivation (#147, XSTS
/// disallowedSubst set). Only type-derivation blocks (`extension`/`restriction`)
/// had been applied, so a same-type member still substituted under a
/// substitution block.
@Suite("Substitution-group block")
struct SchemaSubstitutionBlockTests {
private func schema(headBlock: String) throws -> PureXML.Schema.Document {
let attribute = headBlock.isEmpty ? "" : " block=\"\(headBlock)\""
return try PureXML.Schema.Document("""
""")
}
private let withMember = #"ab"#
private let headsOnly = #"ab"#
@Test("block='substitution' on the head rejects a substituting member")
func test_substitutionBlocked() throws {
#expect(try !schema(headBlock: "substitution").validate(withMember).isEmpty)
// Plain heads are still fine.
#expect(try schema(headBlock: "substitution").validate(headsOnly).isEmpty)
}
@Test("without a substitution block the member may substitute")
func test_memberAllowedWithoutBlock() throws {
#expect(try schema(headBlock: "").validate(withMember).isEmpty)
}
}