OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 var thrower = { [Symbol.toPrimitive]: () => FAIL }; | 5 var thrower = { [Symbol.toPrimitive]: () => FAIL }; |
6 | 6 |
7 // Tests that a native conversion function is included in the | 7 // Tests that a native conversion function is included in the |
8 // stack trace. | 8 // stack trace. |
9 function testTraceNativeConversion(nativeFunc) { | 9 function testTraceNativeConversion(nativeFunc) { |
10 var nativeFuncName = nativeFunc.name; | 10 var nativeFuncName = nativeFunc.name; |
11 try { | 11 try { |
12 nativeFunc(thrower); | 12 nativeFunc(thrower); |
13 assertUnreachable(nativeFuncName); | 13 assertUnreachable(nativeFuncName); |
14 } catch (e) { | 14 } catch (e) { |
15 assertTrue(e.stack.indexOf(nativeFuncName) >= 0, nativeFuncName); | 15 assertTrue(e.stack.indexOf(nativeFuncName) >= 0, nativeFuncName); |
16 } | 16 } |
17 } | 17 } |
18 | 18 |
19 testTraceNativeConversion(Math.max); | 19 testTraceNativeConversion(Math.max); |
20 testTraceNativeConversion(Math.min); | 20 testTraceNativeConversion(Math.min); |
| 21 |
| 22 function 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 testBuiltinInStackTrace("Date.prototype.getDate.call('')", "getDate"); |
| 32 testBuiltinInStackTrace("Date.prototype.getUTCDate.call('')", "getUTCDate"); |
| 33 testBuiltinInStackTrace("Date.prototype.getTime.call('')", "getTime"); |
| 34 testBuiltinInStackTrace("Date.prototype.getYear.call('')", "getYear"); |
OLD | NEW |