2017-07-27 13:09:49 +00:00
|
|
|
// Copyright 2017 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 TestNonCallableForEach() {
|
2019-06-12 14:00:50 +00:00
|
|
|
function foo() {
|
|
|
|
[].forEach(undefined);
|
|
|
|
};
|
|
|
|
%PrepareFunctionForOptimization(foo);
|
2017-07-27 13:09:49 +00:00
|
|
|
assertThrows(foo, TypeError);
|
|
|
|
assertThrows(foo, TypeError);
|
|
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
|
|
assertThrows(foo, TypeError);
|
|
|
|
})();
|
|
|
|
|
|
|
|
(function TestNonCallableForEachCaught() {
|
2019-06-12 14:00:50 +00:00
|
|
|
function foo() {
|
|
|
|
try {
|
|
|
|
[].forEach(undefined);
|
|
|
|
} catch (e) {
|
|
|
|
return e;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
%PrepareFunctionForOptimization(foo);
|
2017-07-27 13:09:49 +00:00
|
|
|
assertInstanceof(foo(), TypeError);
|
|
|
|
assertInstanceof(foo(), TypeError);
|
|
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
|
|
assertInstanceof(foo(), TypeError);
|
|
|
|
})();
|
|
|
|
|
|
|
|
(function TestNonCallableMap() {
|
2019-06-12 14:00:50 +00:00
|
|
|
function foo() {
|
|
|
|
[].map(undefined);
|
|
|
|
};
|
|
|
|
%PrepareFunctionForOptimization(foo);
|
2017-07-27 13:09:49 +00:00
|
|
|
assertThrows(foo, TypeError);
|
|
|
|
assertThrows(foo, TypeError);
|
|
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
|
|
assertThrows(foo, TypeError);
|
|
|
|
})();
|
|
|
|
|
|
|
|
(function TestNonCallableMapCaught() {
|
2019-06-12 14:00:50 +00:00
|
|
|
function foo() {
|
|
|
|
try {
|
|
|
|
[].map(undefined);
|
|
|
|
} catch (e) {
|
|
|
|
return e;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
%PrepareFunctionForOptimization(foo);
|
2017-07-27 13:09:49 +00:00
|
|
|
assertInstanceof(foo(), TypeError);
|
|
|
|
assertInstanceof(foo(), TypeError);
|
|
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
|
|
assertInstanceof(foo(), TypeError);
|
|
|
|
})();
|
2017-10-23 14:23:27 +00:00
|
|
|
|
|
|
|
(function TestNonCallableFilter() {
|
2019-06-12 14:00:50 +00:00
|
|
|
function foo() {
|
|
|
|
[].filter(undefined);
|
|
|
|
};
|
|
|
|
%PrepareFunctionForOptimization(foo);
|
2017-10-23 14:23:27 +00:00
|
|
|
assertThrows(foo, TypeError);
|
|
|
|
assertThrows(foo, TypeError);
|
|
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
|
|
assertThrows(foo, TypeError);
|
|
|
|
})();
|
|
|
|
|
|
|
|
(function TestNonCallableFilterCaught() {
|
2019-06-12 14:00:50 +00:00
|
|
|
function foo() {
|
|
|
|
try {
|
|
|
|
[].filter(undefined);
|
|
|
|
} catch (e) {
|
|
|
|
return e;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
%PrepareFunctionForOptimization(foo);
|
2017-10-23 14:23:27 +00:00
|
|
|
assertInstanceof(foo(), TypeError);
|
|
|
|
assertInstanceof(foo(), TypeError);
|
|
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
|
|
assertInstanceof(foo(), TypeError);
|
|
|
|
})();
|