|
559 | 559 | }); |
560 | 560 |
|
561 | 561 | test("findFunctionName", function() { |
562 | | - expect(12); |
| 562 | + expect(13); |
563 | 563 | equals(pst.findFunctionName(['var a = function aa() {', 'var b = 2;', '};'], 2), 'a'); |
564 | 564 | equals(pst.findFunctionName(['var a = function () {', 'var b = 2;', '};'], 2), 'a'); |
565 | 565 | equals(pst.findFunctionName(['var a = function() {', 'var b = 2;', '};'], 2), 'a'); |
566 | 566 | // FIXME: currently failing because we don't have a way to distinguish which fn is being sought |
567 | 567 | // equals(pst.findFunctionName(['a:function(){},b:function(){', '};'], 1), 'b'); |
568 | 568 | equals(pst.findFunctionName(['"a": function(){', '};'], 1), 'a'); |
569 | 569 |
|
| 570 | + // different formatting |
570 | 571 | equals(pst.findFunctionName(['function a() {', 'var b = 2;', '}'], 2), 'a'); |
571 | 572 | equals(pst.findFunctionName(['function a(b,c) {', 'var b = 2;', '}'], 2), 'a'); |
572 | 573 | equals(pst.findFunctionName(['function a () {', '}'], 2), 'a'); |
|
576 | 577 | equals(pst.findFunctionName(['var data = new Function("return true;");', ''], 1), 'data'); |
577 | 578 | equals(pst.findFunctionName(['var data = new Function("s,r",', '"return s + r;");'], 1), 'data'); |
578 | 579 |
|
| 580 | + // not found |
579 | 581 | equals(pst.findFunctionName(['var a = 1;', 'var b = 2;', 'var c = 3;'], 2), '(?)'); |
580 | 582 |
|
| 583 | + // false positive in comment |
581 | 584 | equals(pst.findFunctionName(['function a() {', ' // function commented()', ' error here', '}'], 3), 'a'); |
582 | 585 | }); |
583 | 586 |
|
|
0 commit comments