import Testing @testable import PureXML /// XSD 1.0 cos-particle-restrict NameAndTypeOK.2.2 (#158): when a complexContent /// restriction narrows an element, the element's type must be validly derived from /// the base element's type EXCLUDING extension (by restriction only). A type derived /// from the base type by extension is not a valid restriction (corpus particlesIj008). @Suite("XSD NameAndTypeOK restriction-only type derivation (#158)") struct SchemaParticleTypeRestrictionTests { private func compiles(_ derivedC1Type: String) -> Bool { let schema = """ """ return (try? PureXML.Schema.Document(schema)) != nil } @Test("restricting an element to a type derived by EXTENSION is rejected (particlesIj008)") func test_extensionDerivedTypeRejected() { #expect(!compiles("barExt")) } @Test("restricting an element to a type derived by RESTRICTION is accepted") func test_restrictionDerivedTypeAccepted() { #expect(compiles("barRes")) } @Test("restricting an element to the same type is accepted") func test_sameTypeAccepted() { #expect(compiles("foo")) } }