import Testing
@testable import PureXML
@Suite("XSD Particle Restriction over substitution groups")
struct XSDParticleSubstitutionRestrictionTests {
private let xsNamespace = "xmlns:xs=\"http://www.w3.org/2001/XMLSchema\""
@Test("A restriction may not swap an element ref for a substitution-group member")
func test_substitutionMemberSwapRejected() {
// elemZ026: NameAndTypeOK clause 1 pairs the DECLARED references, and requires
// the same name and target namespace; substitution has no allowance in Elt:Elt.
// Swapping the head ref for a member ref names a different declaration.
let schema = """
"""
#expect(throws: (any Error).self) {
try PureXML.Schema.Document(schema)
}
}
@Test("A restriction that repeats the declared ref and narrows occurrence compiles")
func test_sameRefNarrowedOccurrenceCompiles() throws {
// The positive control for the declared-reference check: the same head ref with
// a narrowed range is the spec's idiom, and the substitution expansion behind
// both sides must not disturb it.
let schema = """
"""
_ = try PureXML.Schema.Document(schema)
}
}