Ejemplo n.º 1
0
 public void testModify1() {
   String[] oldL = {"A", "X", "C"};
   String[] newL = {"A", "B", "C"};
   String golden = "";
   ListMatcher matcher = ListMatcher.instance(oldL, newL);
   if (matcher.match()) {
     Separator s = new Separator(matcher.getTransformedResult(), JavaTokenId.COMMA);
     s.compute();
     System.err.println("testModify1: ");
     System.err.println(p(oldL, newL));
     System.err.println(s.print());
     assertEquals(golden, s.print());
   } else {
     assertTrue("No match!", false);
   }
 }
Ejemplo n.º 2
0
 public void testAddToEmpty() {
   String[] oldL = {};
   String[] newL = {"A", "B", "C"};
   String golden = "head {insert} A next \n" + "{insert} B next \n" + "{insert} C tail \n";
   ListMatcher matcher = ListMatcher.instance(oldL, newL);
   if (matcher.match()) {
     Separator s = new Separator(matcher.getTransformedResult(), JavaTokenId.COMMA);
     s.compute();
     System.err.println("testAddToEmpty: ");
     System.err.println(p(oldL, newL));
     System.err.println(s.print());
     assertEquals(golden, s.print());
   } else {
     assertTrue("No match!", false);
   }
 }
Ejemplo n.º 3
0
 public void testRemoveLast2() {
   String[] oldL = {"A"};
   String[] newL = {};
   String golden = "head {delete} A tail \n";
   ListMatcher matcher = ListMatcher.instance(oldL, newL);
   if (matcher.match()) {
     Separator s = new Separator(matcher.getTransformedResult(), JavaTokenId.COMMA);
     s.compute();
     System.err.println("testRemoveLast2:");
     System.err.println(p(oldL, newL));
     System.err.println(s.print());
     assertEquals(golden, s.print());
   } else {
     assertTrue("No match!", false);
   }
 }
Ejemplo n.º 4
0
 public void testRemoveLastThree() {
   String[] oldL = {"A", "B", "C", "D"};
   String[] newL = {"A"};
   String golden = "previous {delete} B next \n" + "{delete} C next \n" + "{delete} D \n";
   ListMatcher matcher = ListMatcher.instance(oldL, newL);
   if (matcher.match()) {
     Separator s = new Separator(matcher.getTransformedResult(), JavaTokenId.COMMA);
     s.compute();
     System.err.println("testRemoveLastThree:");
     System.err.println(p(oldL, newL));
     System.err.println(s.print());
     assertEquals(golden, s.print());
   } else {
     assertTrue("No match!", false);
   }
 }
Ejemplo n.º 5
0
 public void testComplex() {
   String[] oldL = {"A", "B", "C", "D", "E", "F", "G"};
   String[] newL = {"B", "C", "C1", "D", "E", "G", "H"};
   String golden =
       "{delete} A next \n"
           + "{insert} C1 next \n"
           + "{delete} F next \n"
           + "previous {insert} H \n";
   ListMatcher matcher = ListMatcher.instance(oldL, newL);
   if (matcher.match()) {
     Separator s = new Separator(matcher.getTransformedResult(), JavaTokenId.COMMA);
     s.compute();
     System.err.println("testComplex: ");
     System.err.println(p(oldL, newL));
     System.err.println(s.print());
     assertEquals(golden, s.print());
   } else {
     assertTrue("No match!", false);
   }
 }