diff options
author | Kamran Khan <kamran.khan@mongodb.com> | 2015-11-13 12:32:15 -0500 |
---|---|---|
committer | Kamran Khan <kamran.khan@mongodb.com> | 2015-11-13 12:32:15 -0500 |
commit | 15376bdb5345ed321baa7c456237e9439f8e7549 (patch) | |
tree | beddf25ac979c7d0cb59eff9a25c7148e3c0bee1 /jstests/core/sorta.js | |
parent | cd766108b26e7e272f3c367f9de8767399feeadd (diff) | |
download | mongo-15376bdb5345ed321baa7c456237e9439f8e7549.tar.gz |
SERVER-20941 Update v8-specific code and comments in JS tests
The switch to SpiderMonkey invalidated some of the code and comments.
Diffstat (limited to 'jstests/core/sorta.js')
-rw-r--r-- | jstests/core/sorta.js | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/jstests/core/sorta.js b/jstests/core/sorta.js index 7c82778a186..2b78b8493e4 100644 --- a/jstests/core/sorta.js +++ b/jstests/core/sorta.js @@ -1,26 +1,29 @@ // SERVER-2905 sorting with missing fields -t = db.jstests_sorta; -t.drop(); +(function() { + 'use strict'; -// Enable _allow_dot to try and bypass v8 field name checking. -t.insert( {_id:0,a:MinKey}, true ); -t.save( {_id:3,a:null} ); -t.save( {_id:1,a:[]} ); -t.save( {_id:7,a:[2]} ); -t.save( {_id:4} ); -t.save( {_id:5,a:null} ); -t.save( {_id:2,a:[]} ); -t.save( {_id:6,a:1} ); -t.insert( {_id:8,a:MaxKey}, true ); + var t = db.jstests_sorta; + t.drop(); -function sorted( arr ) { - assert.eq( 9, arr.length ); - for( i = 1; i < arr.length; ++i ) { - assert.lte( arr[ i-1 ]._id, arr[ i ]._id ); + assert.writeOK(t.insert({_id: 0, a: MinKey})); + assert.writeOK(t.save({_id: 3, a: null})); + assert.writeOK(t.save({_id: 1, a: []})); + assert.writeOK(t.save({_id: 7, a: [2]})); + assert.writeOK(t.save({_id: 4})); + assert.writeOK(t.save({_id: 5, a: null})); + assert.writeOK(t.save({_id: 2, a: []})); + assert.writeOK(t.save({_id: 6, a: 1})); + assert.writeOK(t.insert({_id: 8, a: MaxKey})); + + function sorted(arr) { + assert.eq(9, arr.length, tojson(arr)); + for (var i = 1; i < arr.length; ++i) { + assert.lte(arr[i - 1]._id, arr[i]._id); + } } -} -sorted( t.find().sort( {a:1} ).toArray() ); -t.ensureIndex( {a:1} ); -sorted( t.find().sort( {a:1} ).hint( {a:1} ).toArray() ); + sorted(t.find().sort({a: 1}).toArray()); + assert.commandWorked(t.ensureIndex({a: 1})); + sorted(t.find().sort({a: 1}).hint({a: 1}).toArray()); +})(); |