summaryrefslogtreecommitdiff
path: root/jstests/core/not2.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/not2.js
parenta025d43f3ce2efc1fb1282a718f5d286fa0a4dc1 (diff)
downloadmongo-4ae691e8edc87d0e3cfb633bb91c328426be007b.tar.gz
SERVER-22468 Format JS code with approved style in jstests/
Diffstat (limited to 'jstests/core/not2.js')
-rw-r--r--jstests/core/not2.js120
1 files changed, 60 insertions, 60 deletions
diff --git a/jstests/core/not2.js b/jstests/core/not2.js
index 43dbfb20e3e..98eb19cee6f 100644
--- a/jstests/core/not2.js
+++ b/jstests/core/not2.js
@@ -1,84 +1,84 @@
t = db.jstests_not2;
t.drop();
-check = function( query, expected, size ) {
- if ( size == null ) {
+check = function(query, expected, size) {
+ if (size == null) {
size = 1;
}
- assert.eq( size, t.find( query ).itcount(), tojson( query ) );
- if ( size > 0 ) {
- assert.eq( expected, t.findOne( query ).i, tojson( query ) );
+ assert.eq(size, t.find(query).itcount(), tojson(query));
+ if (size > 0) {
+ assert.eq(expected, t.findOne(query).i, tojson(query));
}
};
-fail = function( query ) {
+fail = function(query) {
try {
- t.find( query ).itcount();
- assert( false, tojson( query ) );
- } catch ( e ) {
+ t.find(query).itcount();
+ assert(false, tojson(query));
+ } catch (e) {
// expected
}
};
doTest = function() {
-t.remove( {} );
-
-t.save( {i:"a"} );
-t.save( {i:"b"} );
+ t.remove({});
-fail( {i:{$not:"a"}} );
-// SERVER-12735: We currently do not handle double negatives
-// during query canonicalization.
-//fail( {i:{$not:{$not:"a"}}} );
-//fail( {i:{$not:{$not:{$gt:"a"}}}} );
-fail( {i:{$not:{$ref:"foo"}}} );
-fail( {i:{$not:{}}} );
-check( {i:{$gt:"a"}}, "b" );
-check( {i:{$not:{$gt:"a"}}}, "a" );
-check( {i:{$not:{$ne:"a"}}}, "a" );
-check( {i:{$not:{$gte:"b"}}}, "a" );
-check( {i:{$exists:true}}, "a", 2 );
-check( {i:{$not:{$exists:true}}}, "", 0 );
-check( {j:{$not:{$exists:false}}}, "", 0 );
-check( {j:{$not:{$exists:true}}}, "a", 2 );
-check( {i:{$not:{$in:["a"]}}}, "b" );
-check( {i:{$not:{$in:["a", "b"]}}}, "", 0 );
-check( {i:{$not:{$in:["g"]}}}, "a", 2 );
-check( {i:{$not:{$nin:["a"]}}}, "a" );
-check( {i:{$not:/a/}}, "b" );
-check( {i:{$not:/(a|b)/}}, "", 0 );
-check( {i:{$not:/a/,$regex:"a"}}, "", 0 );
-check( {i:{$not:/aa/}}, "a", 2 );
-fail( {i:{$not:{$regex:"a"}}} );
-fail( {i:{$not:{$options:"a"}}} );
-check( {i:{$type:2}}, "a", 2 );
-check( {i:{$not:{$type:1}}}, "a", 2 );
-check( {i:{$not:{$type:2}}}, "", 0 );
+ t.save({i: "a"});
+ t.save({i: "b"});
-t.remove( {} );
-t.save( {i:1} );
-check( {i:{$not:{$mod:[5,1]}}}, null, 0 );
-check( {i:{$mod:[5,2]}}, null, 0 );
-check( {i:{$not:{$mod:[5,2]}}}, 1, 1 );
+ fail({i: {$not: "a"}});
+ // SERVER-12735: We currently do not handle double negatives
+ // during query canonicalization.
+ // fail( {i:{$not:{$not:"a"}}} );
+ // fail( {i:{$not:{$not:{$gt:"a"}}}} );
+ fail({i: {$not: {$ref: "foo"}}});
+ fail({i: {$not: {}}});
+ check({i: {$gt: "a"}}, "b");
+ check({i: {$not: {$gt: "a"}}}, "a");
+ check({i: {$not: {$ne: "a"}}}, "a");
+ check({i: {$not: {$gte: "b"}}}, "a");
+ check({i: {$exists: true}}, "a", 2);
+ check({i: {$not: {$exists: true}}}, "", 0);
+ check({j: {$not: {$exists: false}}}, "", 0);
+ check({j: {$not: {$exists: true}}}, "a", 2);
+ check({i: {$not: {$in: ["a"]}}}, "b");
+ check({i: {$not: {$in: ["a", "b"]}}}, "", 0);
+ check({i: {$not: {$in: ["g"]}}}, "a", 2);
+ check({i: {$not: {$nin: ["a"]}}}, "a");
+ check({i: {$not: /a/}}, "b");
+ check({i: {$not: /(a|b)/}}, "", 0);
+ check({i: {$not: /a/, $regex: "a"}}, "", 0);
+ check({i: {$not: /aa/}}, "a", 2);
+ fail({i: {$not: {$regex: "a"}}});
+ fail({i: {$not: {$options: "a"}}});
+ check({i: {$type: 2}}, "a", 2);
+ check({i: {$not: {$type: 1}}}, "a", 2);
+ check({i: {$not: {$type: 2}}}, "", 0);
-t.remove( {} );
-t.save( {i:["a","b"]} );
-check( {i:{$not:{$size:2}}}, null, 0 );
-check( {i:{$not:{$size:3}}}, ["a","b"] );
-check( {i:{$not:{$gt:"a"}}}, null, 0 );
-check( {i:{$not:{$gt:"c"}}}, ["a","b"] );
-check( {i:{$not:{$all:["a","b"]}}}, null, 0 );
-check( {i:{$not:{$all:["c"]}}}, ["a","b"] );
+ t.remove({});
+ t.save({i: 1});
+ check({i: {$not: {$mod: [5, 1]}}}, null, 0);
+ check({i: {$mod: [5, 2]}}, null, 0);
+ check({i: {$not: {$mod: [5, 2]}}}, 1, 1);
-t.remove( {} );
-t.save( {i:[{j:"a"}]} );
-t.save( {i:[{j:"b"}]} );
-check( {i:{$not:{$elemMatch:{j:"a"}}}}, [{j:"b"}] );
-check( {i:{$not:{$elemMatch:{j:"f"}}}}, [{j:"a"}], 2 );
+ t.remove({});
+ t.save({i: ["a", "b"]});
+ check({i: {$not: {$size: 2}}}, null, 0);
+ check({i: {$not: {$size: 3}}}, ["a", "b"]);
+ check({i: {$not: {$gt: "a"}}}, null, 0);
+ check({i: {$not: {$gt: "c"}}}, ["a", "b"]);
+ check({i: {$not: {$all: ["a", "b"]}}}, null, 0);
+ check({i: {$not: {$all: ["c"]}}}, ["a", "b"]);
+
+ t.remove({});
+ t.save({i: [{j: "a"}]});
+ t.save({i: [{j: "b"}]});
+ check({i: {$not: {$elemMatch: {j: "a"}}}}, [{j: "b"}]);
+ check({i: {$not: {$elemMatch: {j: "f"}}}}, [{j: "a"}], 2);
};
doTest();
-t.ensureIndex( {i:1} );
+t.ensureIndex({i: 1});
doTest();