summaryrefslogtreecommitdiff
path: root/jstests/core/sort_numeric.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/core/sort_numeric.js')
-rw-r--r--jstests/core/sort_numeric.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/jstests/core/sort_numeric.js b/jstests/core/sort_numeric.js
new file mode 100644
index 00000000000..807f23dfe8d
--- /dev/null
+++ b/jstests/core/sort_numeric.js
@@ -0,0 +1,35 @@
+
+t = db.sort_numeric;
+t.drop();
+
+// there are two numeric types int he db; make sure it handles them right
+// for comparisons.
+
+t.save( { a : 3 } );
+t.save( { a : 3.1 } );
+t.save( { a : 2.9 } );
+t.save( { a : 1 } );
+t.save( { a : 1.9 } );
+t.save( { a : 5 } );
+t.save( { a : 4.9 } );
+t.save( { a : 2.91 } );
+
+for( var pass = 0; pass < 2; pass++ ) {
+
+ var c = t.find().sort({a:1});
+ var last = 0;
+ while( c.hasNext() ) {
+ current = c.next();
+ assert( current.a > last );
+ last = current.a;
+ }
+
+ assert( t.find({a:3}).count() == 1 );
+ assert( t.find({a:3.0}).count() == 1 );
+ assert( t.find({a:3.0}).length() == 1 );
+
+ t.ensureIndex({a:1});
+}
+
+assert(t.validate().valid);
+