jltools.visit
Class NodeScrambler

java.lang.Object
  |
  +--jltools.ast.NodeVisitor
        |
        +--jltools.visit.NodeScrambler

public class NodeScrambler
extends NodeVisitor

The NodeScrambler is test case generator of sorts. Since it is ofter useful to introduce ``random'' errors into source code, this class provides a way of doing so in a semi-structed manner. The process takes place in two phases. First, a "FirstPass" is made to collect a list of nodes and their parents. Then a second pass is made to randomly replace a branch of the tree with another suitable branch.


Inner Class Summary
 class NodeScrambler.FirstPass
          Scans throught the AST, create a list of all nodes present, along with the set of parents for each node in the tree.
 
Field Summary
 NodeScrambler.FirstPass fp
           
 
Constructor Summary
NodeScrambler()
           
NodeScrambler(long seed)
          Create a new NodeScrambler with the given random number generator seed.
 
Method Summary
protected  boolean coinFlip()
           
 long getSeed()
           
 Node override(Node n)
          Given a tree rooted at n, the visitor has the option of overriding all traversal of the children of n.
protected  Node potentialScramble(Node n)
           
 
Methods inherited from class jltools.ast.NodeVisitor
enter, finish, leave, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

fp

public NodeScrambler.FirstPass fp
Constructor Detail

NodeScrambler

public NodeScrambler()

NodeScrambler

public NodeScrambler(long seed)
Create a new NodeScrambler with the given random number generator seed.
Method Detail

getSeed

public long getSeed()

override

public Node override(Node n)
Description copied from class: NodeVisitor
Given a tree rooted at n, the visitor has the option of overriding all traversal of the children of n. If no changes were made to n and the visitor wishes to prevent further traversal of the tree, then it should return n. If changes were made to the subtree, then the visitor should return a copy of n with appropriate changes. Finally, if the visitor does not wish to override traversal of the subtree rooted at n, then it should return null.
Overrides:
override in class NodeVisitor
Following copied from class: jltools.ast.NodeVisitor
Parameters:
n - The root of the subtree to be traversed.
Returns:
A node if normal traversal is to stop, null if it is to continue.

coinFlip

protected boolean coinFlip()

potentialScramble

protected Node potentialScramble(Node n)