0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00
mongodb/jstests/mod1.js
Eliot Horowitz 33ac3c31c3 fix mod eq 0
2009-08-21 15:17:58 -04:00

22 lines
556 B
JavaScript

t = db.mod1;
t.drop();
t.save( { a : 1 } );
t.save( { a : 2 } );
t.save( { a : 11 } );
t.save( { a : 20 } );
assert.eq( 2 , t.find( "this.a % 10 == 1" ).itcount() , "A" );
assert.eq( 2 , t.find( { a : { $mod : [ 10 , 1 ] } } ).itcount() , "B" );
t.ensureIndex( { a : 1 } );
assert.eq( 2 , t.find( "this.a % 10 == 1" ).itcount() , "C" );
assert.eq( 2 , t.find( { a : { $mod : [ 10 , 1 ] } } ).itcount() , "D" );
assert.eq( 1 , t.find( "this.a % 10 == 0" ).itcount() , "E" );
assert.eq( 1 , t.find( { a : { $mod : [ 10 , 0 ] } } ).itcount() , "F" );