diff options
author | Jonathan Abrahams <jonathan@mongodb.com> | 2016-03-09 12:17:50 -0500 |
---|---|---|
committer | Jonathan Abrahams <jonathan@mongodb.com> | 2016-03-09 12:18:14 -0500 |
commit | 4ae691e8edc87d0e3cfb633bb91c328426be007b (patch) | |
tree | 52079a593f54382ca13a2e741633eab1b6271893 /jstests/core/index_check3.js | |
parent | a025d43f3ce2efc1fb1282a718f5d286fa0a4dc1 (diff) | |
download | mongo-4ae691e8edc87d0e3cfb633bb91c328426be007b.tar.gz |
SERVER-22468 Format JS code with approved style in jstests/
Diffstat (limited to 'jstests/core/index_check3.js')
-rw-r--r-- | jstests/core/index_check3.js | 87 |
1 files changed, 43 insertions, 44 deletions
diff --git a/jstests/core/index_check3.js b/jstests/core/index_check3.js index 78135ff30ca..2c07ae6d50a 100644 --- a/jstests/core/index_check3.js +++ b/jstests/core/index_check3.js @@ -3,63 +3,62 @@ t = db.index_check3; t.drop(); +t.save({a: 1}); +t.save({a: 2}); +t.save({a: 3}); +t.save({a: "z"}); +assert.eq(1, t.find({a: {$lt: 2}}).itcount(), "A"); +assert.eq(1, t.find({a: {$gt: 2}}).itcount(), "B"); -t.save( { a : 1 } ); -t.save( { a : 2 } ); -t.save( { a : 3 } ); -t.save( { a : "z" } ); +t.ensureIndex({a: 1}); -assert.eq( 1 , t.find( { a : { $lt : 2 } } ).itcount() , "A" ); -assert.eq( 1 , t.find( { a : { $gt : 2 } } ).itcount() , "B" ); - -t.ensureIndex( { a : 1 } ); - -assert.eq( 1 , t.find( { a : { $lt : 2 } } ).itcount() , "C" ); -assert.eq( 1 , t.find( { a : { $gt : 2 } } ).itcount() , "D" ); +assert.eq(1, t.find({a: {$lt: 2}}).itcount(), "C"); +assert.eq(1, t.find({a: {$gt: 2}}).itcount(), "D"); t.drop(); -for ( var i=0; i<100; i++ ){ - var o = { i : i }; - if ( i % 2 == 0 ) +for (var i = 0; i < 100; i++) { + var o = { + i: i + }; + if (i % 2 == 0) o.foo = i; - t.save( o ); + t.save(o); } -t.ensureIndex( { foo : 1 } ); - -var explain = t.find( { foo : { $lt : 50 } } ).explain("executionStats"); -assert.gt( 30 , explain.executionStats.totalKeysExamined , "lt" ); -var explain = t.find( { foo : { $gt : 50 } } ).explain("executionStats"); -assert.gt( 30 , explain.executionStats.totalKeysExamined , "gt" ); +t.ensureIndex({foo: 1}); +var explain = t.find({foo: {$lt: 50}}).explain("executionStats"); +assert.gt(30, explain.executionStats.totalKeysExamined, "lt"); +var explain = t.find({foo: {$gt: 50}}).explain("executionStats"); +assert.gt(30, explain.executionStats.totalKeysExamined, "gt"); t.drop(); -t.save( {i:'a'} ); -for( var i=0; i < 10; ++i ) { - t.save( {} ); +t.save({i: 'a'}); +for (var i = 0; i < 10; ++i) { + t.save({}); } -t.ensureIndex( { i : 1 } ); +t.ensureIndex({i: 1}); -var explain = t.find( { i : { $lte : 'a' } } ).explain("executionStats"); -assert.gt( 3 , explain.executionStats.totalKeysExamined , "lte" ); -//printjson( t.find( { i : { $gte : 'a' } } ).explain() ); +var explain = t.find({i: {$lte: 'a'}}).explain("executionStats"); +assert.gt(3, explain.executionStats.totalKeysExamined, "lte"); +// printjson( t.find( { i : { $gte : 'a' } } ).explain() ); // bug SERVER-99 -var explain = t.find( { i : { $gte : 'a' } } ).explain("executionStats"); -assert.gt( 3 , explain.executionStats.totalKeysExamined , "gte" ); -assert.eq( 1 , t.find( { i : { $gte : 'a' } } ).count() , "gte a" ); -assert.eq( 1 , t.find( { i : { $gte : 'a' } } ).itcount() , "gte b" ); -assert.eq( 1 , t.find( { i : { $gte : 'a' } } ).sort( { i : 1 } ).count() , "gte c" ); -assert.eq( 1 , t.find( { i : { $gte : 'a' } } ).sort( { i : 1 } ).itcount() , "gte d" ); - -t.save( { i : "b" } ); - -var explain = t.find( { i : { $gte : 'a' } } ).explain("executionStats"); -assert.gt( 3 , explain.executionStats.totalKeysExamined , "gte" ); -assert.eq( 2 , t.find( { i : { $gte : 'a' } } ).count() , "gte a2" ); -assert.eq( 2 , t.find( { i : { $gte : 'a' } } ).itcount() , "gte b2" ); -assert.eq( 2 , t.find( { i : { $gte : 'a' , $lt : MaxKey } } ).itcount() , "gte c2" ); -assert.eq( 2 , t.find( { i : { $gte : 'a' , $lt : MaxKey } } ).sort( { i : -1 } ).itcount() , "gte d2" ); -assert.eq( 2 , t.find( { i : { $gte : 'a' , $lt : MaxKey } } ).sort( { i : 1 } ).itcount() , "gte e2" ); +var explain = t.find({i: {$gte: 'a'}}).explain("executionStats"); +assert.gt(3, explain.executionStats.totalKeysExamined, "gte"); +assert.eq(1, t.find({i: {$gte: 'a'}}).count(), "gte a"); +assert.eq(1, t.find({i: {$gte: 'a'}}).itcount(), "gte b"); +assert.eq(1, t.find({i: {$gte: 'a'}}).sort({i: 1}).count(), "gte c"); +assert.eq(1, t.find({i: {$gte: 'a'}}).sort({i: 1}).itcount(), "gte d"); + +t.save({i: "b"}); + +var explain = t.find({i: {$gte: 'a'}}).explain("executionStats"); +assert.gt(3, explain.executionStats.totalKeysExamined, "gte"); +assert.eq(2, t.find({i: {$gte: 'a'}}).count(), "gte a2"); +assert.eq(2, t.find({i: {$gte: 'a'}}).itcount(), "gte b2"); +assert.eq(2, t.find({i: {$gte: 'a', $lt: MaxKey}}).itcount(), "gte c2"); +assert.eq(2, t.find({i: {$gte: 'a', $lt: MaxKey}}).sort({i: -1}).itcount(), "gte d2"); +assert.eq(2, t.find({i: {$gte: 'a', $lt: MaxKey}}).sort({i: 1}).itcount(), "gte e2"); |