diff options
author | Antonin Kral <a.kral@bobek.cz> | 2011-09-14 17:08:06 +0200 |
---|---|---|
committer | Antonin Kral <a.kral@bobek.cz> | 2011-09-14 17:08:06 +0200 |
commit | 5d342a758c6095b4d30aba0750b54f13b8916f51 (patch) | |
tree | 762e9aa84781f5e3b96db2c02d356c29cf0217c0 /jstests/sort2.js | |
parent | cbe2d992e9cd1ea66af9fa91df006106775d3073 (diff) | |
download | mongodb-5d342a758c6095b4d30aba0750b54f13b8916f51.tar.gz |
Imported Upstream version 2.0.0
Diffstat (limited to 'jstests/sort2.js')
-rw-r--r-- | jstests/sort2.js | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/jstests/sort2.js b/jstests/sort2.js index 1e21414..6dfa848 100644 --- a/jstests/sort2.js +++ b/jstests/sort2.js @@ -1,22 +1,32 @@ // test sorting, mainly a test ver simple with no index t = db.sort2; -t.drop(); +t.drop(); t.save({x:1, y:{a:5,b:4}}); t.save({x:1, y:{a:7,b:3}}); t.save({x:1, y:{a:2,b:3}}); t.save({x:1, y:{a:9,b:3}}); - for( var pass = 0; pass < 2; pass++ ) { - var res = t.find().sort({'y.a':1}).toArray(); assert( res[0].y.a == 2 ); assert( res[1].y.a == 5 ); assert( res.length == 4 ); - t.ensureIndex({"y.a":1}); - } - assert(t.validate().valid); + +t.drop(); +t.insert({ x: 1 }) +t.insert({ x: 5000000000 }) +t.insert({ x: NaN }); +t.insert({ x: Infinity }); +t.insert({ x: -Infinity }); +var good = [NaN, -Infinity, 1, 5000000000, Infinity]; +for (var pass = 0; pass < 2; pass++) { + var res = t.find({}, { _id: 0 }).sort({ x: 1 }).toArray(); + for (var i = 0; i < good.length; i++) { + assert(good[i].toString() == res[i].x.toString()); + } + t.ensureIndex({ x : 1 }); +} |