Files
mongo/jstests/core/regex_util.js
Siyuan Zhou 3660343e0b SERVER-12127 migrate js tests to jscore suite when not related to writes
Migrate js tests starting from j-z.
Include SERVER-12920 Update use_power_of_2.js

Signed-off-by: Matt Kangas <matt.kangas@mongodb.com>
2014-03-03 22:54:10 -05:00

28 lines
457 B
JavaScript

// Tests for RegExp.escape
(function() {
var TEST_STRINGS = [
"[db]",
"{ab}",
"<c2>",
"(abc)",
"^first^",
"&addr",
"k@10gen.com",
"#4",
"!b",
"<>3",
"****word+",
"\t| |\n\r",
"Mongo-db",
"[{(<>)}]!@#%^&*+\\"
];
TEST_STRINGS.forEach(function (str) {
var escaped = RegExp.escape(str);
var regex = new RegExp(escaped);
assert(regex.test(str), "Wrong escape for " + str);
});
})();