import Testing @testable import PureXML @Suite("XSLT match-pattern caching") struct XSLTMatchCacheTests { /// Guards the shape #112 optimized: many nodes against several templates, /// where each match pattern must be compiled and evaluated once per /// transform (not once per node) and selection must stay correct. @Test("A multi-template transform over hundreds of nodes selects correctly") func test_multiTemplateShape() throws { let rows = (1 ... 300).map { index in index.isMultiple(of: 2) ? "\(index)" : "\(index)" }.joined() let source = "\(rows)" let stylesheet = """ E O """ let output = try PureXML.XSLT.transform(stylesheet: stylesheet, source: source) #expect(output.count == 300) #expect(output.count(where: { $0 == "E" }) == 150) #expect(output.count(where: { $0 == "O" }) == 150) // Alternation is preserved (selection by pattern, not by order accident). #expect(output.hasPrefix("OEOE")) } }