anchor.diff:      onFatalError: (index, _) => fail('Fatal error at $index.'),
     );
     reader.parse(input);
  -
     expect(nodes, isEmpty, reason: 'All nodes should be processed.');
     expect(stack, isEmpty, reason: 'All elements should be closed.');
  -}
  +  expect(state, 2, reason: 'Reader not completed.');
  +}
  
positive.code: }
  
  void assertReaderInvariants(String input, XmlNode node) {
    final includedTypes = new Set.from([
      XmlNodeType.ELEMENT,
      XmlNodeType.TEXT,
      XmlNodeType.CDATA,
      XmlNodeType.PROCESSING,
    ]);
    final nodes = node.descendants
        .where((node) => includedTypes.contains(node.nodeType))
        .toList(growable: true);
    final stack = <XmlName>[];
    final reader = new XmlReader(
      onStartElement: (name, attributes) {
        expect(nodes, isNotEmpty);
        XmlNode node = nodes.removeAt(0);
        expect(node.nodeType, XmlNodeType.ELEMENT,
            reason: 'Node type should be an ELEMENT.');
  
negative.code:       expect(text, node.text, reason: 'Text data should match.');
      },
      onProcessingInstruction: (target, text) {
        expect(state, 1, reason: 'Reader not started');
        expect(nodes, isNotEmpty, reason: 'Missing element in node list.');
        XmlNode node = nodes.removeAt(0);
        expect(node.nodeType, XmlNodeType.PROCESSING,
  