Home | History | Annotate | Download | only in webkit

Lines Matching refs:Constructor

24 description('This test makes sure that instance of behaves correctly when the value, constructor, or its prototype are immediates.');
26 // A Constructor to use check for instances of, and an instance called obj.
27 function Constructor() {}
28 var obj = new Constructor();
30 // Run a batch of tests; call'testInstanceOf' three times, passing 1, {}, and the object 'obj', which is an instance of Constructor.
31 function testSet(constructor, testMethod)
33 testMethod["1"]("(1 instanceof " + constructor + ")");
34 testMethod["{}"]("({} instanceof " + constructor + ")");
35 testMethod["obj"]("(obj instanceof " + constructor + ")");
38 // Test set 1, test passing the integer 1 as the constructor to be tested for.
39 // The constructor being an object is the first thing tested, so these should all throw.
42 // Test set 2, test passing an empty object ({}) as the constructor to be tested for.
43 // As well as being an object, the constructor must implement 'HasInstance' (i.e. be a function), so these should all throw too.
46 // Test set 3, test passing Constructor as the constructor to be tested for.
47 // Nothing should except, the third test should pass, since obj is an instance of Constructor.
48 testSet("Constructor", { "1":shouldBeFalse, "{}":shouldBeFalse, "obj":shouldBeTrue });
50 // Test set 4, test passing Constructor as the constructor to be tested for - with Constructor.prototype set to the integer 1.
51 // Constructor.prototype being a non-object will cause an exception, /unless/ value is also a non-object, since this is checked first.
52 Constructor.prototype = 1;
53 testSet("Constructor", { "1":shouldBeFalse, "{}":shouldThrow, "obj":shouldThrow });
55 // Test set 5, test passing Constructor as the constructor to be tested for - with Constructor.prototype set to an empty object ({}).
56 // All test fail, no reason to throw. (obj instanceof Constructor) is now false, since Constructor.prototype has changed.
57 Constructor.prototype = {};
58 testSet("Constructor", { "1":shouldBeFalse, "{}":shouldBeFalse, "obj":shouldBeFalse });
60 // Test set 6, test passing Constructor as the constructor to be tested for - with Constructor.prototype set to null.
62 Constructor.prototype = null;
63 testSet("Constructor", { "1":shouldBeFalse, "{}":shouldThrow, "obj":shouldThrow });