MCPcopy
hub / github.com/meteor/meteor / match

Function match

packages/check/match_test.js:339–357  ·  view source on GitHub ↗
(value, pattern, expectedPath)

Source from the content-addressed store, hash-verified

337
338Tinytest.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

Callers 2

match_test.jsFile · 0.85

Calls 2

checkFunction · 0.70
failMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…