diff options
author | Siyuan Zhou <siyuan.zhou@mongodb.com> | 2014-03-03 17:15:39 -0500 |
---|---|---|
committer | Matt Kangas <matt.kangas@mongodb.com> | 2014-03-03 22:54:14 -0500 |
commit | 93d8befdbac74fb965faa4d3a8ae3e60d5a7a5b9 (patch) | |
tree | b1be042b0d074266fb417177b33aa0f266a3f38b /jstests/regex7.js | |
parent | 3660343e0b4627d2fee4afb89b74d32644d16d18 (diff) | |
download | mongo-93d8befdbac74fb965faa4d3a8ae3e60d5a7a5b9.tar.gz |
SERVER-12127 Temporarily put back jstest in order not to lose test coverage.
Signed-off-by: Matt Kangas <matt.kangas@mongodb.com>
Diffstat (limited to 'jstests/regex7.js')
-rw-r--r-- | jstests/regex7.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/jstests/regex7.js b/jstests/regex7.js new file mode 100644 index 00000000000..ab4f6089f9b --- /dev/null +++ b/jstests/regex7.js @@ -0,0 +1,26 @@ +t = db.regex_matches_self; +t.drop(); + +t.insert({r:/^a/}); +t.insert({r:/^a/i}); +t.insert({r:/^b/}); + +// no index +assert.eq( /^a/, t.findOne({r:/^a/}).r, '1 1 a') +assert.eq( 1, t.count({r:/^a/}), '1 2') +assert.eq( /^a/i, t.findOne({r:/^a/i}).r, '2 1 a') +assert.eq( 1, t.count({r:/^a/i}), '2 2 a') +assert.eq( /^b/, t.findOne({r:/^b/}).r, '3 1 a') +assert.eq( 1, t.count({r:/^b/}), '3 2 a') + +// with index +t.ensureIndex({r:1}) +assert.eq( /^a/, t.findOne({r:/^a/}).r, '1 1 b') +assert.eq( 1, t.count({r:/^a/}), '1 2 b') +assert.eq( /^a/i, t.findOne({r:/^a/i}).r, '2 1 b') +assert.eq( 1, t.count({r:/^a/i}), '2 2 b') +assert.eq( /^b/, t.findOne({r:/^b/}).r, '3 1 b') +assert.eq( 1, t.count({r:/^b/}), '3 2 b') + +t.insert( {r:"a"} ); +assert.eq( 2, t.count({r:/^a/}), 'c' );
\ No newline at end of file |