@testable import PureXML
import Testing
@Suite("Schematron schema- and pattern-level let")
struct SchematronScopedLetTests {
private func validate(_ schema: String, _ xml: String) throws -> [PureXML.Validation.ValidationError] {
try PureXML.Validation.Schematron(schema: schema).validate(xml)
}
@Test("A schema-level let is available to every rule")
func test_schemaLet() throws {
let schema = """
over the schema limit
"""
#expect(try validate(schema, "5").isEmpty)
#expect(try !validate(schema, "50").isEmpty)
}
@Test("A pattern-level let is available to the pattern's rules")
func test_patternLet() throws {
let schema = """
flag must be yes
"""
#expect(try validate(schema, "yes").isEmpty)
#expect(try !validate(schema, "no").isEmpty)
}
@Test("A rule-level let overrides a wider-scope let of the same name")
func test_ruleOverridesSchema() throws {
let schema = """
over the rule limit
"""
// The rule's limit (10) wins over the schema's (100).
#expect(try !validate(schema, "50").isEmpty)
}
}