test(shim): add C4:ParseXml - #62
Conversation
The shim had no C4:ParseXml, so nothing that parses XML under test could be exercised: a thermostatV2 driver receives its preset list as XML whose per-preset field values ride as escaped XML inside an attribute, and a test could only stub around it. The shim now carries a small parser that returns what Director's does, a node with Name, Attributes (name -> value) and ordered ChildNodes. Attribute values are entity-unescaped so nested XML carried in an attribute is re-parsable; because markup inside an attribute is always escaped, scanning to the first '>' is safe. Prolog and comments are dropped. Same-name nesting closes at the matching depth. Both C4:ParseXml(xml) and C4.ParseXml(C4, xml) are accepted. No mixed content, CDATA or namespaces. Fourteen assertions cover the preset-list shape, attribute quoting and entities, nesting, the two calling styles and the nil cases.
|
Reviewed at The port itself is clean. I diffed the 86-line implementation against the copy in Four things worth a look before this lands. 1.
|
|
CI on I have not clicked it. Approving a workflow run executes an outside contributor's code on the repo's runners, which is a maintainer gate, so it stays Derek's. Everything below was run locally instead, at The four review items are all closedI re-ran the exact reproductions from my earlier comment against both 1. The guard is scoped the way I would want: 2. The dot call. The dead guard is gone and the replacement tests 3. Unescaped The header comment was also corrected, it now describes the scanner instead of claiming the old scan was safe. 4. Numeric character references. Byte counts, since this is the whole point of the item: Out of range, zero and surrogate halves degrade to the literal rather than raising, which is the forgiving behaviour the rest of the parser has. The new assertions are not vacuousItem 2 last time was a test that passed with the code deleted, so I mutation-tested the new ones rather than trusting the count. Each mutant reverts exactly one fix:
All four are caught. Baseline is 223 passed, 0 failed under Scope of what I ran: the suite in place under Three small things, none blocking
Comments, CDATA, the prolog, same-name nesting and quotes nested inside the other quote style all behave sanely, including the cases the rewrite could plausibly have regressed. An unterminated attribute quote returns SequencingMy earlier note that this file is byte-identical to the copy in This is a comment, not an approval. The verdict and the merge are Derek's, and the workflow approval is his too. |
The shim had no C4:ParseXml, so nothing that parses XML under test could be exercised: a thermostatV2 driver receives its preset list as XML whose per-preset field values ride as escaped XML inside an attribute, and a test could only stub around it.
The shim now carries a small parser that returns what Director's does, a node with Name, Attributes (name -> value) and ordered ChildNodes. Attribute values are entity-unescaped so nested XML carried in an attribute is re-parsable; because markup inside an attribute is always escaped, scanning to the first '>' is safe. Prolog and comments are dropped. Same-name nesting closes at the matching depth. Both C4:ParseXml(xml) and C4.ParseXml(C4, xml) are accepted. No mixed content, CDATA or namespaces.
Fourteen assertions cover the preset-list shape, attribute quoting and entities, nesting, the two calling styles and the nil cases.