summaryrefslogtreecommitdiff
path: root/jstests/core/type4.js
blob: c7e111106184750393baad2a84adc5fd249a236f (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
(function() {
"use strict";

// Tests for SERVER-20080
//
// Verify that various types cannot be invoked as constructors

var t = db.jstests_type4;
t.drop();
t.insert({});
t.insert({});
t.insert({});

assert.throws(function() {
    (new _rand())();
}, [], "invoke constructor on natively injected function");

assert.throws(function() {
    var doc = db.test.findOne();
    new doc();
}, [], "invoke constructor on BSON");

assert.throws(function() {
    var cursor = t.find();
    cursor.next();

    new cursor._cursor._cursorHandle();
}, [], "invoke constructor on CursorHandle");
})();