Home | History | Annotate | Download | only in bdd
      1 Scenario: A class that is replicated using a CloneVisitor should be equal to the source
      2 
      3 Given a CompilationUnit
      4 Given a second CompilationUnit
      5 When the following source is parsed:
      6 package japa.parser;
      7 public class ClassEquality {
      8 
      9     public void aMethod(){
     10         int a=0; // second comment
     11     }
     12 }
     13 When the CompilationUnit is cloned to the second CompilationUnit
     14 Then the CompilationUnit is equal to the second CompilationUnit
     15 Then the CompilationUnit has the same hashcode to the second CompilationUnit
     16 
     17 
     18 Scenario: A classes variable name is changed to uppercase VoidVisitorAdapter
     19 
     20 Given a CompilationUnit
     21 Given a VoidVisitorAdapter with a visit method that changes variable names to uppercase
     22 When the following source is parsed:
     23 package japa.parser;
     24 public class ToUpperClass {
     25     private int zero = 0;
     26 }
     27 When the CompilationUnit is visited by the to uppercase visitor
     28 Then the expected source should be:
     29 package japa.parser;
     30 public class ToUpperClass {
     31     private int ZERO = 0;
     32 }
     33 
     34 Scenario: A class with a try statement is visited using by a VoidVisitorAdapter
     35 
     36 Given a CompilationUnit
     37 Given a VoidVisitorAdapter with a visit method and collects the variable names
     38 When the following source is parsed:
     39 package japa.parser;
     40 public class ToUpperClass {
     41     public void aMethod(){
     42         try {
     43             int zero = 0;
     44         }catch (Exception exception) {
     45         }
     46     }
     47 }
     48 When the CompilationUnit is visited by the variable name collector visitor
     49 Then the collected variable name is "exception;zero;"
     50 
     51 
     52 Scenario: A class with a try statement is visited using by a GenericVisitorAdapter
     53 
     54 Given a CompilationUnit
     55 Given a GenericVisitorAdapter with a visit method that returns variable names
     56 When the following source is parsed:
     57 package japa.parser;
     58 public class ToUpperClass {
     59     public void aMethod(){
     60         try {
     61             int zero = 0;
     62         }catch (Exception exception) {
     63         }
     64     }
     65 }
     66 When the CompilationUnit is visited by the visitor that returns variable names
     67 Then the return variable name is "zero"
     68