|
532 | 532 | }); |
533 | 533 |
|
534 | 534 | test("other", function() { |
535 | | - var mode = pst.mode(UnitTest.fn.createGenericError()); |
536 | | - var frame = function(args, fun, caller) { |
537 | | - this['arguments'] = args; |
538 | | - this.caller = caller; |
539 | | - this.fun = fun; |
540 | | - }; |
541 | | - frame.prototype.toString = function() { |
542 | | - return 'function ' + this.fun + '() {}'; |
543 | | - }; |
544 | | - function f10() { |
545 | | - } |
| 535 | + expect(5); |
| 536 | + var results = []; |
546 | 537 |
|
547 | | - var frame_f2 = new frame([], '', undefined); |
548 | | - var frame_f1 = new frame([1, 'abc', f10, { |
549 | | - 1: { |
550 | | - 2: { |
551 | | - 3: 4 |
552 | | - } |
| 538 | + function f1() { |
| 539 | + try { |
| 540 | + this.undef(); |
| 541 | + } catch (e) { |
| 542 | + var p = impl(); |
| 543 | + results = p.run(e, 'other'); |
553 | 544 | } |
554 | | - }], 'FUNCTION f1 (a,b,c)', frame_f2); |
555 | | - |
556 | | - expect(mode == 'other' ? 4 : 2); |
557 | | - var message = pst.other(frame_f1); |
558 | | - equals(message[0].indexOf('f1(1,"abc",#function,#object)') >= 0, true, 'f1'); |
559 | | - equals(message[1].indexOf('{anonymous}()') >= 0, true, 'f2 anonymous'); |
| 545 | + } |
560 | 546 |
|
561 | | - if (mode == 'other') { |
562 | | - function f1(arg1, arg2) { |
563 | | - var message = pst.other(arguments.callee); |
564 | | - //equals(message.join("\n"), '', 'debug'); |
565 | | - equals(message[0].indexOf('f1(1,"abc",#function,#object)') >= 0, true, 'f1'); |
566 | | - equals(message[1].indexOf('{anonymous}()') >= 0, true, 'f2 anonymous'); |
567 | | - } |
| 547 | + function f2() { |
| 548 | + f1(0, 'abc', f1, {a: 0}); |
| 549 | + } |
568 | 550 |
|
569 | | - var f2 = function() { |
570 | | - f1(1, 'abc', f10, { |
571 | | - 1: { |
572 | | - 2: { |
573 | | - 3: 4 |
574 | | - } |
575 | | - } |
576 | | - }); |
577 | | - }; |
| 551 | + (function longName_$1() { |
578 | 552 | f2(); |
579 | | - } |
| 553 | + }()); |
| 554 | + |
| 555 | + ok(results.length >= 3, 'Call chain should contain at least 4 frames'); |
| 556 | + //equals(results, '', 'debug'); |
| 557 | + equals(results[1], 'f1(0,"abc",#function,#object)'); |
| 558 | + equals(results[2], 'f2()'); |
| 559 | + equals(results[3], 'longName_$1()'); |
| 560 | + equals(results[4], '{anonymous}()'); |
580 | 561 | }); |
581 | 562 |
|
582 | 563 | test("other in strict mode", function() { |
| 564 | + expect(3); |
583 | 565 | var results = []; |
584 | 566 | var p = impl(); |
585 | 567 |
|
586 | 568 | function f1() { |
587 | 569 | try { |
588 | 570 | this.undef(); |
589 | 571 | } catch (e) { |
590 | | - debugger; |
591 | 572 | results = p.run(e, 'other'); |
592 | 573 | } |
593 | 574 | } |
|
603 | 584 |
|
604 | 585 | f3(); |
605 | 586 |
|
606 | | - ok(results.length >= 3, 'Stack should contain at least 3 frames in non-strict mode'); |
| 587 | + ok(results.length >= 3, 'Call chain should contain at least 3 frames (2 non-strict and 1 strict)'); |
607 | 588 | //equals(results, '', 'debug'); |
608 | 589 | equals(results[1], 'f1()'); |
609 | 590 | equals(results[2], 'f2()'); |
|
0 commit comments