Closed gustavnikolaj closed 10 years ago
I figured out what the problem is. Unexpected has a few cases that tries to test if an argument is a regex. But the code that does the check, looks like this:
isRegExp: function (re) {
var s;
try {
s = '' + re;
} catch (e) {
return false;
}
return re instanceof RegExp || // easy case
// duck-type for context-switching evalcx case
typeof(re) === 'function' &&
re.constructor.name === 'RegExp' &&
re.compile &&
re.test &&
re.exec &&
s.match(/^\/.*\/[gim]{0,3}$/);
}
That means toString will be called on jshell by this code. I'll fix it by checking if toString receives a callback.
Nice one :+1: Thanks!
I had to disable it in 7c41e0a9f69a8dd99d40c2c1a059befd7daacba6 and replace it with a check using 'to be a function'.
I got an error bubbling up from spawn - that was the weirdest thing - as nothing should have called spawn yet. This makes me feel like it's coming from this code and is not the fault of unexpected, but I'm at a loss @sunesimonsen .