2021-03-09 11:18:52 +00:00
|
|
|
// Copyright 2021 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.
|
|
|
|
|
2021-04-06 15:26:09 +00:00
|
|
|
// Flags: --always-sparkplug --allow-natives-syntax
|
2021-03-09 11:18:52 +00:00
|
|
|
|
|
|
|
// This test mainly exists to make ClusterFuzz aware of
|
|
|
|
// d8.test.verifySourcePositions.
|
|
|
|
|
|
|
|
globalValue = false;
|
|
|
|
|
|
|
|
function foo(param1, ...param2) {
|
|
|
|
try {
|
|
|
|
for (let key in param1) { param2.push(key); }
|
|
|
|
for (let a of param1) { param2.push(a); }
|
|
|
|
let [a, b] = param2;
|
|
|
|
let copy = [{literal:1}, {}, [], [1], 1, ...param2];
|
|
|
|
return a + b + copy.length;
|
|
|
|
} catch (e) {
|
|
|
|
return e.toString().match(/[a-zA-Z]+/g);
|
|
|
|
} finally {
|
|
|
|
globalValue = new String(23);
|
|
|
|
}
|
|
|
|
return Math.min(Math.random(), 0.5);
|
|
|
|
}
|
|
|
|
|
|
|
|
var obj = [...Array(10).keys()];
|
|
|
|
obj.foo = 'bar';
|
|
|
|
foo(obj, obj);
|
|
|
|
|
|
|
|
d8.test.verifySourcePositions(foo);
|
2021-03-10 08:55:16 +00:00
|
|
|
|
2021-04-06 15:26:09 +00:00
|
|
|
// Make sure invalid calls throw.
|
2021-04-07 07:39:58 +00:00
|
|
|
assertThrows(() => {d8.test.verifySourcePositions(0)});
|
|
|
|
assertThrows(() => {d8.test.verifySourcePositions(obj)});
|
2021-04-06 15:26:09 +00:00
|
|
|
assertThrows(() => {d8.test.verifySourcePositions(new Proxy(foo, {}))});
|
|
|
|
assertThrows(() => {d8.test.verifySourcePositions(%GetUndetectable())});
|