Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

failing calls test

  • Loading branch information...
commit 18863d26b9699df8419a3c37c8ba1f70529b909c 1 parent 82744f0
@substack authored
Showing with 58 additions and 0 deletions.
  1. +53 −0 test/calls.js
  2. +5 −0 test/sources/calls.js
View
53 test/calls.js
@@ -0,0 +1,53 @@
+var fritter = require('../');
+var test = require('tap').test;
+var vm = require('vm');
+
+var fs = require('fs');
+var src = fs.readFileSync(__dirname + '/sources/calls.js', 'utf8');
+test('calls', function (t) {
+ t.plan(11);
+ var fry = fritter().include(src, { filename : 'zoom.js' });
+
+ fry.on('error', function (err, c) {
+ t.equal(err, 'moo');
+ t.equal(c.current.filename, 'zoom.js');
+ t.equal(c.current.start.line, 2);
+ t.equal(c.current.end.line, 2);
+
+ t.equal(c.stack.length, 3);
+
+ t.deepEqual(
+ c.stack.map(function (s) {
+ return s.callee.name
+ }),
+ [ 'h', 'g', 'f' ]
+ );
+
+ t.deepEqual(
+ c.stack.map(function (s) { return s.start.line }),
+ [ 1, 0, 4 ]
+ );
+
+ t.deepEqual(
+ c.stack.map(function (s) { return s.end.line }),
+ [ 1, 0, 4 ]
+ );
+
+ t.deepEqual(
+ c.stack.map(function (s) { return s.start.col }),
+ [ 16, 16, 0 ]
+ );
+
+ t.deepEqual(
+ c.stack.map(function (s) { return s.end.col }),
+ [ 18, 18, 2 ]
+ );
+ });
+
+ try {
+ vm.runInNewContext(fry.source, fry.context);
+ }
+ catch (err) {
+ t.equal(err, 'moo');
+ }
+});
View
5 test/sources/calls.js
@@ -0,0 +1,5 @@
+function f () { g() }
+function g () { h() }
+function h () { throw 'moo' }
+
+f();
Please sign in to comment.
Something went wrong with that request. Please try again.