summaryrefslogtreecommitdiff
path: root/jstests/jni3.js
blob: ab0cdc00918645b4b086663434b42604a2b8b2d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

db = connect( "foo");
t = db.jni3;

for( z = 0; z < 2; z++ ) {
    print(z);
    
    t.drop();
    
    if( z > 0 ) {
	t.ensureIndex({_id:1});
	t.ensureIndex({i:1});
    }
    
    for( i = 0; i < 1000; i++ )
	t.save( { i:i, z: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } );
    
    assert( 33 == db.dbEval(function() { return 33; } ) );
    
    db.dbEval( function() { db.jni3.save({i:-1, z:"server side"}) } );
    
    assert( db.jni3.findOne({i:-1}) );
    
    assert( 2 == t.find( { $where : 
			   function(){ 
                               return obj.i == 7 || obj.i == 8;
			   } 
			 } ).length() );
    
    
    // NPE test
    var ok = false;
    try {
        var x = t.find( { $where : 
			  function(){ 
                              asdf.asdf.f.s.s();
			  } 
	                } );
        print( x.length() );
        print( tojson( x ) );
    }
    catch(e) { 
	ok = true;
    }
    assert(ok);
    
    t.ensureIndex({z:1});
    t.ensureIndex({q:1});
    
    assert( 2 == t.find( { $where : 
			   function(){ 
                               return obj.i == 7 || obj.i == 8;
			   } 
			 } ).length() );
    
    for( i = 1000; i < 2000; i++ )
	t.save( { i:i, z: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } );
    
    assert( t.find().count() == 2001 );
    
    assert( t.validate().valid );
    
}