summaryrefslogtreecommitdiff
path: root/jstests/all.js
diff options
context:
space:
mode:
authorAntonin Kral <a.kral@bobek.cz>2010-01-31 08:32:52 +0100
committerAntonin Kral <a.kral@bobek.cz>2010-01-31 08:32:52 +0100
commit4eefaf421bfeddf040d96a3dafb12e09673423d7 (patch)
treecb2e5ccc7f98158894f977ff131949da36673591 /jstests/all.js
downloadmongodb-4eefaf421bfeddf040d96a3dafb12e09673423d7.tar.gz
Imported Upstream version 1.3.1
Diffstat (limited to 'jstests/all.js')
-rw-r--r--jstests/all.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/jstests/all.js b/jstests/all.js
new file mode 100644
index 0000000..3d642ee
--- /dev/null
+++ b/jstests/all.js
@@ -0,0 +1,45 @@
+t = db.jstests_all;
+t.drop();
+
+doTest = function() {
+
+ t.save( { a:[ 1,2,3 ] } );
+ t.save( { a:[ 1,2,4 ] } );
+ t.save( { a:[ 1,8,5 ] } );
+ t.save( { a:[ 1,8,6 ] } );
+ t.save( { a:[ 1,9,7 ] } );
+
+ assert.eq( 5, t.find( { a: { $all: [ 1 ] } } ).count() );
+ assert.eq( 2, t.find( { a: { $all: [ 1, 2 ] } } ).count() );
+ assert.eq( 2, t.find( { a: { $all: [ 1, 8 ] } } ).count() );
+ assert.eq( 1, t.find( { a: { $all: [ 1, 3 ] } } ).count() );
+ assert.eq( 2, t.find( { a: { $all: [ 2 ] } } ).count() );
+ assert.eq( 1, t.find( { a: { $all: [ 2, 3 ] } } ).count() );
+ assert.eq( 2, t.find( { a: { $all: [ 2, 1 ] } } ).count() );
+
+ t.save( { a: [ 2, 2 ] } );
+ assert.eq( 3, t.find( { a: { $all: [ 2, 2 ] } } ).count() );
+
+ t.save( { a: [ [ 2 ] ] } );
+ assert.eq( 3, t.find( { a: { $all: [ 2 ] } } ).count() );
+
+ t.save( { a: [ { b: [ 10, 11 ] }, 11 ] } );
+ assert.eq( 1, t.find( { 'a.b': { $all: [ 10 ] } } ).count() );
+ assert.eq( 1, t.find( { a: { $all: [ 11 ] } } ).count() );
+
+ t.save( { a: { b: [ 20, 30 ] } } );
+ assert.eq( 1, t.find( { 'a.b': { $all: [ 20 ] } } ).count() );
+ assert.eq( 1, t.find( { 'a.b': { $all: [ 20, 30 ] } } ).count() );
+
+
+ assert.eq( 5 , t.find( { a : { $all : [1] } } ).count() , "E1" );
+ assert.eq( 0 , t.find( { a : { $all : [19] } } ).count() , "E2" );
+ assert.eq( 0 , t.find( { a : { $all : [] } } ).count() , "E3" );
+
+
+}
+
+doTest();
+t.drop();
+t.ensureIndex( {a:1} );
+doTest();