Sfoglia il codice sorgente

Fix test results comparasion.

Vladislav Folts 11 anni fa
parent
commit
404eef21d5
3 ha cambiato i file con 26 aggiunte e 14 eliminazioni
  1. 0 14
      test/expected/nodejs/export.js
  2. 10 0
      test/expected/nodejs/export/m.js
  3. 16 0
      test/test_compile.js

+ 0 - 14
test/expected/nodejs/export.js

@@ -1,14 +0,0 @@
-var m = function (){
-var ci = 123;
-var p = null;
-var vi = 0;
-
-function p1(){
-}
-return {
-	ci: ci,
-	p: function(){return p;},
-	vi: function(){return vi;},
-	p1: p1
-}
-}();

+ 10 - 0
test/expected/nodejs/export/m.js

@@ -0,0 +1,10 @@
+var ci = 123;
+var p = null;
+var vi = 0;
+
+function p1(){
+}
+exports.ci = ci
+exports.p = function(){return p;}
+exports.vi = function(){return vi;}
+exports.p1 = p1

+ 16 - 0
test/test_compile.js

@@ -46,6 +46,8 @@ function compileNodejs(src, dirs){
                     );
     if (errors)
         throw new Test.TestError(errors);
+
+    cmpDirs(path.join(dirs.expected, subdir), outDir);
 }
 
 function expectOk(src, dirs){
@@ -100,6 +102,20 @@ function rmTree(root){
     fs.rmdirSync(root);
 }
 
+function cmpDirs(expected, result){
+    fs.readdirSync(expected).forEach(function(file){
+        var expectedFile = path.join(expected, file);
+        var resultFile = path.join(result, file);
+        var expectedContent = fs.readFileSync(expectedFile, "utf8");
+        var resultContent = fs.readFileSync(resultFile, "utf8");
+        if (   normalizeLineEndings(expectedContent)
+            != normalizeLineEndings(resultContent))
+            throw new Test.TestError(
+                "Files '" + expectedFile + "' and '"
+                + resultFile + "' do not match.");
+    });
+}
+
 function main(){
     if (process.argv.length > 2){
         var tests = {};