Files
mongo/jstests/core/regexc.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

29 lines
682 B
JavaScript

// Multiple regular expressions using the same index
var t = db.jstests_regexc;
// $and using same index twice
t.drop();
t.ensureIndex({a: 1});
t.save({a: "0"});
t.save({a: "1"});
t.save({a: "10"});
assert.eq( 1, t.find({$and: [{a: /0/}, {a: /1/}]}).itcount() );
// implicit $and using compound index twice
t.drop();
t.ensureIndex({a: 1, b: 1});
t.save({a: "0", b: "1"});
t.save({a: "10", b: "10"});
t.save({a: "10", b: "2"});
assert.eq( 2, t.find({a: /0/, b: /1/}).itcount() );
// $or using same index twice
t.drop();
t.ensureIndex({a: 1});
t.save({a: "0"});
t.save({a: "1"});
t.save({a: "2"});
t.save({a: "10"});
assert.eq( 3, t.find({$or: [{a: /0/}, {a: /1/}]}).itcount() );