(value, pattern, expectedPath)
| 337 | |
| 338 | Tinytest.add('check - Match error path', test => { |
| 339 | const match = (value, pattern, expectedPath) => { |
| 340 | try { |
| 341 | check(value, pattern); |
| 342 | } catch (err) { |
| 343 | |
| 344 | // XXX just for FF 3.6, its JSON stringification prefers "\u000a" to "\n" |
| 345 | err.path = err.path.replace(/\\u000a/, '\\n'); |
| 346 | if (err.path != expectedPath) { |
| 347 | test.fail({ |
| 348 | type: 'match-error-path', |
| 349 | message: "The path of Match.Error doesn't match.", |
| 350 | pattern: JSON.stringify(pattern), |
| 351 | value: JSON.stringify(value), |
| 352 | path: err.path, |
| 353 | expectedPath, |
| 354 | }); |
| 355 | } |
| 356 | } |
| 357 | }; |
| 358 | |
| 359 | match({ foo: [ { bar: 3 }, { bar: 'something' } ] }, { foo: [{ bar: Number }] }, 'foo[1].bar'); |
| 360 |
no test coverage detected
searching dependent graphs…