tapjs / tmatch

This module exists to facilitate the t.match() method in node-tap (http://npm.im/tap)
22 stars 9 forks source link

always compare against stringified object when pattern is RegExp #14

Closed addaleax closed 8 years ago

addaleax commented 8 years ago

When the pattern is a regular expression and the object has not already been detected as a regular expression too, one can be almost 100 % certain that the user meant to compare the stringified version of the left-hand side (e.g. for errors, arrays, etc.) against the regular expression.

Previously, this would almost always pass silently in these simple cases.

This is likely a semver-major change, both for tmatch and tap.

(side note: I was particularly confused when looking into this by the fact that node-tap.org itself says that tap uses t.match(er, …) for t.throws. I’d PR over there too, but I can’t seem to find the website repo, if there is any.)

/cc @isaacs