Permalink
Browse files

passing throw in a block test

  • Loading branch information...
1 parent 3506c94 commit 9434a366aba2b5ee21c3e99903fc65a6ea3fc378 @substack committed Sep 28, 2011
Showing with 24 additions and 0 deletions.
  1. +17 −0 test/block.js
  2. +7 −0 test/sources/block.js
View
@@ -3,6 +3,7 @@ var test = require('tap').test;
var fs = require('fs');
var src = fs.readFileSync(__dirname + '/sources/block.js', 'utf8');
+
test('return in a block', function (t) {
t.plan(1);
var context = { exports : {} };
@@ -17,3 +18,19 @@ test('return in a block', function (t) {
t.fail(err);
});
});
+
+test('throw in a block', function (t) {
+ var context = { exports : {} };
+ var stack = stackedy(src).run(context);
+
+ process.nextTick(function () {
+ context.exports.blockThrow();
+ });
+
+ stack.on('error', function (err, c) {
+ stack.stop();
+ t.equal(err, 5);
+ t.equal(c.current.start.line, 10);
+ t.end();
+ });
+});
View
@@ -4,3 +4,10 @@ exports.blockReturn = function () {
return x / 3;
}
};
+
+exports.blockThrow = function () {
+ var x = 2 * 5 + 5;
+ {
+ throw x / 3;
+ }
+};

0 comments on commit 9434a36

Please sign in to comment.