summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Hannan <tony@10gen.com>2011-08-09 09:22:34 -0400
committerTony Hannan <tony@10gen.com>2011-08-09 09:22:34 -0400
commitad2f56a651b0b25f7a63ca4f533bdbc48b8c6ef0 (patch)
treee91d16510417dc79cea2f337a4efb132fbaac633
parentb52af9b709dfa905eb4585c537b69b32da1caaaa (diff)
downloadmongo-ad2f56a651b0b25f7a63ca4f533bdbc48b8c6ef0.tar.gz
new jstests/date3.js for SERVER-405 & SERVER-960
-rw-r--r--jstests/date3.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/jstests/date3.js b/jstests/date3.js
new file mode 100644
index 00000000000..81b385a8616
--- /dev/null
+++ b/jstests/date3.js
@@ -0,0 +1,29 @@
+// Check dates before Unix epoch - SERVER-405
+
+t = db.date3;
+t.drop()
+
+d1 = new Date(-1000)
+dz = new Date(0)
+d2 = new Date(1000)
+
+t.save( {x: 2, d: d2} )
+t.save( {x: 1, d: d1} )
+
+function test () {
+ var list = t.find( {d: {$lt: dz}} )
+ assert.eq ( 1, list.size() )
+ assert.eq ( 1, list[0].x )
+ assert.eq ( d1, list[0].d )
+ var list = t.find( {d: {$gt: dz}} )
+ assert.eq ( 1, list.size() )
+ assert.eq ( 2, list[0].x )
+ var list = t.find().sort( {d:1} )
+ assert.eq ( 2, list.size() )
+ assert.eq ( 1, list[0].x )
+ assert.eq ( 2, list[1].x )
+}
+
+test()
+t.ensureIndex( {d: 1} )
+test()