blob: 00e61cb70a078f71e8fba7788ed702492f70095d [file] [log] [blame]
Ben Murdoch61f157c2016-09-16 13:49:30 +01001// Copyright 2016 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5var thrower = { [Symbol.toPrimitive]: () => FAIL };
6
7// Tests that a native conversion function is included in the
8// stack trace.
9function testTraceNativeConversion(nativeFunc) {
10 var nativeFuncName = nativeFunc.name;
11 try {
12 nativeFunc(thrower);
13 assertUnreachable(nativeFuncName);
14 } catch (e) {
15 assertTrue(e.stack.indexOf(nativeFuncName) >= 0, nativeFuncName);
16 }
17}
18
19testTraceNativeConversion(Math.max);
20testTraceNativeConversion(Math.min);
21
22function testBuiltinInStackTrace(script, nativeFuncName) {
23 try {
24 eval(script);
25 assertUnreachable(nativeFuncName);
26 } catch (e) {
27 assertTrue(e.stack.indexOf(nativeFuncName) >= 0, nativeFuncName);
28 }
29}
30
31// Use the full name ('String.getDate') in order to avoid false pass
32// results when the method name is mentioned in the error message itself.
33// This occurs, e.g., for Date.prototype.getYear, which uses a different code
34// path and never hits the Generate_DatePrototype_GetField builtin.
35testBuiltinInStackTrace("Date.prototype.getDate.call('')", "String.getDate");
36testBuiltinInStackTrace("Date.prototype.getUTCDate.call('')",
37 "String.getUTCDate");
38testBuiltinInStackTrace("Date.prototype.getTime.call('')", "String.getTime");