Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | // Flags: --nostress-opt |
| 6 | |
| 7 | Error.prepareStackTrace = function(exception, frames) { |
| 8 | return frames[0].getEvalOrigin(); |
| 9 | } |
| 10 | |
| 11 | var source = "new Error()"; |
| 12 | var eval_origin; |
| 13 | var geval = eval; |
| 14 | var log = []; |
| 15 | |
| 16 | (function() { |
| 17 | log.push([geval(source).stack, "17:13"]); |
| 18 | log.push([geval(source).stack, "18:13"]); |
| 19 | // log.push([geval(source).stack, "19:13"]); TODO(4921). |
| 20 | })(); |
| 21 | |
| 22 | (function() { |
| 23 | log.push([eval(source).stack, "23:13"]); |
| 24 | log.push([eval(source).stack, "24:13"]); |
| 25 | // log.push([eval(source).stack, "25:13"]); TODO(4921). |
| 26 | })(); |
| 27 | |
| 28 | log.push([eval(source).stack, "28:11"]); |
| 29 | log.push([eval(source).stack, "29:11"]); |
| 30 | // log.push([eval(source).stack, "30:11"]); TODO(4921). |
| 31 | |
| 32 | Error.prepareStackTrace = undefined; |
| 33 | |
| 34 | for (var item of log) { |
| 35 | var stacktraceline = item[0]; |
| 36 | var expectation = item[1]; |
| 37 | var re = new RegExp(`:${expectation}\\)$`); |
| 38 | assertTrue(re.test(stacktraceline)); |
| 39 | } |