summaryrefslogtreecommitdiff
path: root/jstests/core/index8.js
diff options
context:
space:
mode:
authorJonathan Abrahams <jonathan@mongodb.com>2016-03-09 12:17:50 -0500
committerJonathan Abrahams <jonathan@mongodb.com>2016-03-09 12:18:14 -0500
commit4ae691e8edc87d0e3cfb633bb91c328426be007b (patch)
tree52079a593f54382ca13a2e741633eab1b6271893 /jstests/core/index8.js
parenta025d43f3ce2efc1fb1282a718f5d286fa0a4dc1 (diff)
downloadmongo-4ae691e8edc87d0e3cfb633bb91c328426be007b.tar.gz
SERVER-22468 Format JS code with approved style in jstests/
Diffstat (limited to 'jstests/core/index8.js')
-rw-r--r--jstests/core/index8.js81
1 files changed, 40 insertions, 41 deletions
diff --git a/jstests/core/index8.js b/jstests/core/index8.js
index 7b41da5ce50..6773f2d29f5 100644
--- a/jstests/core/index8.js
+++ b/jstests/core/index8.js
@@ -3,60 +3,59 @@
t = db.jstests_index8;
t.drop();
-t.ensureIndex( { a: 1 } );
-t.ensureIndex( { b: 1 }, true );
-t.ensureIndex( { c: 1 }, [ false, "cIndex" ] );
+t.ensureIndex({a: 1});
+t.ensureIndex({b: 1}, true);
+t.ensureIndex({c: 1}, [false, "cIndex"]);
-checkIndexes = function( num ) {
+checkIndexes = function(num) {
var indexes = t.getIndexes();
- assert.eq( 4, indexes.length );
+ assert.eq(4, indexes.length);
var start = 0;
- if ( indexes[0].name == "_id_" )
+ if (indexes[0].name == "_id_")
start = 1;
- assert( !indexes[ start ].unique , "A" + num );
- assert( indexes[ start + 1 ].unique , "B" + num + " " + tojson( indexes[start+1] ) );
- assert( !indexes[ start + 2 ].unique , "C" + num );
- assert.eq( "cIndex", indexes[ start + 2 ].name , "D" + num );
+ assert(!indexes[start].unique, "A" + num);
+ assert(indexes[start + 1].unique, "B" + num + " " + tojson(indexes[start + 1]));
+ assert(!indexes[start + 2].unique, "C" + num);
+ assert.eq("cIndex", indexes[start + 2].name, "D" + num);
};
-checkIndexes( 1 );
+checkIndexes(1);
t.reIndex();
-checkIndexes( 2 );
+checkIndexes(2);
-t.save( { a: 2, b: 1 } );
-t.save( { a: 2 } );
-assert.eq( 2, t.find().count() );
+t.save({a: 2, b: 1});
+t.save({a: 2});
+assert.eq(2, t.find().count());
-t.save( { b: 4 } );
-t.save( { b: 4 } );
-assert.eq( 3, t.find().count() );
-assert.eq( 3, t.find().hint( {c:1} ).toArray().length );
-assert.eq( 3, t.find().hint( {b:1} ).toArray().length );
-assert.eq( 3, t.find().hint( {a:1} ).toArray().length );
+t.save({b: 4});
+t.save({b: 4});
+assert.eq(3, t.find().count());
+assert.eq(3, t.find().hint({c: 1}).toArray().length);
+assert.eq(3, t.find().hint({b: 1}).toArray().length);
+assert.eq(3, t.find().hint({a: 1}).toArray().length);
t.drop();
-t.ensureIndex( { a: 1, b: -1 }, true );
-t.save( { a: 2, b: 3 } );
-t.save( { a: 2, b: 3 } );
-t.save( { a: 2, b: 4 } );
-t.save( { a: 1, b: 3 } );
-assert.eq( 3, t.find().count() );
+t.ensureIndex({a: 1, b: -1}, true);
+t.save({a: 2, b: 3});
+t.save({a: 2, b: 3});
+t.save({a: 2, b: 4});
+t.save({a: 1, b: 3});
+assert.eq(3, t.find().count());
t.drop();
-t.ensureIndex( { a: 1 }, true );
-t.save( { a: [ 2, 3 ] } );
-t.save( { a: 2 } );
-assert.eq( 1, t.find().count() );
+t.ensureIndex({a: 1}, true);
+t.save({a: [2, 3]});
+t.save({a: 2});
+assert.eq(1, t.find().count());
t.drop();
-t.ensureIndex( { a: 1 }, true );
-t.save( { a: 2 } );
-t.save( { a: [ 1, 2, 3 ] } );
-t.save( { a: [ 3, 2, 1 ] } );
-assert.eq( 1, t.find().sort( { a: 1 } ).hint( { a: 1 } ).toArray().length );
-assert.eq( 1, t.find().sort( { a: -1 } ).hint( { a: 1 } ).toArray().length );
-
-assert.eq( t._indexSpec( { x : 1 } , true ) , t._indexSpec( { x : 1 } , [ true ] ) , "spec 1" );
-assert.eq( t._indexSpec( { x : 1 } , "eliot" ) , t._indexSpec( { x : 1 } , [ "eliot" ] ) , "spec 2" );
-
+t.ensureIndex({a: 1}, true);
+t.save({a: 2});
+t.save({a: [1, 2, 3]});
+t.save({a: [3, 2, 1]});
+assert.eq(1, t.find().sort({a: 1}).hint({a: 1}).toArray().length);
+assert.eq(1, t.find().sort({a: -1}).hint({a: 1}).toArray().length);
+
+assert.eq(t._indexSpec({x: 1}, true), t._indexSpec({x: 1}, [true]), "spec 1");
+assert.eq(t._indexSpec({x: 1}, "eliot"), t._indexSpec({x: 1}, ["eliot"]), "spec 2");