Permalink
Browse files

failing test for inline function toString

  • Loading branch information...
1 parent b30a7e0 commit 6a2258af814cf9ee0101d995b48f1cbcaa05f8ae @substack committed Apr 29, 2012
Showing with 27 additions and 9 deletions.
  1. +27 −9 test/to_string.js
View
@@ -1,17 +1,35 @@
var stackedy = require('../');
var test = require('tap').test;
-var src = '(' + function () {
- function plusTen () { return x + 10 };
- t.equal(
- plusTen.toString().replace(/\s+/g, ''),
- 'function plusTen () { return x + 10 }'.replace(/\s+/g, '')
- );
-} + ')()';
+var src = {
+ defun : '(' + function () {
+ function plusTen () { return x + 10 };
+ t.equal(
+ plusTen.toString().replace(/\s+/g, ''),
+ 'function plusTen () { return x + 10 }'.replace(/\s+/g, '')
+ );
+ } + ')()',
+ fn : '(' + function () {
+ t.equal(
+ (function () { return x + 10 }).toString().replace(/\s+/g, ''),
+ 'function () { return x + 10 }'.replace(/\s+/g, '')
+ );
+ } + ')()',
+};
-test('fn.toString()', function (t) {
+test('defun toString()', function (t) {
t.plan(1);
- var stack = stackedy(src).run({ t : t });
+ var stack = stackedy(src.defun).run({ t : t });
+
+ stack.on('error', function (err, c) {
+ stack.stop();
+ t.fail(err);
+ });
+});
+
+test('fn toString()', function (t) {
+ t.plan(1);
+ var stack = stackedy(src.fn).run({ t : t });
stack.on('error', function (err, c) {
stack.stop();

0 comments on commit 6a2258a

Please sign in to comment.