From 7b48713334469818661fe276cf571de9c7899f2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Tue, 12 Mar 2019 09:01:49 +0100 Subject: deps: update V8 to 7.3.492.25 PR-URL: https://github.com/nodejs/node/pull/25852 Reviewed-By: Ujjwal Sharma Reviewed-By: Matteo Collina Reviewed-By: Ali Ijaz Sheikh --- .../instance-of-overridden-has-instance.js | 106 +++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 deps/v8/test/mjsunit/compiler/instance-of-overridden-has-instance.js (limited to 'deps/v8/test/mjsunit/compiler/instance-of-overridden-has-instance.js') diff --git a/deps/v8/test/mjsunit/compiler/instance-of-overridden-has-instance.js b/deps/v8/test/mjsunit/compiler/instance-of-overridden-has-instance.js new file mode 100644 index 0000000000..49c8899e69 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/instance-of-overridden-has-instance.js @@ -0,0 +1,106 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +(function NonConstHasInstance() { + var C = { + [Symbol.hasInstance] : () => true + }; + + function f() { + return {} instanceof C; + } + + assertTrue(f()); + assertTrue(f()); + %OptimizeFunctionOnNextCall(f); + assertTrue(f()); + C[Symbol.hasInstance] = () => false; + assertFalse(f()); +})(); + +(function NumberHasInstance() { + var C = { + [Symbol.hasInstance] : 0.1 + }; + + function f(b, C) { + if (b) return {} instanceof C; + return false; + } + + function g(b) { + return f(b, C); + } + + assertFalse(f(true, Number)); + assertFalse(f(true, Number)); + assertFalse(g(false)); + assertFalse(g(false)); + %OptimizeFunctionOnNextCall(g); + assertThrows(() => g(true)); +})(); + +(function NonFunctionHasInstance() { + var C = { + [Symbol.hasInstance] : {} + }; + + function f(b, C) { + if (b) return {} instanceof C; + return false; + } + + function g(b) { + return f(b, C); + } + + assertFalse(f(true, Number)); + assertFalse(f(true, Number)); + assertFalse(g(false)); + assertFalse(g(false)); + %OptimizeFunctionOnNextCall(g); + assertThrows(() => g(true)); +})(); + +(function NonConstHasInstanceProto() { + var B = { + [Symbol.hasInstance]() { return true; } + }; + + var C = { __proto__ : B }; + + function f() { + return {} instanceof C; + } + + assertTrue(f()); + assertTrue(f()); + %OptimizeFunctionOnNextCall(f); + assertTrue(f()); + B[Symbol.hasInstance] = () => { return false; }; + assertFalse(f()); +})(); + +(function HasInstanceOverwriteOnProto() { + var A = { + [Symbol.hasInstance] : () => false + } + + var B = { __proto__ : A }; + + var C = { __proto__ : B }; + + function f() { + return {} instanceof C; + } + + assertFalse(f()); + assertFalse(f()); + %OptimizeFunctionOnNextCall(f); + assertFalse(f()); + B[Symbol.hasInstance] = () => { return true; }; + assertTrue(f()); +})(); -- cgit v1.2.1