     assert.equal r['listtest']['item'][0]['subitem'][3], 'Foo(4)'
     assert.equal r['listtest']['item'][1], 'Qux.'
     assert.equal r['listtest']['item'][2], 'Quux.')
-    
+
   'test parse with explicitCharkey': skeleton({explicitCharkey: true}, (r) ->
     assert.equal r['chartest']['@']['desc'], 'Test for CHARs'
     assert.equal r['chartest']['#'], 'Character data here!'

    assert.equal r['arraytest'][0]['item'][0]['subitem'][0], 'Baz.'
    assert.equal r['arraytest'][0]['item'][1]['subitem'][0], 'Foo.'
    assert.equal r['arraytest'][0]['item'][1]['subitem'][1], 'Bar.')

assert = require 'assert'
path = require 'path'

fileName = path.join __dirname, '/fixtures/sample.xml'

skeleton = (options, checks) ->
  (test) ->
    xmlString = options?.__xmlString
    delete options?.__xmlString
    x2js = new xml2js.Parser options
    x2js.addListener 'end', (r) ->
      checks r
      test.finish()
    if not xmlString
      fs.readFile fileName, (err, data) ->
        x2js.parseString data
