-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathisinstanceof.js
37 lines (28 loc) · 1.58 KB
/
isinstanceof.js
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
30
31
32
33
34
35
36
37
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Copyright (c) ChakraCore Project Contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
// @ts-check
/// <reference path="..\UnitTestFramework\UnitTestFramework.js" />
WScript.LoadScriptFile("..\\UnitTestFramework\\UnitTestFramework.js");
const tests = [{
name: "Clear IsInstInlineCache of 'Object.setPrototypeOf'",
body: function () {
// See https://github.com/chakra-core/ChakraCore/issues/5915
function Component() { }
function Shape() { }
function Box() { }
Box.prototype = Object.create(Shape.prototype);
Box.prototype.constructor = Box;
function checkInstanceOf(a, b) {
return a instanceof b;
}
assert.isFalse(Box.prototype instanceof Component, "Box.prototype instanceof Component");
assert.isFalse(checkInstanceOf(Box.prototype, Component), "checkInstanceOf(Box.prototype, Component)");
Object.setPrototypeOf(Shape.prototype, Component.prototype);
assert.isTrue(Box.prototype instanceof Component, "Box.prototype instanceof Component");
assert.isTrue(checkInstanceOf(Box.prototype, Component), "checkInstanceOf(Box.prototype, Component)");
}
}];
testRunner.runTests(tests, { verbose: WScript.Arguments[0] != "summary" });