0

I have project compile js to js.

I wrote filename.js and compile to filename.out.js, and check manually filename.out.js, next time when I modify my compiler, I hope the output does not changed, if it changed show the diff.

function testFile(filename){
  var code = fs.readFileSync(filename + '.js', 'utf-8');
  var expect = fs.readFileSync(filename + '.out.js', 'utf-8');
  assert.equal(pro.compile(code), expect);
}

['groups', 'steps', 'serial', 'parallel'].forEach(testFile);

Every time it said AssertionError, but should not be, and it can not give diffrent.

Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265
guilin 桂林
  • 17,050
  • 29
  • 92
  • 146
  • 1
    Do you know that they are identical? Could there be a difference in whitespace? if you dump out some props like: console.log(pro.compile(code).length); and console.log(expect.length); are they the same? – Geoff Chappell May 18 '11 at 12:42
  • thank you for log length, save my life. 1 size bigger, strange. trim() then they are same. – guilin 桂林 May 18 '11 at 13:08
  • Maybe a white space at the end of the file. Or the file is encoded with BOM. – tozlu Mar 05 '14 at 03:17

1 Answers1

0

thank you for log length, save my life. 1 size bigger, strange. trim() then they are same

Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265