test/script/basic/JDK-8025515.js

changeset 750
23cbfa168a4e
parent 582
2016a6b9e1f3
child 952
6d5471a497fb
child 962
ac62e33a99b0
     1.1 --- a/test/script/basic/JDK-8025515.js	Mon Dec 16 23:25:50 2013 +0530
     1.2 +++ b/test/script/basic/JDK-8025515.js	Thu Dec 19 21:53:27 2013 +0530
     1.3 @@ -30,13 +30,23 @@
     1.4  
     1.5  // Make sure synthetic names of anonymous functions have correct line numbers
     1.6  
     1.7 +function getFirstScriptFrame(stack) {
     1.8 +    for (frameNum in stack) {
     1.9 +        var frame = stack[frameNum];
    1.10 +        if (frame.className.startsWith("jdk.nashorn.internal.scripts.Script$")) {
    1.11 +            return frame;
    1.12 +        }
    1.13 +    }
    1.14 +}
    1.15 +
    1.16  function testMethodName(f, expected) {
    1.17      try {
    1.18          f();
    1.19          fail("expected error");
    1.20      } catch (e) {
    1.21 -        var stack = e.getStackTrace();
    1.22 -        if (stack[0].methodName !== expected) {
    1.23 +        var stack = e.nashornException.getStackTrace();
    1.24 +        var name = getFirstScriptFrame(stack).methodName;
    1.25 +        if (name !== expected) {
    1.26              fail("got " + stack[0].methodName + ", expected " + expected);
    1.27          }
    1.28      }
    1.29 @@ -44,15 +54,15 @@
    1.30  
    1.31  testMethodName(function() {
    1.32      return a.b.c;
    1.33 -}, "_L45");
    1.34 +}, "L:55");
    1.35  
    1.36 -testMethodName(function() { throw new Error() }, "_L49");
    1.37 +testMethodName(function() { throw new Error() }, "L:59");
    1.38  
    1.39  var f = (function() {
    1.40      return function() { a.b.c; };
    1.41  })();
    1.42 -testMethodName(f, "_L51$_L52");
    1.43 +testMethodName(f, "L:61$L:62");
    1.44  
    1.45  testMethodName((function() {
    1.46      return function() { return a.b.c; };
    1.47 -})(), "_L56$_L57");
    1.48 +})(), "L:66$L:67");

mercurial