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/or2.js | |
parent | a025d43f3ce2efc1fb1282a718f5d286fa0a4dc1 (diff) | |
download | mongo-4ae691e8edc87d0e3cfb633bb91c328426be007b.tar.gz |
SERVER-22468 Format JS code with approved style in jstests/
Diffstat (limited to 'jstests/core/or2.js')
-rw-r--r-- | jstests/core/or2.js | 79 |
1 files changed, 45 insertions, 34 deletions
diff --git a/jstests/core/or2.js b/jstests/core/or2.js index 11cfc44ff7f..2624c213fad 100644 --- a/jstests/core/or2.js +++ b/jstests/core/or2.js @@ -4,47 +4,58 @@ t.drop(); // Include helpers for analyzing explain output. load("jstests/libs/analyze_plan.js"); -checkArrs = function( a, b ) { - assert.eq( a.length, b.length ); +checkArrs = function(a, b) { + assert.eq(a.length, b.length); aStr = []; bStr = []; - a.forEach( function( x ) { aStr.push( tojson( x ) ); } ); - b.forEach( function( x ) { bStr.push( tojson( x ) ); } ); - for ( i = 0; i < aStr.length; ++i ) { - assert.neq( -1, bStr.indexOf( aStr[ i ] ) ); + a.forEach(function(x) { + aStr.push(tojson(x)); + }); + b.forEach(function(x) { + bStr.push(tojson(x)); + }); + for (i = 0; i < aStr.length; ++i) { + assert.neq(-1, bStr.indexOf(aStr[i])); } }; -doTest = function( index ) { - if ( index == null ) { +doTest = function(index) { + if (index == null) { index = true; } - t.save( {_id:0,x:0,a:1} ); - t.save( {_id:1,x:0,a:2} ); - t.save( {_id:2,x:0,b:1} ); - t.save( {_id:3,x:0,b:2} ); - t.save( {_id:4,x:1,a:1,b:1} ); - t.save( {_id:5,x:1,a:1,b:2} ); - t.save( {_id:6,x:1,a:2,b:1} ); - t.save( {_id:7,x:1,a:2,b:2} ); + t.save({_id: 0, x: 0, a: 1}); + t.save({_id: 1, x: 0, a: 2}); + t.save({_id: 2, x: 0, b: 1}); + t.save({_id: 3, x: 0, b: 2}); + t.save({_id: 4, x: 1, a: 1, b: 1}); + t.save({_id: 5, x: 1, a: 1, b: 2}); + t.save({_id: 6, x: 1, a: 2, b: 1}); + t.save({_id: 7, x: 1, a: 2, b: 2}); - assert.throws( function() { t.find( { x:0,$or:"a" } ).toArray(); } ); - assert.throws( function() { t.find( { x:0,$or:[] } ).toArray(); } ); - assert.throws( function() { t.find( { x:0,$or:[ "a" ] } ).toArray(); } ); + assert.throws(function() { + t.find({x: 0, $or: "a"}).toArray(); + }); + assert.throws(function() { + t.find({x: 0, $or: []}).toArray(); + }); + assert.throws(function() { + t.find({x: 0, $or: ["a"]}).toArray(); + }); - a1 = t.find( { x:0, $or: [ { a : 1 } ] } ).toArray(); - checkArrs( [ { _id:0, x:0, a:1 } ], a1 ); - if ( index ) { - var explain = t.find( { x:0,$or: [ { a : 1 } ] } ).explain(); - assert( isIxscan(explain.queryPlanner.winningPlan) ); + a1 = t.find({x: 0, $or: [{a: 1}]}).toArray(); + checkArrs([{_id: 0, x: 0, a: 1}], a1); + if (index) { + var explain = t.find({x: 0, $or: [{a: 1}]}).explain(); + assert(isIxscan(explain.queryPlanner.winningPlan)); } - a1b2 = t.find( { x:1, $or: [ { a : 1 }, { b : 2 } ] } ).toArray(); - checkArrs( [ { _id:4, x:1, a:1, b:1 }, { _id:5, x:1, a:1, b:2 }, { _id:7, x:1, a:2, b:2 } ], a1b2 ); - if ( index ) { - var explain = t.find( { x:0,$or: [ { a : 1 } ] } ).explain(); - assert( isIxscan(explain.queryPlanner.winningPlan) ); + a1b2 = t.find({x: 1, $or: [{a: 1}, {b: 2}]}).toArray(); + checkArrs([{_id: 4, x: 1, a: 1, b: 1}, {_id: 5, x: 1, a: 1, b: 2}, {_id: 7, x: 1, a: 2, b: 2}], + a1b2); + if (index) { + var explain = t.find({x: 0, $or: [{a: 1}]}).explain(); + assert(isIxscan(explain.queryPlanner.winningPlan)); } /* @@ -56,19 +67,19 @@ doTest = function( index ) { */ }; -doTest( false ); +doTest(false); -t.ensureIndex( { x:1 } ); +t.ensureIndex({x: 1}); doTest(); t.drop(); -t.ensureIndex( { x:1,a:1 } ); +t.ensureIndex({x: 1, a: 1}); doTest(); t.drop(); -t.ensureIndex( {x:1,b:1} ); +t.ensureIndex({x: 1, b: 1}); doTest(); t.drop(); -t.ensureIndex( {x:1,a:1,b:1} ); +t.ensureIndex({x: 1, a: 1, b: 1}); doTest(); |