jstests/noPassthroughWithMongod/capped6.js
/**
 * Check that documents in the collection are in order according to the value
 * of a, which corresponds to the insert order.  This is a check that the oldest
 * document(s) is/are deleted when space is needed for the newest document.  The
 * check is performed in both forward and reverse directions.
 */
Check that documents in the collection are in order according to the value
of a, which corresponds to the insert order.  This is a check that the oldest
document(s) is/are deleted when space is needed for the newest document.  The
check is performed in both forward and reverse directions.
Check that documents in the collection are in order according to the value of a which corresponds to the insert order . This is a check that the oldest document ( s ) is / are deleted when space is needed for the newest document . The check is performed in both forward and reverse directions .
function checkOrder(i, valueArray) {
    res = coll.find().sort({$natural: -1});
    assert(res.hasNext(), "A");
    var j = i;
    while (res.hasNext()) {
        assert.eq(valueArray[j--].a, res.next().a, "B");
    }
    res = coll.find().sort({$natural: 1});
    assert(res.hasNext(), "C");
    while (res.hasNext()) {
        assert.eq(valueArray[++j].a, res.next().a, "D");
    }
    assert.eq(j, i, "E");
}
function checkOrder ( i , valueArray ) { res = coll . find ( ) . sort ( { $natural : - 1 } ) ; assert ( res . hasNext ( ) , "A" ) ; var j = i ; while ( res . hasNext ( ) ) { assert . eq ( valueArray [ j -- ] . a , res . next ( ) . a , "B" ) ; } res = coll . find ( ) . sort ( { $natural : 1 } ) ; assert ( res . hasNext ( ) , "C" ) ; while ( res . hasNext ( ) ) { assert . eq ( valueArray [ ++ j ] . a , res . next ( ) . a , "D" ) ; } assert . eq ( j , i , "E" ) ; }
Check that documents in the collection are in order according to the value
 of a, which corresponds to the insert order.
Check that documents in the collection are in order according to the value of a which corresponds to the insert order .