1 33 34 package edu.rice.cs.drjava.model.definitions; 35 36 import edu.rice.cs.drjava.DrJava; 37 import edu.rice.cs.drjava.DrJavaTestCase; 38 import edu.rice.cs.drjava.config.OptionConstants; 39 import edu.rice.cs.drjava.model.GlobalEventNotifier; 40 import edu.rice.cs.drjava.model.definitions.reducedmodel.BraceReduction; 41 import edu.rice.cs.drjava.model.definitions.reducedmodel.HighlightStatus; 42 import edu.rice.cs.drjava.model.definitions.reducedmodel.ReducedModelStates; 43 import edu.rice.cs.drjava.model.definitions.reducedmodel.ReducedToken; 44 import junit.framework.Test; 45 import junit.framework.TestSuite; 46 47 import javax.swing.text.BadLocationException ; 48 import java.util.Vector ; 49 50 53 public final class DefinitionsDocumentTest extends DrJavaTestCase implements ReducedModelStates { 54 private DefinitionsDocument _defModel; 55 private GlobalEventNotifier _notifier; 56 57 60 public DefinitionsDocumentTest(String name) { 61 super(name); 62 } 63 64 67 protected void setUp() throws Exception { 68 super.setUp(); 69 _notifier = new GlobalEventNotifier(); 70 _defModel = new DefinitionsDocument(_notifier); 71 DrJava.getConfig().resetToDefaults(); 72 } 73 74 78 public static Test suite() { 79 return new TestSuite(DefinitionsDocumentTest.class); 80 } 81 82 85 public void testInsertToDoc() throws BadLocationException { 86 _defModel.insertString(0, "a/*bc */\"\\{}()", null); 87 assertEquals("#0.0", _defModel.getText(0, 8), "a/*bc */"); 88 assertEquals("#0.1", 14, _defModel.getCurrentLocation()); 89 _defModel.insertString(0, "Start:", null); 90 assertEquals("#1.0", _defModel.getText(0, 14), "Start:a/*bc */"); 91 assertEquals("#1.1", 6, _defModel.getCurrentLocation()); 92 BraceReduction _reduced = _defModel.getReduced(); 95 assertEquals("2.1", FREE, _reduced.getStateAtCurrent()); 96 _reduced.move(2); 97 assertEquals("2.3", "/*", _reduced.currentToken().getType()); 100 _reduced.move(2); 101 assertEquals("2.4", true, _reduced.currentToken().isGap()); 104 assertEquals("2.5", ReducedToken.INSIDE_BLOCK_COMMENT, _reduced.currentToken().getState()); 105 _reduced.move(2); 106 assertEquals("2.6", "*/", _reduced.currentToken().getType()); 109 _reduced.move(2); 110 assertEquals("2.7", "\"", _reduced.currentToken().getType()); 113 _reduced.move(1); 114 assertEquals("2.8", "\\", _reduced.currentToken().getType()); 117 _reduced.move(1); 118 assertEquals("2.9", "{", _reduced.currentToken().getType()); 121 _reduced.move(1); 122 assertEquals("2.91", "}", _reduced.currentToken().getType()); 125 _reduced.move(1); 126 assertEquals("2.92", "(", _reduced.currentToken().getType()); 129 _reduced.move(1); 130 assertEquals("2.93", ")", _reduced.currentToken().getType()); 133 } 134 135 139 public void testInsertStarIntoStarSlash() throws BadLocationException { 140 BraceReduction _reduced = _defModel.getReduced(); 141 _defModel.insertString(0, "/**/", null); 142 _defModel.insertString(3, "*", null); 144 _defModel.move(-4); 145 assertEquals("1", "/*", _reduced.currentToken().getType()); 146 assertEquals("2", ReducedToken.FREE, _reduced.currentToken().getState()); 147 _reduced.move(2); 148 assertEquals("3", "*", _reduced.currentToken().getType()); 149 assertEquals("4", ReducedToken.INSIDE_BLOCK_COMMENT, _reduced.currentToken().getState()); 150 _reduced.move(1); 151 assertEquals("5", "*/", _reduced.currentToken().getType()); 152 assertEquals("6", ReducedToken.FREE, _reduced.currentToken().getState()); 153 } 154 155 159 public void testInsertSlashIntoStarSlash() throws BadLocationException { 160 BraceReduction _reduced = _defModel.getReduced(); 161 _defModel.insertString(0, "/**/", null); 162 _defModel.insertString(3, "/", null); 164 _defModel.move(-4); 165 assertEquals("1", "/*", _reduced.currentToken().getType()); 166 assertEquals("2", ReducedToken.FREE, _reduced.currentToken().getState()); 167 _reduced.move(2); 168 assertEquals("3", "*/", _reduced.currentToken().getType()); 169 assertEquals("4", ReducedToken.FREE, _reduced.currentToken().getState()); 170 _reduced.move(2); 171 assertEquals("5", "/", _reduced.currentToken().getType()); 172 assertEquals("6", ReducedToken.FREE, _reduced.currentToken().getState()); 173 } 174 175 178 public void testInsertStarIntoSlashStar() throws BadLocationException { 179 BraceReduction _reduced = _defModel.getReduced(); 180 _defModel.insertString(0, "/**/", null); 181 _defModel.insertString(1, "*", null); 183 _defModel.move(-2); 184 assertEquals("1", "/*", _reduced.currentToken().getType()); 185 assertEquals("2", ReducedToken.FREE, _reduced.currentToken().getState()); 186 _reduced.move(2); 187 assertEquals("3", "*", _reduced.currentToken().getType()); 188 assertEquals("4", ReducedToken.INSIDE_BLOCK_COMMENT, _reduced.currentToken().getState()); 189 _reduced.move(1); 190 assertEquals("5", "*/", _reduced.currentToken().getType()); 191 assertEquals("6", ReducedToken.FREE, _reduced.currentToken().getState()); 192 } 193 194 195 public void testDeleteDoc() throws BadLocationException { 196 _defModel.insertString(0, "a/*bc */", null); 197 _defModel.remove(3, 3); 198 assertEquals("#0.0", "a/**/", _defModel.getText(0, 5)); 199 assertEquals("#0.1", 3, _defModel.getCurrentLocation()); 200 BraceReduction _reduced = _defModel.getReduced(); 201 assertEquals("1.0", "*/", _reduced.currentToken().getType()); 202 _reduced.move(-2); 205 assertEquals("1.2", "/*", _reduced.currentToken().getType()); 206 _reduced.move(2); 207 assertEquals("1.3", ReducedToken.INSIDE_BLOCK_COMMENT, _reduced.getStateAtCurrent()); 208 } 209 210 214 private void _checkHighlightStatusConsistent(Vector <HighlightStatus> v, 215 int start, 216 int end) 217 { 218 int walk = start; 220 for (int i = 0; i < v.size(); i++) { 221 assertEquals("Item #" + i + "in highlight vector starts at right place", 222 walk, 223 v.get(i).getLocation()); 224 assertTrue("Item #" + i + " in highlight vector has positive length", 226 v.get(i).getLength() > 0); 227 228 walk += v.get(i).getLength(); 229 } 230 assertEquals("Location after walking highlight vector", 231 end, 232 walk); 233 } 234 235 238 public void testHighlightKeywords1() throws BadLocationException { 239 Vector <HighlightStatus> v; 240 final String s = "public class Foo {\n" + 241 " private int _x = 0;\n" + 242 "}"; 243 _defModel.insertString(_defModel.getLength(), s, null); 244 v = _defModel.getHighlightStatus(0, _defModel.getLength()); 245 _checkHighlightStatusConsistent(v, 0, _defModel.getLength()); 246 assertEquals("vector length", 12, v.size()); 248 assertEquals(HighlightStatus.KEYWORD, v.get(0).getState()); 249 assertEquals(HighlightStatus.NORMAL, v.get(1).getState()); 250 assertEquals(HighlightStatus.KEYWORD, v.get(2).getState()); 251 assertEquals(HighlightStatus.NORMAL, v.get(3).getState()); 252 assertEquals(HighlightStatus.TYPE, v.get(4).getState()); 253 assertEquals(HighlightStatus.NORMAL, v.get(5).getState()); 254 255 assertEquals(HighlightStatus.KEYWORD, v.get(6).getState()); 256 assertEquals(HighlightStatus.NORMAL, v.get(7).getState()); 257 assertEquals(HighlightStatus.TYPE, v.get(8).getState()); 258 assertEquals(HighlightStatus.NORMAL, v.get(9).getState()); 259 assertEquals(HighlightStatus.NUMBER, v.get(10).getState()); 260 assertEquals(HighlightStatus.NORMAL, v.get(11).getState()); 261 } 262 263 272 public void testHighlightKeywords2() throws BadLocationException { 273 Vector <HighlightStatus> v; 274 final String s = "int y"; 275 _defModel.insertString(_defModel.getLength(), s, null); 276 v = _defModel.getHighlightStatus(0, _defModel.getLength()); 278 _checkHighlightStatusConsistent(v, 0, _defModel.getLength()); 279 281 assertEquals("vector length", 2, v.size()); 282 assertEquals(HighlightStatus.TYPE, v.get(0).getState()); 283 assertEquals(HighlightStatus.NORMAL, v.get(1).getState()); 284 v = _defModel.getHighlightStatus(0, 2); 286 _checkHighlightStatusConsistent(v, 0, 2); 287 assertEquals("vector length", 1, v.size()); 288 assertEquals(0, v.get(0).getLocation()); 289 assertEquals(2, v.get(0).getLength()); 290 } 291 292 295 public void testGotoLine1() throws BadLocationException { 296 final String s = "a\n"; 297 _defModel.insertString(0, s, null); 298 _defModel.gotoLine(2); 299 assertEquals("#0.0", 2, _defModel.getCurrentLocation()); 300 } 301 302 306 public void testGotoLine2() throws BadLocationException { 307 final String s = "abcd\n"; 308 _defModel.insertString(0, s, null); 309 _defModel.gotoLine(2); 310 assertEquals("#0.0", 5, _defModel.getCurrentLocation()); 311 } 312 313 317 public void testGotoLine3() throws BadLocationException { 318 final String s = "a\nb\nc\n"; 319 _defModel.insertString(0, s, null); 320 _defModel.gotoLine(4); 321 assertEquals("#0.0", 6, _defModel.getCurrentLocation()); 322 } 323 324 329 public void testGotoLine4() throws BadLocationException { 330 final String s = "a\nb\nc\n"; 331 _defModel.insertString(0, s, null); 332 _defModel.gotoLine(8); 333 assertEquals("#0.0", 6, _defModel.getCurrentLocation()); 334 } 335 336 341 public void testGotoLine5() { 342 _defModel.gotoLine(1); 343 assertEquals("#0.0", 0, _defModel.getCurrentLocation()); 344 } 345 346 350 public void testGotoLine6() { 351 _defModel.gotoLine(4); 352 assertEquals("#0.0", 0, _defModel.getCurrentLocation()); 353 } 354 355 360 public void testGotoLine7() throws BadLocationException { 361 final String s = "11111\n2222\n33333\n44444"; 362 _defModel.insertString(0, s, null); 363 _defModel.gotoLine(3); 364 assertEquals("#0.0", 11, _defModel.getCurrentLocation()); 365 } 366 367 370 public void testGetColumn1() throws BadLocationException { 371 final String s = "1234567890"; 372 assertEquals("#0.0", 0, _defModel.getCurrentCol()); 373 _defModel.insertString(0, s, null); 374 assertEquals("#0.1", 10, _defModel.getCurrentCol()); 375 _defModel.gotoLine(0); 376 assertEquals("#0.2", 0, _defModel.getCurrentCol()); 377 } 378 379 380 383 public void testGetColumn2() throws BadLocationException { 384 final String s = "1234567890\n1234\n12345"; 385 _defModel.insertString(0, s, null); 386 assertEquals("#0.0", 5, _defModel.getCurrentCol() ); 387 } 388 389 393 public void testGetLine1() throws BadLocationException { 394 final String s = "a\n"; 395 _defModel.insertString(0, s, null); 396 _defModel.setCurrentLocation(2); 397 assertEquals("#0.0", 2, _defModel.getCurrentLine()); 398 } 399 400 404 public void testGetLine2() throws BadLocationException { 405 final String s = "abcd\n"; 406 _defModel.insertString(0, s, null); 407 _defModel.setCurrentLocation(2); 408 assertEquals("#0.0", 1, _defModel.getCurrentLine()); 409 _defModel.gotoLine(2); 410 assertEquals("#0.1", 2, _defModel.getCurrentLine()); 411 } 412 413 417 public void testGetLine3() throws BadLocationException { 418 final String s = "a\nb\nc\n"; 419 _defModel.insertString(0, s, null); 420 _defModel.setCurrentLocation(6); 421 assertEquals("#0.0", 4, _defModel.getCurrentLine()); 422 } 423 424 429 public void testGetLine4() throws BadLocationException { 430 final String s = "a\nb\nc\n"; 431 _defModel.insertString(0, s, null); 432 _defModel.gotoLine(8); 433 assertEquals("#0.0", 4, _defModel.getCurrentLine()); 434 } 435 436 441 public void testGetLine5() { 442 _defModel.setCurrentLocation(0); 443 assertEquals("#0.0", 1, _defModel.getCurrentLine()); 444 } 445 446 450 public void testGetLine6() { 451 _defModel.gotoLine(4); 452 assertEquals("#0.0", 1, _defModel.getCurrentLine()); 453 } 454 455 460 public void testGetLine7() throws BadLocationException { 461 final String s = "12345\n7890\n2345\n789"; 462 _defModel.insertString(0, s, null); 463 _defModel.setCurrentLocation(12); 464 assertEquals("#0.0", 3, _defModel.getCurrentLine()); 465 _defModel.move(-5); 466 assertEquals("#0.1", 2, _defModel.getCurrentLine()); 467 _defModel.setCurrentLocation(19); 468 assertEquals("#0.2", 4, _defModel.getCurrentLine()); 469 } 470 471 474 public void testGetLineDeleteText() throws BadLocationException { 475 final String s = "123456789\n123456789\n123456789\n123456789\n"; 476 _defModel.insertString(0,s,null); 477 _defModel.setCurrentLocation(35); 478 assertEquals("Before delete", 4, _defModel.getCurrentLine() ); 479 _defModel.remove(0,30); 480 _defModel.setCurrentLocation(5); 481 assertEquals("After delete", 1, _defModel.getCurrentLine() ); 482 } 483 484 487 public void testGetLineDeleteText2() throws BadLocationException { 488 final String s = "123456789\n123456789\n123456789\n123456789\n"; 489 _defModel.insertString(0,s,null); 490 _defModel.setCurrentLocation(35); 491 assertEquals("Before delete", 4, _defModel.getCurrentLine()); 492 _defModel.remove(18,7); 493 assertEquals("After delete", 2, _defModel.getCurrentLine()); 494 } 495 496 499 public void testRemoveTabs1() { 500 _defModel.setIndent(1); 501 String test = "\t this \t\tis a \t\t\t\t\ttest\t\t"; 502 String result = _defModel._removeTabs(test); 503 assertEquals( " this is a test ", result); 504 } 505 506 511 public void testRemoveTabs2() { 512 String input = 513 "\ttoken = nextToken(); // read trailing parenthesis\n" + 514 "\tif (token != ')')\n" + 515 "\t throw new ParseException(\"wrong number of arguments to |\");\n"; 516 517 String expected = 518 " token = nextToken(); // read trailing parenthesis\n" + 519 " if (token != ')')\n" + 520 " throw new ParseException(\"wrong number of arguments to |\");\n"; 521 522 int count = 5000; 523 final StringBuilder bigIn = new StringBuilder (input.length() * count); 524 final StringBuilder bigExp = new StringBuilder (expected.length() * count); 525 for (int i = 0; i < count; i++) { 526 bigIn.append(input); 527 bigExp.append(expected); 528 } 529 530 String result = _defModel._removeTabs(bigIn.toString()); 531 assertEquals(bigExp.toString(), result); 532 } 533 534 537 public void testTabRemovalOnInsertString2() throws BadLocationException { 538 String [] inputs = { 539 "\ttoken = nextToken(); // read trailing parenthesis\n", 540 "\tif (token != ')')\n", 541 "\t throw new ParseException(\"wrong number of arguments to |\");\n", 542 }; 543 544 String expected = 545 " token = nextToken(); // read trailing parenthesis\n" + 546 " if (token != ')')\n" + 547 " throw new ParseException(\"wrong number of arguments to |\");\n"; 548 549 for (int i = 0; i < inputs.length; i++) { 550 _defModel.insertString(_defModel.getLength(), inputs[i], null); 551 } 552 553 assertEquals(expected, _getAllText()); 554 } 555 556 557 public void testTabRemovalOnInsertString() throws BadLocationException { 558 _defModel.setIndent(1); 559 _defModel.insertString(0, " \t yet \t\tanother\ttest\t", null); 560 String result = _defModel.getText(); 561 562 if (_defModel.tabsRemoved()) { 563 assertEquals(" yet another test ", result); 564 } 565 else { assertEquals(" \t yet \t\tanother\ttest\t", result); 567 } 568 } 569 570 571 public void testPackageNameEmpty() throws InvalidPackageException { 572 assertEquals("Package name for empty document", "", _defModel.getPackageName()); 573 } 574 575 576 public void testPackageNameSimple() 577 throws Exception 578 { 579 final String [] comments = { 580 "/* package very.bad; */", 581 "// package terribly.wrong;" 582 }; 583 584 final String [] packages = {"edu", "edu.rice", "edu.rice.cs.drjava" }; 585 586 for (int i = 0; i < packages.length; i++) { 587 String curPack = packages[i]; 588 589 for (int j = 0; j < comments.length; j++) { 590 String curComment = comments[j]; 591 setUp(); 592 _defModel.insertString(0, curComment + "\n\n" + "package " + curPack + ";\nclass Foo { int x; }\n", null); 593 594 assertEquals("Package name for document with comment " + curComment, curPack, _defModel.getPackageName()); 595 } 596 } 597 } 598 599 600 public void testPackageNameWeird1() throws BadLocationException , InvalidPackageException { 601 String weird = "package edu . rice\n./*comment!*/cs.drjava;"; 602 String normal = "edu.rice.cs.drjava"; 603 _defModel.insertString(0, weird, null); 604 605 assertEquals("Package name for weird: '" + weird + "'", normal, _defModel.getPackageName()); 606 } 607 608 609 public void testPackageNameWeird2() throws BadLocationException , InvalidPackageException { 610 String weird = "package edu . rice //comment!\n.cs.drjava;"; 611 String normal = "edu.rice.cs.drjava"; 612 _defModel.insertString(0, weird, null); 613 614 assertEquals("Package name for weird: '" + weird + "'", normal, _defModel.getPackageName()); 615 } 616 617 620 public void testGetPackageNameWithPackageStatementAfterImport() throws BadLocationException , InvalidPackageException { 621 String text = "import java.util.*;\npackage junk;\nclass Foo {}"; 622 _defModel.insertString(0, text, null); 623 assertEquals("Package name for text with package statement after import", "", _defModel.getPackageName()); 624 } 625 626 private String _getAllText() throws BadLocationException { return _defModel.getText(); } 627 628 629 public void testTopLevelClassName() throws BadLocationException , ClassNameNotFoundException { 630 String weird = "package edu . rice\n./*comment!*/cs.drjava; class MyClass<T> implements O{"; 631 String result = "MyClass"; 632 _defModel.insertString(0, weird, null); 633 634 assertEquals("class name for weird: '" + weird + "'", result, _defModel.getFirstTopLevelClassName()); 635 } 636 637 638 public void testTopLevelInterfaceName() throws BadLocationException , ClassNameNotFoundException { 639 String weird = "package edu . rice\n./*comment!*/cs.drjava; \n" + " interface thisInterface { \n" + 640 " class MyClass {"; 641 String result = "thisInterface"; 642 _defModel.insertString(0, weird, null); 643 644 assertEquals("class name for interface: '" + weird + "'", result, _defModel.getFirstTopLevelClassName()); 645 } 646 647 648 public void testTopLevelClassNameWComments() throws BadLocationException , ClassNameNotFoundException { 649 String weird = "package edu . rice\n./*comment!*/cs.drjava; \n" + 650 "/* class Y */ \n" + 651 " /* class Foo \n" + 652 " * class Bar \n" + 653 " interface Baz \n" + 654 " */ \n" + 655 "//class Blah\n" + 656 "class MyClass {"; 657 658 String result = "MyClass"; 659 _defModel.insertString(0, weird, null); 660 661 assertEquals("class name for class: '" + weird + "'", result, _defModel.getFirstTopLevelClassName()); 662 } 663 664 665 public void testTopLevelClassNameNoSpace() throws BadLocationException { 666 String c = "class"; 667 _defModel.insertString(0, c, null); 668 try { 669 _defModel.getFirstTopLevelClassName(); 670 fail("Should not have found a class name"); 671 } 672 catch (ClassNameNotFoundException e) { 673 } 675 } 676 677 681 public void testTopLevelClassNameWithClassloaderImport() 682 throws BadLocationException , ClassNameNotFoundException 683 { 684 String weird = "import classloader.class; class MyClass {"; 685 String result = "MyClass"; 686 _defModel.insertString(0, weird, null); 687 688 assertEquals("class name for weird: '" + weird + "'", result, _defModel.getFirstTopLevelClassName()); 689 } 690 691 692 public void testTopLevelClassNameMisleading() throws BadLocationException , ClassNameNotFoundException { 693 String weird = "package edu . rice\n./*comment!*/cs.drjava; \n" + 694 " {class X} \n" + 695 " interface thisInterface { \n" + 696 " class MyInnerClass {"; 697 String result = "thisInterface"; 698 _defModel.insertString(0, weird, null); 699 700 assertEquals("class name for interface: '" + weird + "'", 701 result, 702 _defModel.getFirstTopLevelClassName()); 703 } 704 705 706 public void testTopLevelInterfaceNameMisleading() throws BadLocationException , ClassNameNotFoundException { 707 String weird = "package edu . rice\n./*comment!*/cs.drjava; \n" + " {interface X} " + " \"class Foo\"" + 708 " class MyClass {"; 709 String result = "MyClass"; 710 _defModel.insertString(0, weird, null); 711 712 assertEquals("class name for user interface: '" + weird + "'", result, _defModel.getFirstTopLevelClassName()); 713 } 714 715 716 public void testTopLevelInterfaceNameMisleading2() throws BadLocationException , ClassNameNotFoundException { 717 String weird = "package edu . rice\n./*interface comment!*/cs.drjava; \n" + " {interface X<T>} " + 718 " \"class interface Foo\"" + " class MyClass extends Foo<T> {"; 719 String result = "MyClass"; 720 _defModel.insertString(0, weird, null); 721 722 assertEquals("class name for user interface: '" + weird + "'", result, _defModel.getFirstTopLevelClassName()); 723 } 724 725 726 public void testTopLevelInterfaceNameBeforeClassName() 727 throws BadLocationException , ClassNameNotFoundException 728 { 729 String weird = "package edu . rice\n./*comment!*/cs.drjava; \n" + 730 " interface thisInterface { \n" + 731 " } \n" + 732 " class thatClass {\n" + 733 " }"; 734 String result = "thisInterface"; 735 _defModel.insertString(0, weird, null); 736 737 assertEquals("interface should have been chosen, rather than the class: '" + weird + "'", 738 result, 739 _defModel.getFirstTopLevelClassName()); 740 } 741 742 743 public void testTopLevelClassNameWithDelimiters() throws BadLocationException , ClassNameNotFoundException { 744 String weird1 = "package edu . rice\n./*comment!*/cs.drjava; \n" + " class MyClass<T> {"; 745 String result1 = "MyClass"; 746 _defModel.insertString(0, weird1, null); 747 748 assertEquals("generics should be removed: '" + weird1 + "'", result1, _defModel.getFirstTopLevelClassName()); 749 750 String weird2 = "package edu . rice\n./*comment!*/cs.drjava; \n" + " class My_Class {"; 751 String result2 = "My_Class"; 752 _defModel.insertString(0, weird2, null); 753 754 assertEquals("underscores should remain: '" + weird1 + "'", result2, _defModel.getFirstTopLevelClassName()); 755 } 756 757 758 public void testTopLevelEnclosingClassName() throws BadLocationException , ClassNameNotFoundException { 759 String classes = 760 "import foo;\n" + "class C1 {\n" + " void foo() { int a; }\n" + " class C2 { int x;\n" + " int y;\n" + " class C3 {}\n" + " } int b;\n" + "}\n" + "class C4 {\n" + " class C5 {\n" + " void bar() { int c; } class C6 {}\n" + " }\n" + "} class C7 {}"; 774 _defModel.insertString(0, classes, null); 775 776 try { 778 String result = _defModel.getEnclosingTopLevelClassName(3); 779 fail("no enclosing class should be found at start"); 780 } 781 catch (ClassNameNotFoundException cnnfe) { 782 } 784 785 try { 787 _defModel.getEnclosingTopLevelClassName(15); 788 fail("no enclosing class should be found before open brace"); 789 } 790 catch (ClassNameNotFoundException cnnfe) { 791 } 793 794 try { 795 String result = _defModel.getEnclosingTopLevelClassName(186); 796 fail("no enclosing class should be found at end of file"); 797 } 798 catch (ClassNameNotFoundException cnnfe) { 799 } 801 802 assertEquals("top level class name after first open brace", "C1", _defModel.getEnclosingTopLevelClassName(22)); 803 assertEquals("top level class name inside C1", "C1", _defModel.getEnclosingTopLevelClassName(26)); 804 assertEquals("top level class name inside method of C1", "C1", _defModel.getEnclosingTopLevelClassName(42)); 805 assertEquals("top level class name on C2's brace", "C1", _defModel.getEnclosingTopLevelClassName(58)); 806 assertEquals("top level class name after C2's brace", "C1", _defModel.getEnclosingTopLevelClassName(59)); 807 assertEquals("top level class name inside C2", "C1", _defModel.getEnclosingTopLevelClassName(68)); 808 assertEquals("top level class name inside C3", "C1", _defModel.getEnclosingTopLevelClassName(92)); 809 assertEquals("top level class name after C3's close brace", "C1", _defModel.getEnclosingTopLevelClassName(93)); 810 assertEquals("top level class name after C2's close brace", "C1", _defModel.getEnclosingTopLevelClassName(100)); 811 812 try { 814 _defModel.getEnclosingTopLevelClassName(107); 815 fail("no enclosing class should be found between classes"); 816 } 817 catch (ClassNameNotFoundException cnnfe) { 818 } 820 821 assertEquals("class name inside C4", "C4", _defModel.getEnclosingTopLevelClassName(122)); 822 assertEquals("class name inside C5", "C4", _defModel.getEnclosingTopLevelClassName(135)); 823 assertEquals("class name inside C6", "C4", _defModel.getEnclosingTopLevelClassName(167)); 824 assertEquals("class name inside C7", "C7", _defModel.getEnclosingTopLevelClassName(185)); 825 826 try { 828 String result = _defModel.getEnclosingTopLevelClassName(186); 829 fail("no enclosing class should be found at end"); 830 } 831 catch (ClassNameNotFoundException cnnfe) { 832 } 834 } 835 836 837 public void testQualifiedClassNameWithPackage() throws BadLocationException , ClassNameNotFoundException { 838 String classes = 839 "package foo;\n" + "class C1 {}\n" + "class C2 {}"; _defModel.insertString(0, classes, null); 843 844 assertEquals("qualified class name without pos", "foo.C1", _defModel.getQualifiedClassName()); 845 assertEquals("enclosing class name in C1", "C1", _defModel.getEnclosingTopLevelClassName(23)); 846 assertEquals("qualified class name with pos in C1", "foo.C1", _defModel.getQualifiedClassName(23)); 847 assertEquals("qualified class name with pos in C2", "foo.C2", _defModel.getQualifiedClassName(35)); 848 849 try { 851 _defModel.getQualifiedClassName(15); 852 fail("no qualified class name should be found outside classes"); 853 } 854 catch (ClassNameNotFoundException cnnfe) { 855 } 857 } 858 859 860 public void testQualifiedClassNameWithoutPackage() throws BadLocationException , ClassNameNotFoundException { 861 String classes = 862 "class C1 {}\n" + "class C2 {}"; _defModel.insertString(0, classes, null); 865 866 assertEquals("qualified class name without pos", "C1", _defModel.getQualifiedClassName()); 867 assertEquals("qualified class name with pos in C1", "C1", _defModel.getQualifiedClassName(10)); 868 assertEquals("qualified class name with pos in C2", "C2", _defModel.getQualifiedClassName(22)); 869 870 try { 872 _defModel.getQualifiedClassName(15); 873 fail("no qualified class name should be found outside classes"); 874 } 875 catch (ClassNameNotFoundException cnnfe) { 876 } 878 } 879 880 962 963 966 public void testUndoAndRedoAfterMultipleLineIndent() throws BadLocationException { String text = 968 "public class stuff {\n" + 969 "private int _int;\n" + 970 "private Bar _bar;\n" + 971 "public void foo() {\n" + 972 "_bar.baz(_int);\n" + 973 "}\n" + 974 "}\n"; 975 976 String indented = 977 "public class stuff {\n" + 978 " private int _int;\n" + 979 " private Bar _bar;\n" + 980 " public void foo() {\n" + 981 " _bar.baz(_int);\n" + 982 " }\n" + 983 "}\n"; 984 985 _defModel.addUndoableEditListener(_defModel.getUndoManager()); 986 DrJava.getConfig().setSetting(OptionConstants.INDENT_LEVEL,new Integer (2)); 987 _defModel.insertString(0,text,null); 988 assertEquals("insertion",text, _defModel.getText()); 989 994 _defModel.getUndoManager().startCompoundEdit(); 995 _defModel.indentLines(0,_defModel.getLength()); 996 assertEquals("indenting",indented, _defModel.getText()); 997 _defModel.getUndoManager().undo(); 998 assertEquals("undo",text, _defModel.getText()); 999 _defModel.getUndoManager().redo(); 1000 assertEquals("redo",indented, _defModel.getText()); 1001 } 1002 1003 1006 public void testUndoAndRedoAfterMultipleLineCommentAndUncomment() 1007 throws BadLocationException { 1008 String text = 1009 "public class stuff {\n" + 1010 " private int _int;\n" + 1011 " private Bar _bar;\n" + 1012 " public void foo() {\n" + 1013 " _bar.baz(_int);\n" + 1014 " }\n" + 1015 "}\n"; 1016 1017 String commented = 1018 "//public class stuff {\n" + 1019 "// private int _int;\n" + 1020 "// private Bar _bar;\n" + 1021 "// public void foo() {\n" + 1022 "// _bar.baz(_int);\n" + 1023 "// }\n" + 1024 "//}\n"; 1025 1026 _defModel.addUndoableEditListener(_defModel.getUndoManager()); 1027 DrJava.getConfig().setSetting(OptionConstants.INDENT_LEVEL,new Integer (2)); 1028 _defModel.insertString(0,text,null); 1029 assertEquals("insertion",text, _defModel.getText()); 1030 1031 _defModel.getUndoManager().startCompoundEdit(); 1032 _defModel.commentLines(0,_defModel.getLength()); 1033 assertEquals("commenting",commented, _defModel.getText()); 1034 _defModel.getUndoManager().undo(); 1035 assertEquals("undo commenting",text, _defModel.getText()); 1036 _defModel.getUndoManager().redo(); 1037 assertEquals("redo commenting",commented, _defModel.getText()); 1038 1039 _defModel.getUndoManager().startCompoundEdit(); 1040 _defModel.uncommentLines(0,_defModel.getLength()); 1041 assertEquals("uncommenting",text, _defModel.getText()); 1042 _defModel.getUndoManager().undo(); 1043 assertEquals("undo uncommenting",commented, _defModel.getText()); 1044 _defModel.getUndoManager().redo(); 1045 assertEquals("redo uncommenting",text, _defModel.getText()); 1046 } 1047 1048 1051 public void testCompoundUndoManager() throws BadLocationException { 1052 String text = 1053 "public class foo {\n" + 1054 "int bar;\n" + 1055 "}"; 1056 1057 String indented = 1058 "public class foo {\n" + 1059 " int bar;\n" + 1060 "}"; 1061 CompoundUndoManager undoManager = _defModel.getUndoManager(); 1062 1063 _defModel.addUndoableEditListener(undoManager); 1064 DrJava.getConfig().setSetting(OptionConstants.INDENT_LEVEL,new Integer (2)); 1065 1066 1068 int key = undoManager.startCompoundEdit(); 1070 assertEquals("Should have returned the correct key.", 0, key); 1071 1072 _defModel.insertString(0, text, null); 1074 assertEquals("Should have inserted the text properly.", text, _defModel.getText()); 1075 1076 undoManager.startCompoundEdit(); 1078 1079 _defModel.indentLines(0, _defModel.getLength()); 1080 assertEquals("Should have indented correctly.", indented, _defModel.getText()); 1081 1082 undoManager.undo(); 1083 assertEquals("Should have undone correctly.", "", _defModel.getText()); 1084 1085 1087 String commented = 1088 "//public class foo {\n" + 1089 "// int bar;\n" + 1090 "//}"; 1091 1092 key = _defModel.getUndoManager().startCompoundEdit(); 1094 assertEquals("Should have returned the correct key.", 2, key); 1095 1096 _defModel.insertString(0, text, null); 1098 assertEquals("Should have inserted the text properly.", text, 1099 _defModel.getText()); 1100 1101 _defModel.indentLines(0, _defModel.getLength()); 1103 assertEquals("Should have indented correctly.", indented, 1104 _defModel.getText()); 1105 1106 undoManager.startCompoundEdit(); 1107 _defModel.commentLines(0, _defModel.getLength()); 1108 assertEquals("Should have commented correctly.", commented, 1109 _defModel.getText()); 1110 1111 _defModel.getUndoManager().undo(); 1113 assertEquals("Should have undone the commenting.", indented, 1114 _defModel.getText()); 1115 1116 _defModel.getUndoManager().undo(); 1118 assertEquals("Should have undone the indenting and inserting.", "", 1119 _defModel.getText()); 1120 1121 1123 key = _defModel.getUndoManager().startCompoundEdit(); 1125 assertEquals("Should have returned the correct key.", 4, key); 1126 1127 _defModel.insertString(0, text, null); 1129 assertEquals("Should have inserted the text properly.", text, 1130 _defModel.getText()); 1131 1132 _defModel.indentLines(0, _defModel.getLength()); 1134 assertEquals("Should have indented correctly.", indented, 1135 _defModel.getText()); 1136 1137 try { 1156 _defModel.getUndoManager().endCompoundEdit(key + 2); 1157 } 1159 catch (IllegalStateException e) { 1160 assertEquals("Should have printed the correct error message.", 1161 "Improperly nested compound edits.", e.getMessage()); 1162 } 1163 1164 undoManager.startCompoundEdit(); 1166 _defModel.indentLines(0, _defModel.getLength()); 1167 assertEquals("Should have indented correctly.", indented, _defModel.getText()); 1168 1169 1174 1183 _defModel.getUndoManager().undo(); 1186 assertEquals("Should have undone the indenting and inserting.", "", _defModel.getText()); 1187 } 1188 1189 1193 public void testUndoOrRedoSetsUnmodifiedState() throws BadLocationException { 1194 _defModel.addUndoableEditListener(_defModel.getUndoManager()); 1195 _defModel.insertString(0, "This is text", null); 1196 assertTrue("Document should be modified.", _defModel.isModifiedSinceSave()); 1197 _defModel.getUndoManager().undo(); 1198 _defModel.updateModifiedSinceSave(); 1199 assertFalse("Document should no longer be modified after undo.", _defModel.isModifiedSinceSave()); 1200 _defModel.insertString(0, "This is text", null); 1201 _defModel.resetModification(); 1202 assertFalse("Document should not be modified after \"save\".", _defModel.isModifiedSinceSave()); 1203 _defModel.getUndoManager().undo(); 1204 _defModel.updateModifiedSinceSave(); 1205 assertTrue("Document should be modified after undo.", _defModel.isModifiedSinceSave()); 1206 _defModel.getUndoManager().redo(); 1207 _defModel.updateModifiedSinceSave(); 1208 assertFalse("Document should no longer be modified after redo.", _defModel.isModifiedSinceSave()); 1209 } 1210 1211 protected final String NEWLINE = System.getProperty("line.separator"); 1212 1213 protected final String NESTED_CLASSES_TEXT = 1214 "/*bof*/package Temp;" + NEWLINE + 1215 "" + NEWLINE + 1216 "public class Test {" + NEWLINE + 1217 " private int i;" + NEWLINE + 1218 " " + NEWLINE + 1219 " public void foo(Test other) {" + NEWLINE + 1220 " i = other.i;" + NEWLINE + 1221 " " + NEWLINE + 1222 " }" + NEWLINE + 1223 " " + NEWLINE + 1224 " public void bar() {" + NEWLINE + 1225 " System.out.println(i);" + NEWLINE + 1226 " }" + NEWLINE + 1227 " " + NEWLINE + 1228 " public static interface Interf {" + NEWLINE + 1229 " static long C = System.currentTimeMillis();" + NEWLINE + 1230 " public void act();" + NEWLINE + 1231 " }" + NEWLINE + 1232 " " + NEWLINE + 1233 " static class Implementor implements Interf {" + NEWLINE + 1234 " public void act() { /*Implementor.act*/" + NEWLINE + 1235 " System.out.println(C);" + NEWLINE + 1236 " Interf inter = new Interf() { /*Implementor$1*/" + NEWLINE + 1237 " public void act() {" + NEWLINE + 1238 " System.out.println(\"Test$Implementor$1\");" + NEWLINE + 1239 " Interf inter = new Interf() { /*Implementor$1$1*/" + NEWLINE + 1240 " public void act() {" + NEWLINE + 1241 " System.out.println(\"Test$Implementor$1$1\");" + NEWLINE + 1242 " }" + NEWLINE + 1243 " };" + NEWLINE + 1244 " Inner<Integer> inn = new Inner<Integer>() { /*Implementor$1$2*/" + NEWLINE + 1245 " public void set(Integer t) { _t = t; }" + NEWLINE + 1246 " };" + NEWLINE + 1247 " } /*b-Implementor$1*/" + NEWLINE + 1248 " }; /*b-Implementor*/" + NEWLINE + 1249 " } /*c-Implementor*/" + NEWLINE + 1250 " " + NEWLINE + 1251 " public abstract class Inner<T> { /*Implementor$Inner*/" + NEWLINE + 1252 " protected T _t; /*b-Implementor$Inner*/" + NEWLINE + 1253 " public abstract void set(T t);" + NEWLINE + 1254 " }" + NEWLINE + 1255 " }" + NEWLINE + 1256 " " + NEWLINE + 1257 " public void anon() { /*anon()*/" + NEWLINE + 1258 " Interf inter = new Interf() { /*Test$1*/" + NEWLINE + 1259 " class NamedInAnonymous implements Interf { /*Test$1$NamedInAnonymous*/" + NEWLINE + 1260 " public void act() {" + NEWLINE + 1261 " System.out.println(\"Test$1$NamedInAnonymous\");" + NEWLINE + 1262 " }" + NEWLINE + 1263 " }" + NEWLINE + 1264 " public void act() { /*b-Test$1*/" + NEWLINE + 1265 " System.out.println(\"Test$1\");" + NEWLINE + 1266 " NamedInAnonymous nia = new NamedInAnonymous();" + NEWLINE + 1267 " nia.act();" + NEWLINE + 1268 " }" + NEWLINE + 1269 " };" + NEWLINE + 1270 " inter.act(); /*b-anon()*/" + NEWLINE + 1271 " Interf inter2 = new Interf() { /*Test$2*/" + NEWLINE + 1272 " public void act() {" + NEWLINE + 1273 " System.out.println(\"Test$2\");" + NEWLINE + 1274 " Interf inter = new Interf() { /*Test$2$1*/" + NEWLINE + 1275 " public void act() {" + NEWLINE + 1276 " System.out.println(\"Test$2$1\");" + NEWLINE + 1277 " }" + NEWLINE + 1278 " };" + NEWLINE + 1279 " inter.act();" + NEWLINE + 1280 " }" + NEWLINE + 1281 " };" + NEWLINE + 1282 " inter2.act();" + NEWLINE + 1283 " Interf inter3 = new Implementor() { /*Test$3*/" + NEWLINE + 1284 " public void act() {" + NEWLINE + 1285 " System.out.println(\"Test$3\");" + NEWLINE + 1286 " }" + NEWLINE + 1287 " };" + NEWLINE + 1288 " inter3.act();" + NEWLINE + 1289 " }" + NEWLINE + 1290 " " + NEWLINE + 1291 " public Test(int j) { if (true) { i = j; } }" + NEWLINE + 1292 " " + NEWLINE + 1293 " protected abstract class Param<T> {" + NEWLINE + 1294 " T _t;" + NEWLINE + 1295 " public Param(T t, T t2) { _t = t; }" + NEWLINE + 1296 " public abstract void paramDo();" + NEWLINE + 1297 " }" + NEWLINE + 1298 " " + NEWLINE + 1299 " public void anon2() {" + NEWLINE + 1300 " Param<Interf> p = new Param<Interf>(/*anon2()*/new Interf() { /*Test$4*/" + NEWLINE + 1301 " public void act() {" + NEWLINE + 1302 " System.out.println(\"parameter 1 = Test$4\");" + NEWLINE + 1303 " Interf i = new Interf() { /*Test$4$1*/" + NEWLINE + 1304 " public void act() {" + NEWLINE + 1305 " System.out.println(\"Test$4$1\");" + NEWLINE + 1306 " }" + NEWLINE + 1307 " };" + NEWLINE + 1308 " }" + NEWLINE + 1309 " }, /*b-anon2()*/ new Interf() { /*Test$5*/" + NEWLINE + 1310 " public void act() {" + NEWLINE + 1311 " System.out.println(\"parameter 2 = Test$5\");" + NEWLINE + 1312 " }" + NEWLINE + 1313 " }) /*c-anon2()*/ { /*Test$6*/" + NEWLINE + 1314 " public void paramDo() {" + NEWLINE + 1315 " System.out.println(\"Test$6\");" + NEWLINE + 1316 " }" + NEWLINE + 1317 " };" + NEWLINE + 1318 " }" + NEWLINE + 1319 "" + NEWLINE + 1320 " public void anon3() {" + NEWLINE + 1321 " Param<Interf> p = new Param<Interf>(/*anon3()*/new Interf() { /*Test$7*/" + NEWLINE + 1322 " class NamedClassAgain {" + NEWLINE + 1323 " void doSomething() { System.out.println(\"doSomething\"); }" + NEWLINE + 1324 " }" + NEWLINE + 1325 " public void act() {" + NEWLINE + 1326 " System.out.println(\"parameter 3 = Test$7\");" + NEWLINE + 1327 " Interf i = new Interf() { /*Test$7$1*/" + NEWLINE + 1328 " public void act() {" + NEWLINE + 1329 " System.out.println(\"Test$7$1\");" + NEWLINE + 1330 " }" + NEWLINE + 1331 " };" + NEWLINE + 1332 " }" + NEWLINE + 1333 " }) /*c-anon2()*/ { /*Test$8*/" + NEWLINE + 1334 " public void paramDo() {" + NEWLINE + 1335 " System.out.println(\"Test$8\");" + NEWLINE + 1336 " }" + NEWLINE + 1337 " };" + NEWLINE + 1338 " }" + NEWLINE + 1339 " " + NEWLINE + 1340 " public static void main(String[] args) {" + NEWLINE + 1341 " Test t1 = new Test(1);" + NEWLINE + 1342 " t1.bar();" + NEWLINE + 1343 " Test t2 = new Test(123);" + NEWLINE + 1344 " t2.bar();" + NEWLINE + 1345 " t1.foo(t2);" + NEWLINE + 1346 " t1.bar();" + NEWLINE + 1347 " Implementor imp = new Implementor();" + NEWLINE + 1348 " imp.act();" + NEWLINE + 1349 " t1.anon();" + NEWLINE + 1350 " }" + NEWLINE + 1351 " public static class Outer {" + NEWLINE + 1352 " public static interface Inner {" + NEWLINE + 1353 " public void innerDo();" + NEWLINE + 1354 " }" + NEWLINE + 1355 " public static interface InnerParam<T> {" + NEWLINE + 1356 " public void innerParam(T t);" + NEWLINE + 1357 " }" + NEWLINE + 1358 " public class Middle<T> {" + NEWLINE + 1359 " T t;" + NEWLINE + 1360 " public abstract class Innerst {" + NEWLINE + 1361 " public abstract void innerstDo();" + NEWLINE + 1362 " }" + NEWLINE + 1363 " " + NEWLINE + 1364 " Innerst i = new Outer.Middle.Innerst() { /*Test$Outer$Middle$1*/" + NEWLINE + 1365 " public void innerstDo() {" + NEWLINE + 1366 " System.out.println(\"Test$Outer$Middle$1\");" + NEWLINE + 1367 " }" + NEWLINE + 1368 " };" + NEWLINE + 1369 " }" + NEWLINE + 1370 " }" + NEWLINE + 1371 " " + NEWLINE + 1372 " public void anonDotTest() {" + NEWLINE + 1373 " Outer.Inner test = new Outer.Inner() { /*Test$9*/" + NEWLINE + 1374 " public void innerDo() {" + NEWLINE + 1375 " System.out.println(\"Test$9\");" + NEWLINE + 1376 " }" + NEWLINE + 1377 " };" + NEWLINE + 1378 " Outer.InnerParam<String> test2 = new Outer.InnerParam<String>() { /*Test$10*/" + NEWLINE + 1379 " public void innerParam(String t) {" + NEWLINE + 1380 " System.out.println(\"Test$10\");" + NEWLINE + 1381 " }" + NEWLINE + 1382 " };" + NEWLINE + 1383 " }" + NEWLINE + 1384 "}" + NEWLINE + 1385 "" + NEWLINE + 1386 "class Foo {" + NEWLINE + 1387 " public void foo() {" + NEWLINE + 1388 " System.out.println(\"foo\");" + NEWLINE + 1389 " FooImplementor fimp = new FooImplementor();" + NEWLINE + 1390 " fimp.act();" + NEWLINE + 1391 " }" + NEWLINE + 1392 " " + NEWLINE + 1393 " static interface FooInterf {" + NEWLINE + 1394 " static long C = System.currentTimeMillis(); /*Foo$FooInterf*/" + NEWLINE + 1395 " public void act();" + NEWLINE + 1396 " }" + NEWLINE + 1397 " " + NEWLINE + 1398 " public static class FooImplementor implements FooInterf { /*Foo$FooImplementor*/" + NEWLINE + 1399 " public void act() {" + NEWLINE + 1400 " System.out.println(C); /*b-Foo$FooImplementor*/" + NEWLINE + 1401 " FooInterf inter = new FooInterf() { /*Foo$FooImplementor$1*/" + NEWLINE + 1402 " public void act() {" + NEWLINE + 1403 " System.out.println(\"Foo$FooImplementor$1\");" + NEWLINE + 1404 " FooInterf inter = new FooInterf() { /*Foo$FooImplementor$1$1*/" + NEWLINE + 1405 " public void act() {" + NEWLINE + 1406 " System.out.println(\"Foo$FooImplementor$1$1\");" + NEWLINE + 1407 " }" + NEWLINE + 1408 " };" + NEWLINE + 1409 " }" + NEWLINE + 1410 " };" + NEWLINE + 1411 " }" + NEWLINE + 1412 " public class Inner<T> { /*Foo$FooImplementor$Inner*/" + NEWLINE + 1413 " T t;" + NEWLINE + 1414 " }" + NEWLINE + 1415 " }" + NEWLINE + 1416 "}" + NEWLINE + 1417 "abstract class Fee {" + NEWLINE + 1418 " public abstract void feeDo();" + NEWLINE + 1419 " public abstract void feeAct();" + NEWLINE + 1420 " protected String s, t, u;" + NEWLINE + 1421 " " + NEWLINE + 1422 " public static class FeeConc extends Fee {/*Fee$FeeConc*/" + NEWLINE + 1423 " {" + NEWLINE + 1424 " s = \"FeeConc/s\";" + NEWLINE + 1425 " }" + NEWLINE + 1426 " public void feeDo() { System.out.println(\"FeeConc/feeDo\"); }" + NEWLINE + 1427 " {" + NEWLINE + 1428 " t = \"FeeConc/t\";" + NEWLINE + 1429 " }" + NEWLINE + 1430 " public abstract void feeAct() { System.out.println(\"FeeConc/feeAct\"); }" + NEWLINE + 1431 " {" + NEWLINE + 1432 " u = \"FeeConc/u\";" + NEWLINE + 1433 " }" + NEWLINE + 1434 " }" + NEWLINE + 1435 " " + NEWLINE + 1436 " public static void main(String[] args) {" + NEWLINE + 1437 " Fee f = new Fee() {/*Fee$1*/" + NEWLINE + 1438 " {" + NEWLINE + 1439 " s = \"Fee$1/s\";" + NEWLINE + 1440 " }" + NEWLINE + 1441 " public void feeDo() { System.out.println(\"Fee$1/feeDo\"); }" + NEWLINE + 1442 " {" + NEWLINE + 1443 " t = \"Fee$1/t\";" + NEWLINE + 1444 " }" + NEWLINE + 1445 " public abstract void feeAct() { System.out.println(\"Fee$1/feeAct\"); }" + NEWLINE + 1446 " {" + NEWLINE + 1447 " u = \"Fee$1/u\";" + NEWLINE + 1448 " }" + NEWLINE + 1449 " };" + NEWLINE + 1450 " }" + NEWLINE + 1451 "}/*eof*/" + NEWLINE; 1452 1453 1456 public void testAnonymousClassIndex() throws BadLocationException , ClassNameNotFoundException { 1457 _defModel.insertString(0, NESTED_CLASSES_TEXT, null); 1458 1459 String substr; 1460 int exp, act; 1461 substr = "{ /*Test$4*/"; 1462 exp = 4; 1463 act = _defModel._getAnonymousInnerClassIndex(NESTED_CLASSES_TEXT.indexOf(substr)); 1464 assertEquals("index at "+substr+" exp=`"+exp+"`, act=`"+act+"`", exp, act); 1465 1466 substr = "{ /*Test$5*/"; 1467 exp = 5; 1468 act = _defModel._getAnonymousInnerClassIndex(NESTED_CLASSES_TEXT.indexOf(substr)); 1469 assertEquals("index at "+substr+" exp=`"+exp+"`, act=`"+act+"`", exp, act); 1470 1471 substr = "{ /*Test$6*/"; 1472 exp = 6; 1473 act = _defModel._getAnonymousInnerClassIndex(NESTED_CLASSES_TEXT.indexOf(substr)); 1474 assertEquals("index at "+substr+" exp=`"+exp+"`, act=`"+act+"`", exp, act); 1475 1476 substr = "{ /*Test$7*/"; 1477 exp = 7; 1478 act = _defModel._getAnonymousInnerClassIndex(NESTED_CLASSES_TEXT.indexOf(substr)); 1479 assertEquals("index at "+substr+" exp=`"+exp+"`, act=`"+act+"`", exp, act); 1480 1481 substr = "{ /*Test$8*/"; 1482 exp = 8; 1483 act = _defModel._getAnonymousInnerClassIndex(NESTED_CLASSES_TEXT.indexOf(substr)); 1484 assertEquals("index at "+substr+" exp=`"+exp+"`, act=`"+act+"`", exp, act); 1485 } 1486 1487 1490 public void testExactClassName() throws BadLocationException , ClassNameNotFoundException { 1491 _defModel.insertString(0, NESTED_CLASSES_TEXT, null); 1492 1493 String substr, exp1, exp2, act1, act2; 1494 substr = "private int i"; 1495 exp1 = "Temp.Test"; 1496 exp2 = "Test"; 1497 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1498 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1499 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1500 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1501 1502 substr = "= other.i"; 1503 exp1 = "Temp.Test"; 1504 exp2 = "Test"; 1505 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1506 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1507 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1508 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1509 1510 substr = "System.out.println(i)"; 1511 exp1 = "Temp.Test"; 1512 exp2 = "Test"; 1513 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1514 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1515 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1516 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1517 1518 substr = "System.currentTimeMillis"; 1519 exp1 = "Temp.Test$Interf"; 1520 exp2 = "Interf"; 1521 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1522 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1523 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1524 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1525 1526 substr = "Implementor implements Interf"; 1527 exp1 = "Temp.Test"; 1528 exp2 = "Test"; 1529 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1530 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1531 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1532 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1533 1534 substr = "/*Implementor.act*/"; 1535 exp1 = "Temp.Test$Implementor"; 1536 exp2 = "Implementor"; 1537 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1538 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1539 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1540 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1541 1542 substr = "/*Implementor$1*/"; 1543 exp1 = "Temp.Test$Implementor$1"; 1544 exp2 = "1"; 1545 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1546 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1547 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1548 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1549 1550 substr = "\"Test$Implementor$1\""; 1551 exp1 = "Temp.Test$Implementor$1"; 1552 exp2 = "1"; 1553 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1554 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1555 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1556 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1557 1558 substr = "/*Implementor$1$1*/"; 1559 exp1 = "Temp.Test$Implementor$1$1"; 1560 exp2 = "1"; 1561 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1562 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1563 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1564 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1565 1566 substr = "\"Test$Implementor$1$1\""; 1567 exp1 = "Temp.Test$Implementor$1$1"; 1568 exp2 = "1"; 1569 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1570 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1571 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1572 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1573 1574 substr = "/*Implementor$1$2*/"; 1575 exp1 = "Temp.Test$Implementor$1$2"; 1576 exp2 = "2"; 1577 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1578 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1579 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1580 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1581 1582 substr = "/*b-Implementor$1*/"; 1583 exp1 = "Temp.Test$Implementor$1"; 1584 exp2 = "1"; 1585 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1586 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1587 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1588 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1589 1590 substr = "/*b-Implementor*/"; 1591 exp1 = "Temp.Test$Implementor"; 1592 exp2 = "Implementor"; 1593 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1594 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1595 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1596 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1597 1598 substr = "/*c-Implementor*/"; 1599 exp1 = "Temp.Test$Implementor"; 1600 exp2 = "Implementor"; 1601 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1602 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1603 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1604 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1605 1606 substr = "/*Implementor$Inner*/"; 1607 exp1 = "Temp.Test$Implementor$Inner"; 1608 exp2 = "Inner"; 1609 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1610 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1611 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1612 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1613 1614 substr = "/*b-Implementor$Inner*/"; 1615 exp1 = "Temp.Test$Implementor$Inner"; 1616 exp2 = "Inner"; 1617 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1618 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1619 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1620 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1621 1622 substr = "/*anon()*/"; 1623 exp1 = "Temp.Test"; 1624 exp2 = "Test"; 1625 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1626 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1627 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1628 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1629 1630 substr = "/*Test$1*/"; 1631 exp1 = "Temp.Test$1"; 1632 exp2 = "1"; 1633 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1634 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1635 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1636 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1637 1638 substr = "/*Test$1$NamedInAnonymous*/"; 1639 exp1 = "Temp.Test$1$NamedInAnonymous"; 1640 exp2 = "NamedInAnonymous"; 1641 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1642 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1643 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1644 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1645 1646 substr = "\"Test$1$NamedInAnonymous\""; 1647 exp1 = "Temp.Test$1$NamedInAnonymous"; 1648 exp2 = "NamedInAnonymous"; 1649 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1650 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1651 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1652 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1653 1654 substr = "/*b-Test$1*/"; 1655 exp1 = "Temp.Test$1"; 1656 exp2 = "1"; 1657 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1658 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1659 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1660 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1661 1662 substr = "\"Test$1\""; 1663 exp1 = "Temp.Test$1"; 1664 exp2 = "1"; 1665 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1666 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1667 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1668 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1669 1670 substr = "/*b-anon()*/"; 1671 exp1 = "Temp.Test"; 1672 exp2 = "Test"; 1673 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1674 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1675 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1676 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1677 1678 substr = "/*Test$2*/"; 1679 exp1 = "Temp.Test$2"; 1680 exp2 = "2"; 1681 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1682 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1683 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1684 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1685 1686 substr = "\"Test$2\""; 1687 exp1 = "Temp.Test$2"; 1688 exp2 = "2"; 1689 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1690 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1691 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1692 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1693 1694 substr = "/*Test$2$1*/"; 1695 exp1 = "Temp.Test$2$1"; 1696 exp2 = "1"; 1697 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1698 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1699 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1700 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1701 1702 substr = "\"Test$2$1\""; 1703 exp1 = "Temp.Test$2$1"; 1704 exp2 = "1"; 1705 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1706 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1707 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1708 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1709 1710 substr = "/*Test$3*/"; 1711 exp1 = "Temp.Test$3"; 1712 exp2 = "3"; 1713 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1714 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1715 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1716 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1717 1718 substr = "\"Test$3\""; 1719 exp1 = "Temp.Test$3"; 1720 exp2 = "3"; 1721 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1722 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1723 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1724 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1725 1726 substr = "(true) { i = j; }"; 1727 exp1 = "Temp.Test"; 1728 exp2 = "Test"; 1729 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1730 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1731 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1732 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1733 1734 substr = "new Test(1)"; 1735 exp1 = "Temp.Test"; 1736 exp2 = "Test"; 1737 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1738 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1739 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1740 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1741 1742 substr = "class Foo"; 1743 exp1 = ""; 1744 exp2 = ""; 1745 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1746 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1747 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1748 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1749 1750 substr = "FooImplementor fimp"; 1751 exp1 = "Temp.Foo"; 1752 exp2 = "Foo"; 1753 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1754 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1755 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1756 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1757 1758 substr = "/*Foo$FooInterf*/"; 1759 exp1 = "Temp.Foo$FooInterf"; 1760 exp2 = "FooInterf"; 1761 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1762 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1763 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1764 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1765 1766 substr = "/*Foo$FooImplementor*/"; 1767 exp1 = "Temp.Foo$FooImplementor"; 1768 exp2 = "FooImplementor"; 1769 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1770 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1771 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1772 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1773 1774 substr = "/*b-Foo$FooImplementor*/"; 1775 exp1 = "Temp.Foo$FooImplementor"; 1776 exp2 = "FooImplementor"; 1777 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1778 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1779 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1780 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1781 1782 substr = "/*Foo$FooImplementor$1*/"; 1783 exp1 = "Temp.Foo$FooImplementor$1"; 1784 exp2 = "1"; 1785 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1786 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1787 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1788 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1789 1790 substr = "\"Foo$FooImplementor$1\""; 1791 exp1 = "Temp.Foo$FooImplementor$1"; 1792 exp2 = "1"; 1793 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1794 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1795 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1796 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1797 1798 substr = "/*Foo$FooImplementor$1$1*/"; 1799 exp1 = "Temp.Foo$FooImplementor$1$1"; 1800 exp2 = "1"; 1801 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1802 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1803 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1804 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1805 1806 substr = "\"Foo$FooImplementor$1$1\""; 1807 exp1 = "Temp.Foo$FooImplementor$1$1"; 1808 exp2 = "1"; 1809 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1810 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1811 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1812 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1813 1814 substr = "/*Foo$FooImplementor$Inner*/"; 1815 exp1 = "Temp.Foo$FooImplementor$Inner"; 1816 exp2 = "Inner"; 1817 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1818 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1819 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1820 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1821 1822 substr = "/*eof*/"; 1823 exp1 = ""; 1824 exp2 = ""; 1825 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1826 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1827 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1828 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1829 1830 substr = "/*bof*/"; 1831 exp1 = ""; 1832 exp2 = ""; 1833 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1834 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1835 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1836 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1837 1838 substr = "public class Test"; 1839 exp1 = ""; 1840 exp2 = ""; 1841 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1842 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1843 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1844 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1845 1846 substr = "/*anon2()*/"; 1847 exp1 = "Temp.Test"; 1848 exp2 = "Test"; 1849 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1850 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1851 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1852 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1853 1854 substr = "/*Test$4*/"; 1855 exp1 = "Temp.Test$4"; 1856 exp2 = "4"; 1857 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1858 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1859 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1860 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1861 1862 substr = "\"parameter 1 = Test$4\""; 1863 exp1 = "Temp.Test$4"; 1864 exp2 = "4"; 1865 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1866 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1867 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1868 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1869 1870 substr = "/*Test$4$1*/"; 1871 exp1 = "Temp.Test$4$1"; 1872 exp2 = "1"; 1873 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1874 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1875 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1876 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1877 1878 substr = "\"Test$4$1\""; 1879 exp1 = "Temp.Test$4$1"; 1880 exp2 = "1"; 1881 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1882 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1883 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1884 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1885 1886 substr = "/*b-anon2()*/"; 1887 exp1 = "Temp.Test"; 1888 exp2 = "Test"; 1889 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1890 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1891 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1892 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1893 1894 substr = "/*Test$5*/"; 1895 exp1 = "Temp.Test$5"; 1896 exp2 = "5"; 1897 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1898 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1899 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1900 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1901 1902 substr = "\"parameter 2 = Test$5\""; 1903 exp1 = "Temp.Test$5"; 1904 exp2 = "5"; 1905 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1906 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1907 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1908 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1909 1910 substr = "/*c-anon2()*/"; 1911 exp1 = "Temp.Test"; 1912 exp2 = "Test"; 1913 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1914 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1915 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1916 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1917 1918 substr = "/*Test$6*/"; 1919 exp1 = "Temp.Test$6"; 1920 exp2 = "6"; 1921 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1922 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1923 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1924 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1925 1926 substr = "\"Test$6\""; 1927 exp1 = "Temp.Test$6"; 1928 exp2 = "6"; 1929 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1930 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1931 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1932 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1933 1934 substr = "/*anon3()*/"; 1935 exp1 = "Temp.Test"; 1936 exp2 = "Test"; 1937 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1938 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1939 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1940 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1941 1942 substr = "/*Test$7*/"; 1943 exp1 = "Temp.Test$7"; 1944 exp2 = "7"; 1945 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1946 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1947 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1948 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1949 1950 substr = "\"doSomething\""; 1951 exp1 = "Temp.Test$7$NamedClassAgain"; 1952 exp2 = "NamedClassAgain"; 1953 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1954 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1955 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1956 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1957 1958 substr = "\"parameter 3 = Test$7\""; 1959 exp1 = "Temp.Test$7"; 1960 exp2 = "7"; 1961 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1962 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1963 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1964 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1965 1966 substr = "/*Test$7$1*/"; 1967 exp1 = "Temp.Test$7$1"; 1968 exp2 = "1"; 1969 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1970 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1971 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1972 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1973 1974 substr = "\"Test$7$1\""; 1975 exp1 = "Temp.Test$7$1"; 1976 exp2 = "1"; 1977 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1978 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1979 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1980 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1981 1982 substr = "/*c-anon2()*/"; 1983 exp1 = "Temp.Test"; 1984 exp2 = "Test"; 1985 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1986 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1987 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1988 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1989 1990 substr = "/*Test$8*/"; 1991 exp1 = "Temp.Test$8"; 1992 exp2 = "8"; 1993 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 1994 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 1995 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 1996 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 1997 1998 substr = "\"Test$8\""; 1999 exp1 = "Temp.Test$8"; 2000 exp2 = "8"; 2001 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 2002 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 2003 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 2004 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 2005 2006 substr = "abstract void feeDo()"; 2007 exp1 = "Temp.Fee"; 2008 exp2 = "Fee"; 2009 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 2010 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 2011 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 2012 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 2013 2014 substr = "class FeeConc extends Fee"; 2015 exp1 = "Temp.Fee"; 2016 exp2 = "Fee"; 2017 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 2018 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 2019 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 2020 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 2021 2022 substr = "/*Fee$FeeConc*/"; 2023 exp1 = "Temp.Fee$FeeConc"; 2024 exp2 = "FeeConc"; 2025 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 2026 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 2027 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 2028 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 2029 2030 substr = "\"FeeConc/feeDo\""; 2031 exp1 = "Temp.Fee$FeeConc"; 2032 exp2 = "FeeConc"; 2033 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 2034 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 2035 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 2036 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 2037 2038 substr = "\"FeeConc/feeAct\""; 2039 exp1 = "Temp.Fee$FeeConc"; 2040 exp2 = "FeeConc"; 2041 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 2042 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 2043 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 2044 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 2045 2046 substr = "\"FeeConc/s\""; 2047 exp1 = "Temp.Fee$FeeConc"; 2048 exp2 = "FeeConc"; 2049 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 2050 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 2051 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 2052 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 2053 2054 substr = "\"FeeConc/t\""; 2055 exp1 = "Temp.Fee$FeeConc"; 2056 exp2 = "FeeConc"; 2057 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 2058 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 2059 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 2060 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 2061 2062 substr = "\"FeeConc/u\""; 2063 exp1 = "Temp.Fee$FeeConc"; 2064 exp2 = "FeeConc"; 2065 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 2066 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 2067 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 2068 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 2069 2070 substr = "/*Fee$1*/"; 2071 exp1 = "Temp.Fee$1"; 2072 exp2 = "1"; 2073 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 2074 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 2075 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 2076 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 2077 2078 substr = "\"Fee$1/feeDo\""; 2079 exp1 = "Temp.Fee$1"; 2080 exp2 = "1"; 2081 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 2082 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 2083 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 2084 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 2085 2086 substr = "\"Fee$1/feeAct\""; 2087 exp1 = "Temp.Fee$1"; 2088 exp2 = "1"; 2089 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 2090 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 2091 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 2092 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 2093 2094 substr = "\"Fee$1/s\""; 2095 exp1 = "Temp.Fee$1"; 2096 exp2 = "1"; 2097 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 2098 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 2099 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 2100 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 2101 2102 substr = "\"Fee$1/t\""; 2103 exp1 = "Temp.Fee$1"; 2104 exp2 = "1"; 2105 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 2106 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 2107 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 2108 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 2109 2110 substr = "\"Fee$1/u\""; 2111 exp1 = "Temp.Fee$1"; 2112 exp2 = "1"; 2113 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 2114 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 2115 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 2116 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 2117 2118 substr = "/*Test$Outer$Middle$1*/"; 2119 exp1 = "Temp.Test$Outer$Middle$1"; 2120 exp2 = "1"; 2121 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 2122 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 2123 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 2124 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 2125 2126 substr = "\"Test$Outer$Middle$1\""; 2127 exp1 = "Temp.Test$Outer$Middle$1"; 2128 exp2 = "1"; 2129 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 2130 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 2131 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 2132 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 2133 2134 substr = "/*Test$9*/"; 2135 exp1 = "Temp.Test$9"; 2136 exp2 = "9"; 2137 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 2138 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 2139 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 2140 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 2141 2142 substr = "\"Test$9\""; 2143 exp1 = "Temp.Test$9"; 2144 exp2 = "9"; 2145 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 2146 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 2147 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 2148 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 2149 2150 substr = "/*Test$10*/"; 2151 exp1 = "Temp.Test$10"; 2152 exp2 = "10"; 2153 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 2154 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 2155 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 2156 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 2157 2158 substr = "\"Test$10\""; 2159 exp1 = "Temp.Test$10"; 2160 exp2 = "10"; 2161 act1 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), true); 2162 act2 = _defModel.getEnclosingClassName(NESTED_CLASSES_TEXT.indexOf(substr), false); 2163 assertEquals("class name at "+substr+" exp=`"+exp1+"`, act=`"+act1+"`", exp1, act1); 2164 assertEquals("class name at "+substr+" exp=`"+exp2+"`, act=`"+act2+"`", exp2, act2); 2165 } 2166} 2167 | Popular Tags |