summaryrefslogtreecommitdiff
path: root/jstests/sort2.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/sort2.js')
-rw-r--r--jstests/sort2.js22
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 });
+}