QUnit.module('templateParser', {
  before: function() {
    this.parse = function() {
      this.result = this.parser.parse(this.source);
    };
  },
  beforeEach: function() {
    this.parser = smodules.templateParser();
    this.source = '';
    this.result = null;
  },
});

QUnit.test('for block - only value part in dummy variable', function(assert) {
  this.source =
    '{ for $item in $items }' +
    '<p>{ $item | h }</p>' +
    '{ /for }';
  this.parse();

  var block  = this.result[0];

  assert.strictEqual(block.type, 'for');
  assert.strictEqual(typeof block.header.k, 'undefined');
  assert.strictEqual(block.header.v, 'item');
  assert.strictEqual(block.header.array.join('.'), 'items');
  assert.strictEqual(block.blocks.length, 3);
});

QUnit.test('for block - use index in dummy variable', function(assert) {
  this.source =
    '{ for $idx, $item in $items }' +
    '<p>{ $item | h }</p>' +
    '{ /for }';
  this.parse();

  var block  = this.result[0];

  assert.strictEqual(block.type, 'for');
  assert.strictEqual(block.header.k, 'idx');
  assert.strictEqual(block.header.v, 'item');
  assert.strictEqual(block.header.array.join('.'), 'items');
  assert.strictEqual(block.blocks.length, 3);
});

@@ -1193,28 +1193,369 @@
 lock.blocks.length, 3);%0A%7D);%0A
+%0AQUnit.test('for block - variable chain in haystack', function(assert) %7B%0A  this.source =%0A    '%7B for $item in $items.key1.key2 %7D' +%0A    '%3Cp%3E%7B $item %7C h %7D%3C/p%3E' +%0A    '%7B /for %7D';%0A  this.parse();%0A%0A  var block  = this.result%5B0%5D;%0A%0A  assert.strictEqual(block.type, 'for');%0A  assert.strictEqual(block.header.array.join('.'), 'items.key1.key2');%0A%7D);%0A

add test for for block