import Testing
@testable import PureXML
@Suite("XSD nested definitions may not be named (localSimpleType / attributeGroup ref)")
struct SchemaNestedDefinitionTests {
private let xsd = "xmlns:xs=\"http://www.w3.org/2001/XMLSchema\""
private func compiles(_ body: String) -> Bool {
(try? PureXML.Schema.Document("\(body)")) != nil
}
@Test("A nested simpleType with a name is rejected")
func test_nestedNamedSimpleTypeRejected() {
#expect(!compiles(
""
+ ""
+ "",
))
}
@Test("A nested attributeGroup definition with a name is rejected")
func test_nestedNamedAttributeGroupRejected() {
#expect(!compiles(
""
+ ""
+ "",
))
}
@Test("A nested anonymous simpleType compiles")
func test_nestedAnonymousSimpleTypeAccepted() {
#expect(compiles(
"",
))
#expect(compiles(
"",
))
}
@Test("A nested attributeGroup reference and top-level named definitions compile")
func test_refAndTopLevelAccepted() {
#expect(compiles(
""
+ "",
))
#expect(compiles(""))
}
}