TokenIterator.test.js 646 B

1234567891011121314151617
  1. var TokenIterator = require("../lib/TokenIterator");
  2. var Token = require("../lib/Token");
  3. var StringSource = require("../lib/StringSource");
  4. exports.canCreateSourceRangeToIteratorBeyondEnd = function(test) {
  5. var source = function(startIndex, endIndex) {
  6. return new StringSource("blah").range(startIndex, endIndex);
  7. };
  8. var startIterator = new TokenIterator([
  9. new Token("identifier", "blah", source(0, 4)),
  10. new Token("end", null, source(4, 4))
  11. ]);
  12. var endIterator = startIterator.tail().tail();
  13. var range = startIterator.to(endIterator);
  14. test.deepEqual(source(0, 4), range);
  15. test.done();
  16. };