Skip to content
Browse files

failing traverse test since properties aren't copied over

  • Loading branch information...
1 parent 9470f18 commit 084c3dfbd6e8c7569b46b776324bbac22d0a8d75 @substack committed May 15, 2012
Showing with 46 additions and 1 deletion.
  1. +2 −1 package.json
  2. +11 −0 test/sources/traverse.js
  3. +33 −0 test/traverse.js
View
3 package.json
@@ -27,7 +27,8 @@
"identifier" : "~0.0.0"
},
"devDependencies" : {
- "tap" : "~0.2.5"
+ "tap" : "~0.2.5",
+ "traverse" : "~0.6.1"
},
"engines" : {
"node" : ">=0.4.0"
View
11 test/sources/traverse.js
@@ -0,0 +1,11 @@
+var traverse = module.exports;
+
+var xs = [];
+traverse({ a : 1, b : 2, c : [ 3, 4 ]}, function (node) {
+ if (this.isLeaf) xs.push(node);
+});
+t.same(xs, [ 1, 2, 3, 4 ]);
+
+traverse({ a : 1, b : 2, c : [ 3, 4 ]}, function (node) {
+ if (this.isRoot) throw 'beep';
+});
View
33 test/traverse.js
@@ -0,0 +1,33 @@
+var fritter = require('../');
+var vm = require('vm');
+var test = require('tap').test;
+
+var fs = require('fs');
+var src = fs.readFileSync(require.resolve('traverse'), 'utf8')
+ + ';' + fs.readFileSync(__dirname + '/sources/traverse.js', 'utf8')
+;
+
+test('fff', function (t) {
+ t.plan(4);
+ var fry = fritter({
+ t : t,
+ module : { exports : {} },
+ });
+ fry.include(src);
+
+ fry.on('error', function (err, c) {
+ t.equal(err, 'beep');
+ t.deepEqual(
+ c.stack.map(function (s) { return fry.nameOf(s) }),
+ []
+ );
+ });
+
+ try {
+ vm.runInNewContext(fry.source, fry.context);
+ }
+ catch (err) {
+console.log(err.stack);
+ t.equal(err, 'beep');
+ }
+});

0 comments on commit 084c3df

Please sign in to comment.
Something went wrong with that request. Please try again.