[Pkg-javascript-commits] [node-browser-pack] 82/141: fixing source map tests to take maps for prelude into account

Bastien Roucariès rouca at moszumanska.debian.org
Thu May 4 10:23:27 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-browser-pack.

commit c1ad913d638bbc6f180a67685d2525da164fa01e
Author: Thorsten Lorenz <thlorenz at gmx.de>
Date:   Tue Dec 31 21:51:39 2013 -0500

    fixing source map tests to take maps for prelude into account
---
 test/source-maps-existing.js |  3 +++
 test/source-maps.js          | 28 +++++++++++++++++++---------
 2 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/test/source-maps-existing.js b/test/source-maps-existing.js
index c6f2ae0..4c092c2 100644
--- a/test/source-maps-existing.js
+++ b/test/source-maps-existing.js
@@ -28,6 +28,9 @@ test('pack one file with source file field and existing sourcemap', function (t)
 
         var remainingMaps = src.match(convert.commentRegex);
 
+        // remove map for _prelude.js
+        mappings.shift();
+
         var fstMap = mappings[0];
         var fstFooMap = fooMappings[0];
         var lstMap = mappings.pop();
diff --git a/test/source-maps.js b/test/source-maps.js
index c15c7cb..74cfe75 100644
--- a/test/source-maps.js
+++ b/test/source-maps.js
@@ -1,13 +1,23 @@
 var test = require('tape');
 var pack = require('../');
+var path = require('path');
 
 function decode(base64) {
     return new Buffer(base64, 'base64').toString();
 } 
 
+function unmountPrelude(sources) {
+  return sources.map(function (x) {
+    var basename = path.basename(x);
+    return basename === '_prelude.js' ? basename : x;
+  });
+}
+
 function grabSourceMap(lastLine) {
     var base64 = lastLine.split(',').pop();
-    return JSON.parse(decode(base64));
+    var sm = JSON.parse(decode(base64));
+    sm.sources = unmountPrelude(sm.sources);
+    return sm;
 }
 
 function grabLastLine(src) {
@@ -29,8 +39,8 @@ test('pack one file with source file field and one without', function (t) {
         var sm = grabSourceMap(lastLine);
 
         t.ok(/^\/\/# sourceMappingURL/.test(lastLine), 'contains source mapping url as last line');
-        t.deepEqual(sm.sources, [ 'foo.js' ], 'includes mappings for sourceFile only');
-        t.equal(sm.mappings, ';;;AAAA;AACA;AACA;AACA', 'adds offset mapping for each line' );
+        t.deepEqual(sm.sources, [ '_prelude.js', 'foo.js' ], 'includes mappings for sourceFile and prelude only');
+        t.equal(sm.mappings, 'AAAA;;;ACAA;AACA;AACA;AACA', 'adds offset mapping for each line' );
     });
     
     p.end(JSON.stringify([
@@ -63,8 +73,8 @@ test('pack two files with source file field', function (t) {
         var sm = grabSourceMap(lastLine);
 
         t.ok(/^\/\/# sourceMappingURL/.test(lastLine), 'contains source mapping url as last line');
-        t.deepEqual(sm.sources, [ 'wunder/bar.js', 'foo.js' ], 'includes mappings for both files');
-        t.equal(sm.mappings, ';AAAA;;ACAA;AACA;AACA;AACA', 'adds offset mapping for each line' );
+        t.deepEqual(sm.sources, [ '_prelude.js', 'wunder/bar.js', 'foo.js' ], 'includes mappings for both files and prelude');
+        t.equal(sm.mappings, 'AAAA;ACAA;;ACAA;AACA;AACA;AACA', 'adds offset mapping for each line' );
     });
     
     p.end(JSON.stringify([
@@ -127,8 +137,8 @@ test('pack two files with source file field, one with nomap flag', function (t)
         var sm = grabSourceMap(lastLine);
 
         t.ok(/^\/\/# sourceMappingURL/.test(lastLine), 'contains source mapping url as last line');
-        t.deepEqual(sm.sources, [ 'wunder/bar.js' ], 'includes mappings for only the file without the "nomap" flag');
-        t.equal(sm.mappings, ';AAAA', 'adds offset mapping for each line of mapped file' );
+        t.deepEqual(sm.sources, [ '_prelude.js', 'wunder/bar.js' ], 'includes mappings for only the file without the "nomap" flag and prelude');
+        t.equal(sm.mappings, 'AAAA;ACAA', 'adds offset mapping for each line of mapped file' );
         t.end()
     });
     
@@ -164,8 +174,8 @@ test('custom sourceMapPrefix for //@', function (t) {
         var sm = grabSourceMap(lastLine);
 
         t.ok(/^\/\/@ sourceMappingURL/.test(lastLine), 'contains source mapping url as last line');
-        t.deepEqual(sm.sources, [ 'foo.js' ], 'includes mappings for sourceFile only');
-        t.equal(sm.mappings, ';;;AAAA;AACA;AACA;AACA', 'adds offset mapping for each line' );
+        t.deepEqual(sm.sources, [ '_prelude.js', 'foo.js' ], 'includes mappings for sourceFile and prelude only');
+        t.equal(sm.mappings, 'AAAA;;;ACAA;AACA;AACA;AACA', 'adds offset mapping for each line' );
     });
     
     p.end(JSON.stringify([

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-browser-pack.git



More information about the Pkg-javascript-commits mailing list