Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

somehow toString internals are still getting wrapped incorrectly

  • Loading branch information...
commit 1aa4ec3cb9e315fd360bbdb678e83117e609977f 1 parent c63c4f4
@substack authored
Showing with 37 additions and 16 deletions.
  1. +37 −16 test/to_string.js
View
53 test/to_string.js
@@ -1,36 +1,57 @@
var stackedy = require('../');
var test = require('tap').test;
-var src = {
- defun : '(' + function () {
+test('defun toString()', function (t) {
+ t.plan(1);
+ var src = '(' + function () {
function plusTen () { return x + 10 };
t.equal(
- plusTen.toString().replace(/\s+/g, ''),
- 'function plusTen () { return x + 10 }'.replace(/\s+/g, '')
+ 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, '')
- );
- } + ')()',
-};
+ } + ')()';
+
+ var stack = stackedy(src).run({ t : t });
+ stack.on('error', function (err, c) {
+ stack.stop();
+ t.fail(err);
+ });
+});
-test('defun toString()', function (t) {
+test('fn toString()', function (t) {
t.plan(1);
- var stack = stackedy(src.defun).run({ t : t });
+ var src = '(' + function () {
+ t.equal(
+ (function () { return x + 10 }).toString()
+ .replace(/\s+/g, ''),
+ 'function () { return x + 10 }'
+ .replace(/\s+/g, '')
+ );
+ } + ')()';
+ var stack = stackedy(src).run({ t : t });
stack.on('error', function (err, c) {
stack.stop();
t.fail(err);
});
});
-test('fn toString()', function (t) {
+test('expr fn toString()', function (t) {
t.plan(1);
- var stack = stackedy(src.fn).run({ t : t });
+ var src = '(' + function () {
+ log((function (win) {
+ console.log('window!')
+ }).toString());
+ } + ')()';
+
+ var stack = stackedy(src).run({
+ log : function (msg) {
+ t.equal(msg, "function(win){console.log('window')}");
+ }
+ });
stack.on('error', function (err, c) {
stack.stop();
t.fail(err);
Please sign in to comment.
Something went wrong with that request. Please try again.