~ubuntu-branches/ubuntu/trusty/mongodb/trusty-proposed

« back to all changes in this revision

Viewing changes to jstests/sort_numeric.js

  • Committer: Bazaar Package Importer
  • Author(s): Antonin Kral
  • Date: 2010-01-29 19:48:45 UTC
  • Revision ID: james.westby@ubuntu.com-20100129194845-8wbmkf626fwcavc9
Tags: upstream-1.3.1
ImportĀ upstreamĀ versionĀ 1.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
t = db.sort_numeric;
 
3
t.drop();
 
4
 
 
5
// there are two numeric types int he db; make sure it handles them right
 
6
// for comparisons.
 
7
 
 
8
t.save( { a : 3 } );
 
9
t.save( { a : 3.1 } );
 
10
t.save( { a : 2.9 } );
 
11
t.save( { a : 1 } );
 
12
t.save( { a : 1.9 } );
 
13
t.save( { a : 5 } );
 
14
t.save( { a : 4.9 } );
 
15
t.save( { a : 2.91 } );
 
16
 
 
17
for( var pass = 0; pass < 2; pass++ ) { 
 
18
 
 
19
    var c = t.find().sort({a:1});
 
20
    var last = 0;
 
21
    while( c.hasNext() ) {
 
22
        current = c.next();
 
23
        assert( current.a > last );
 
24
        last = current.a;
 
25
    }
 
26
 
 
27
    assert( t.find({a:3}).count() == 1 );
 
28
    assert( t.find({a:3.0}).count() == 1 );
 
29
    assert( t.find({a:3.0}).length() == 1 );
 
30
 
 
31
    t.ensureIndex({a:1});
 
32
}
 
33
 
 
34
assert(t.validate().valid);
 
35