var should = require('should');

var parse = process.env.L20N_COV
  ? require('../../build/cov/lib/l20n/parser').parse.bind(null, null)
  : require('../../lib/l20n/parser').parse.bind(null,null);

describe('Example', function() {
  it('string value', function() {
    var ast = parse("id = string");
    should.not.exist(ast['id'].type);
    ast['id'].should.equal('string');
  });
  it('basic errors', function() {
    var strings = [
      "",
      "id",
      "id ",
      "id =",
      "+id",
      "=id",
    ];

    for (var i in strings) {
      var ast = parse(strings[i]);
      Object.keys(ast).length.should.equal(0);
    }
  });
  it('basic attributes', function() {
    var ast = parse("id.attr1 = foo");
    ast['id']['attr1'].should.equal('foo');
  });
  it('plural macro', function() {
    var ast = parse("id = {[ plural(m) ]} \nid[one] = foo");
    ast['id']['_'].should.be.an.instanceOf(Object);
    ast['id']['_']['one'].should.equal('foo');
    ast['id']['_index'].length.should.equal(2);
    ast['id']['_index'][0].should.equal('plural');
    ast['id']['_index'][1].should.equal('m');
  });
  it('plural macro errors', function() {
    var strings = [
      'id = {[ plural(m) ] \nid[one] = foo',
      'id = {[ plural(m) \nid[one] = foo',
      'id = { plural(m) ]} \nid[one] = foo',
      'id = plural(m) ]} \nid[one] = foo',
      'id = {[ m ]} \nid[one] = foo',
      'id = {[ plural ]} \nid[one] = foo',
      'id = {[ plural(m ]} \nid[one] = foo',
      'id = {[ pluralm) ]} \nid[one] = foo',

    ];
    var errorsThrown = 0;

    for (var i in strings) {
      try {
        parse(strings[i]);
      } catch (e) {
        errorsThrown += 1;
      }
    } 
    errorsThrown.should.equal(strings.length);
  });
  it('comment', function() {
    var ast = parse('#test');
    Object.keys(ast).length.should.equal(0);
  });
  it('comment errors', function() {
    var strings = [
      ' # foo',
      ' ## foo',
      'f# foo',
    ];
    for (var i in strings) {
      var ast = parse(strings[i]);
      Object.keys(ast).length.should.equal(0);
    }  
  });
});

@@ -1,18 +1,18 @@
 var 
-should
+assert
  = requi
@@ -19,22 +19,109 @@
 re('
-should');%0A%0Avar
+assert');%0Avar parse;%0A%0Atry %7B%0A  parse = navigator.mozL10n.debug.parse.bind(null, null);%0A%7D catch (e) %7B%0A 
  par
@@ -146,16 +146,18 @@
 20N_COV%0A
+  
   ? requ
@@ -218,16 +218,18 @@
 , null)%0A
+  
   : requ
@@ -279,16 +279,18 @@
 l,null);
+%0A%7D
 %0A%0Adescri
@@ -297,15 +297,19 @@
 be('
-Example
+L10n Parser
 ', f
@@ -398,69 +398,38 @@
     
-should.not.exist(ast%5B'id'%5D.type);%0A    ast%5B'id'%5D.should.equal(
+assert.strictEqual(ast%5B'id'%5D, 
 'str
@@ -640,32 +640,45 @@
 ings%5Bi%5D);%0A      
+assert.equal(
 Object.keys(ast)
@@ -680,38 +680,26 @@
 (ast).length
-.should.equal(
+, 
 0);%0A    %7D%0A  
@@ -775,32 +775,45 @@
 r1 = foo%22);%0A    
+assert.equal(
 ast%5B'id'%5D%5B'attr1
@@ -814,30 +814,18 @@
 'attr1'%5D
-.should.equal(
+, 
 'foo');%0A
@@ -925,24 +925,34 @@
  foo%22);%0A    
+assert.ok(
 ast%5B'id'%5D%5B'_
@@ -957,30 +957,17 @@
 '_'%5D
-.should.be.an.
+ 
 instance
 Of(O
@@ -966,11 +966,11 @@
 ance
-Of(
+of 
 Obje
@@ -974,24 +974,37 @@
 bject);%0A    
+assert.equal(
 ast%5B'id'%5D%5B'_
@@ -1012,30 +1012,18 @@
 %5D%5B'one'%5D
-.should.equal(
+, 
 'foo');%0A
@@ -1018,32 +1018,45 @@
 '%5D, 'foo');%0A    
+assert.equal(
 ast%5B'id'%5D%5B'_inde
@@ -1069,30 +1069,31 @@
 ngth
-.should.equal(2);%0A    
+, 2);%0A    assert.equal(
 ast%5B
@@ -1110,30 +1110,18 @@
 dex'%5D%5B0%5D
-.should.equal(
+, 
 'plural'
@@ -1127,16 +1127,29 @@
 ');%0A    
+assert.equal(
 ast%5B'id'
@@ -1162,30 +1162,18 @@
 dex'%5D%5B1%5D
-.should.equal(
+, 
 'm');%0A  
@@ -1757,34 +1757,35 @@
     
-errorsThrown.should.equal(
+assert.equal(errorsThrown, 
 stri
@@ -1862,24 +1862,37 @@
 test');%0A    
+assert.equal(
 Object.keys(
@@ -1898,38 +1898,26 @@
 (ast).length
-.should.equal(
+, 
 0);%0A  %7D);%0A  
@@ -2096,16 +2096,29 @@
 ;%0A      
+assert.equal(
 Object.k
@@ -2136,22 +2136,10 @@
 ngth
-.should.equal(
+, 
 0);%0A

update parser tests to work with gaia tests