mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
fix match to accept boolean values as pattern
PR #4107 [stubailo: merged two commits]
This commit is contained in:
committed by
Sashko Stubailo
parent
e0e30c3260
commit
7ed59d866c
@@ -166,8 +166,8 @@ var checkSubtree = function (value, pattern) {
|
||||
throw new Match.Error("Expected null, got " + EJSON.stringify(value));
|
||||
}
|
||||
|
||||
// Strings and numbers match literally. Goes well with Match.OneOf.
|
||||
if (typeof pattern === "string" || typeof pattern === "number") {
|
||||
// Strings, numbers, and booleans match literally. Goes well with Match.OneOf.
|
||||
if (typeof pattern === "string" || typeof pattern === "number" || typeof pattern === "boolean") {
|
||||
if (value === pattern)
|
||||
return;
|
||||
throw new Match.Error("Expected " + pattern + ", got " +
|
||||
|
||||
@@ -117,6 +117,11 @@ Tinytest.add("check - check", function (test) {
|
||||
fails(123, 456);
|
||||
fails("123", 123);
|
||||
fails(123, "123");
|
||||
matches(true, true);
|
||||
matches(false, false);
|
||||
fails(true, false);
|
||||
fails(true, "true");
|
||||
fails("false", false);
|
||||
|
||||
matches(/foo/, RegExp);
|
||||
fails(/foo/, String);
|
||||
|
||||
Reference in New Issue
Block a user