[Pkg-javascript-commits] [node-browser-pack] 43/141: Add test for `this` In node.js `this` on the module root is the same as `exports`. Browser-pack should act like it too.

Bastien Roucariès rouca at moszumanska.debian.org
Thu May 4 10:23:23 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 332c6b59ead97d0a12a7e8390dbbf75691e745c6
Author: Esa-Matti Suuronen <esa-matti at suuronen.org>
Date:   Sat Apr 6 21:21:37 2013 +0300

    Add test for `this`
    In node.js `this` on the module root is the same as `exports`.
    Browser-pack should act like it too.
---
 test/this.js | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/test/this.js b/test/this.js
new file mode 100644
index 0000000..ebef4a9
--- /dev/null
+++ b/test/this.js
@@ -0,0 +1,24 @@
+/**
+ * In node.js `this` on the module root is the same as `exports`. Browser-pack
+ * should act like it too.
+ **/
+var test = require('tape');
+var pack = require('../');
+
+test('this', function (t) {
+    t.plan(1);
+
+    var p = pack();
+    var src = '';
+    p.on('data', function (buf) { src += buf; });
+    p.on('end', function () {
+        var r = Function([], 'return ' + src)();
+        t.deepEqual(r("abc"), { foo: "bar" });
+    });
+
+    p.end(JSON.stringify([{
+        id: 'abc',
+        source: 'this.foo = "bar"'
+    }]));
+
+});

-- 
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