summaryrefslogtreecommitdiff
path: root/jstests/core/type8.js
blob: ceb4993ecb15607dd3a5475a3620b5d77fb0cabc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(function() {
    "use strict";

    // SERVER-8246 Min/MaxKey should be comparable
    //
    // make sure that the MinKey MaxKey JS types are comparable

    function testType(t1, t2) {
        db.minmaxcmp.save({_id: t1});
        var doc = db.minmaxcmp.findOne({_id: t1});
        assert.eq(doc._id, t1, "Value for " + t1 + " did not round-trip to DB correctly");
        assert.neq(doc._id, t2, "Value for " + t1 + " should not equal " + t2);
        assert(doc._id instanceof t1, "Value for " + t1 + "should be instance of" + t1);
        assert(!(doc._id instanceof t2), "Value for " + t1 + "shouldn't be instance of" + t2);
    }
    testType(MinKey, MaxKey);
    testType(MaxKey, MinKey);
})();