js/src/jit-test/tests/proxy/testDirectProxyConstructor.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/proxy/testDirectProxyConstructor.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,23 @@
     1.4 +load(libdir + "asserts.js");
     1.5 +
     1.6 +// Throw a TypeError if Proxy is called with less than two arguments
     1.7 +assertThrowsInstanceOf(function () { Proxy(); }, TypeError);
     1.8 +assertThrowsInstanceOf(function () { new Proxy(); }, TypeError);
     1.9 +assertThrowsInstanceOf(function () { Proxy({}); }, TypeError);
    1.10 +assertThrowsInstanceOf(function () { new Proxy({}); }, TypeError);
    1.11 +
    1.12 +// Throw a TypeError if the first argument is not a non-null object
    1.13 +assertThrowsInstanceOf(function () { Proxy(0, {}); }, TypeError);
    1.14 +assertThrowsInstanceOf(function () { new Proxy(0, {}); }, TypeError);
    1.15 +assertThrowsInstanceOf(function () { Proxy(null, {}); }, TypeError);
    1.16 +assertThrowsInstanceOf(function () { new Proxy(null, {}); }, TypeError);
    1.17 +
    1.18 +// Throw a TypeError if the second argument is not a non-null object
    1.19 +assertThrowsInstanceOf(function () { Proxy({}, 0); }, TypeError);
    1.20 +assertThrowsInstanceOf(function () { new Proxy({}, 0); }, TypeError);
    1.21 +assertThrowsInstanceOf(function () { Proxy({}, null); }, TypeError);
    1.22 +assertThrowsInstanceOf(function () { new Proxy({}, null); }, TypeError);
    1.23 +
    1.24 +// Result of the call should be an object
    1.25 +assertEq(typeof Proxy({}, {}), 'object');
    1.26 +assertEq(typeof new Proxy({}, {}), 'object');

mercurial