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/and3.js | |
parent | a025d43f3ce2efc1fb1282a718f5d286fa0a4dc1 (diff) | |
download | mongo-4ae691e8edc87d0e3cfb633bb91c328426be007b.tar.gz |
SERVER-22468 Format JS code with approved style in jstests/
Diffstat (limited to 'jstests/core/and3.js')
-rw-r--r-- | jstests/core/and3.js | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/jstests/core/and3.js b/jstests/core/and3.js index a0a779937b1..4f6d6bd28fd 100644 --- a/jstests/core/and3.js +++ b/jstests/core/and3.js @@ -3,53 +3,53 @@ t = db.jstests_and3; t.drop(); -t.save( {a:1} ); -t.save( {a:'foo'} ); +t.save({a: 1}); +t.save({a: 'foo'}); -t.ensureIndex( {a:1} ); +t.ensureIndex({a: 1}); -function checkScanMatch( query, docsExamined, n ) { - var e = t.find( query ).hint( {a:1} ).explain( "executionStats" ); - assert.eq( docsExamined, e.executionStats.totalDocsExamined ); - assert.eq( n, e.executionStats.nReturned ); +function checkScanMatch(query, docsExamined, n) { + var e = t.find(query).hint({a: 1}).explain("executionStats"); + assert.eq(docsExamined, e.executionStats.totalDocsExamined); + assert.eq(n, e.executionStats.nReturned); } -checkScanMatch( {a:/o/}, 1, 1 ); -checkScanMatch( {a:/a/}, 0, 0 ); -checkScanMatch( {a:{$not:/o/}}, 2, 1 ); -checkScanMatch( {a:{$not:/a/}}, 2, 2 ); - -checkScanMatch( {$and:[{a:/o/}]}, 1, 1 ); -checkScanMatch( {$and:[{a:/a/}]}, 0, 0 ); -checkScanMatch( {$and:[{a:{$not:/o/}}]}, 2, 1 ); -checkScanMatch( {$and:[{a:{$not:/a/}}]}, 2, 2 ); -checkScanMatch( {$and:[{a:/o/},{a:{$not:/o/}}]}, 1, 0 ); -checkScanMatch( {$and:[{a:/o/},{a:{$not:/a/}}]}, 1, 1 ); -checkScanMatch( {$or:[{a:/o/}]}, 1, 1 ); -checkScanMatch( {$or:[{a:/a/}]}, 0, 0 ); -checkScanMatch( {$nor:[{a:/o/}]}, 2, 1 ); -checkScanMatch( {$nor:[{a:/a/}]}, 2, 2 ); - -checkScanMatch( {$and:[{$and:[{a:/o/}]}]}, 1, 1 ); -checkScanMatch( {$and:[{$and:[{a:/a/}]}]}, 0, 0 ); -checkScanMatch( {$and:[{$and:[{a:{$not:/o/}}]}]}, 2, 1 ); -checkScanMatch( {$and:[{$and:[{a:{$not:/a/}}]}]}, 2, 2 ); -checkScanMatch( {$and:[{$or:[{a:/o/}]}]}, 1, 1 ); -checkScanMatch( {$and:[{$or:[{a:/a/}]}]}, 0, 0 ); -checkScanMatch( {$or:[{a:{$not:/o/}}]}, 2, 1 ); -checkScanMatch( {$and:[{$or:[{a:{$not:/o/}}]}]}, 2, 1 ); -checkScanMatch( {$and:[{$or:[{a:{$not:/a/}}]}]}, 2, 2 ); -checkScanMatch( {$and:[{$nor:[{a:/o/}]}]}, 2, 1 ); -checkScanMatch( {$and:[{$nor:[{a:/a/}]}]}, 2, 2 ); - -checkScanMatch( {$where:'this.a==1'}, 2, 1 ); -checkScanMatch( {$and:[{$where:'this.a==1'}]}, 2, 1 ); - -checkScanMatch( {a:1,$where:'this.a==1'}, 1, 1 ); -checkScanMatch( {a:1,$and:[{$where:'this.a==1'}]}, 1, 1 ); -checkScanMatch( {$and:[{a:1},{$where:'this.a==1'}]}, 1, 1 ); -checkScanMatch( {$and:[{a:1,$where:'this.a==1'}]}, 1, 1 ); -checkScanMatch( {a:1,$and:[{a:1},{a:1,$where:'this.a==1'}]}, 1, 1 ); - -assert.eq( 0, t.find({a:1,$and:[{a:2}]}).itcount() ); -assert.eq( 0, t.find({$and:[{a:1},{a:2}]}).itcount() ); +checkScanMatch({a: /o/}, 1, 1); +checkScanMatch({a: /a/}, 0, 0); +checkScanMatch({a: {$not: /o/}}, 2, 1); +checkScanMatch({a: {$not: /a/}}, 2, 2); + +checkScanMatch({$and: [{a: /o/}]}, 1, 1); +checkScanMatch({$and: [{a: /a/}]}, 0, 0); +checkScanMatch({$and: [{a: {$not: /o/}}]}, 2, 1); +checkScanMatch({$and: [{a: {$not: /a/}}]}, 2, 2); +checkScanMatch({$and: [{a: /o/}, {a: {$not: /o/}}]}, 1, 0); +checkScanMatch({$and: [{a: /o/}, {a: {$not: /a/}}]}, 1, 1); +checkScanMatch({$or: [{a: /o/}]}, 1, 1); +checkScanMatch({$or: [{a: /a/}]}, 0, 0); +checkScanMatch({$nor: [{a: /o/}]}, 2, 1); +checkScanMatch({$nor: [{a: /a/}]}, 2, 2); + +checkScanMatch({$and: [{$and: [{a: /o/}]}]}, 1, 1); +checkScanMatch({$and: [{$and: [{a: /a/}]}]}, 0, 0); +checkScanMatch({$and: [{$and: [{a: {$not: /o/}}]}]}, 2, 1); +checkScanMatch({$and: [{$and: [{a: {$not: /a/}}]}]}, 2, 2); +checkScanMatch({$and: [{$or: [{a: /o/}]}]}, 1, 1); +checkScanMatch({$and: [{$or: [{a: /a/}]}]}, 0, 0); +checkScanMatch({$or: [{a: {$not: /o/}}]}, 2, 1); +checkScanMatch({$and: [{$or: [{a: {$not: /o/}}]}]}, 2, 1); +checkScanMatch({$and: [{$or: [{a: {$not: /a/}}]}]}, 2, 2); +checkScanMatch({$and: [{$nor: [{a: /o/}]}]}, 2, 1); +checkScanMatch({$and: [{$nor: [{a: /a/}]}]}, 2, 2); + +checkScanMatch({$where: 'this.a==1'}, 2, 1); +checkScanMatch({$and: [{$where: 'this.a==1'}]}, 2, 1); + +checkScanMatch({a: 1, $where: 'this.a==1'}, 1, 1); +checkScanMatch({a: 1, $and: [{$where: 'this.a==1'}]}, 1, 1); +checkScanMatch({$and: [{a: 1}, {$where: 'this.a==1'}]}, 1, 1); +checkScanMatch({$and: [{a: 1, $where: 'this.a==1'}]}, 1, 1); +checkScanMatch({a: 1, $and: [{a: 1}, {a: 1, $where: 'this.a==1'}]}, 1, 1); + +assert.eq(0, t.find({a: 1, $and: [{a: 2}]}).itcount()); +assert.eq(0, t.find({$and: [{a: 1}, {a: 2}]}).itcount()); |