summaryrefslogtreecommitdiff
path: root/jstests/core/eval2.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/core/eval2.js')
-rw-r--r--jstests/core/eval2.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/jstests/core/eval2.js b/jstests/core/eval2.js
new file mode 100644
index 00000000000..6e39bb4a7bd
--- /dev/null
+++ b/jstests/core/eval2.js
@@ -0,0 +1,28 @@
+
+t = db.eval2;
+t.drop();
+t.save({a:1});
+t.save({a:1});
+
+var f = db.group(
+ {
+ ns: t.getName(),
+ key: { a:true},
+ cond: { a:1 },
+ reduce: function(obj,prev) { prev.csum++; } ,
+ initial: { csum: 0}
+ }
+);
+
+assert(f[0].a == 1 && f[0].csum == 2 , "on db" );
+
+var f = t.group(
+ {
+ key: { a:true},
+ cond: { a:1 },
+ reduce: function(obj,prev) { prev.csum++; } ,
+ initial: { csum: 0}
+ }
+);
+
+assert(f[0].a == 1 && f[0].csum == 2 , "on coll" );