polyglot.visit
Class NodeScrambler
java.lang.Object
polyglot.visit.NodeVisitor
polyglot.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.
Nested 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. |
Constructor Summary |
NodeScrambler()
|
NodeScrambler(long seed)
Create a new NodeScrambler with the given random number
generator seed. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
fp
public NodeScrambler.FirstPass fp
pairs
protected java.util.HashMap pairs
nodes
protected java.util.LinkedList nodes
currentParents
protected java.util.LinkedList currentParents
seed
protected long seed
ran
protected java.util.Random ran
scrambled
protected boolean scrambled
cw
protected CodeWriter cw
NodeScrambler
public NodeScrambler()
NodeScrambler
public NodeScrambler(long seed)
- Create a new
NodeScrambler
with the given random number
generator seed.
getSeed
public long getSeed()
override
public Node override(Node n)
- Overrides:
override
in class NodeVisitor
coinFlip
protected boolean coinFlip()
potentialScramble
protected Node potentialScramble(Node n)