The typical shape of this node is:
IUnaryOperatorNode IExpressionNode <-- getOperandNode()
-a
IUnaryOperatorNode "-" IIdentifierNode "a"
312313314315316317318319320
protected IUnaryOperatorNode getUnaryNode(String code) { String source = "package {public class A {function a():void {" + code + "}}"; IFileNode node = getFileNode(source); IUnaryOperatorNode child = (IUnaryOperatorNode) findFirstDescendantOfType( node, IUnaryOperatorNode.class); return child; }
150151152153154155156157158
} @Test public void testVisitUnaryOperatorNode_PostIncrement() { IUnaryOperatorNode node = getUnaryNode("a++"); visitor.visitUnaryOperator(node); assertOut("a++"); }
158159160161162163164165166
} @Test public void testVisitUnaryOperatorNode_PreIncrement() { IUnaryOperatorNode node = getUnaryNode("++a"); visitor.visitUnaryOperator(node); assertOut("++a"); }
166167168169170171172173174
} @Test public void testVisitUnaryOperatorNode_PostDecrement() { IUnaryOperatorNode node = getUnaryNode("a--"); visitor.visitUnaryOperator(node); assertOut("a--"); }
174175176177178179180181182
} @Test public void testVisitUnaryOperatorNode_PreDecrement() { IUnaryOperatorNode node = getUnaryNode("--a"); visitor.visitUnaryOperator(node); assertOut("--a"); }
258259260261262263264265266
} @Test public void testVisitUnaryOperatorNode_BitwiseNot() { IUnaryOperatorNode node = getUnaryNode("~a"); visitor.visitUnaryOperator(node); assertOut("~a"); }
439440441442443444445446447
} @Test public void testVisitUnaryOperatorNode_LogicalNot() { IUnaryOperatorNode node = getUnaryNode("!a"); visitor.visitUnaryOperator(node); assertOut("!a"); }
569570571572573574575576577
} @Test public void testVisitUnaryOperator_Delete() { IUnaryOperatorNode node = getUnaryNode("delete a"); visitor.visitUnaryOperator(node); assertOut("delete a"); }
684685686687688689690691692
} @Test public void testVisitUnaryOperatorNode_Typeof() { IUnaryOperatorNode node = getUnaryNode("typeof(a)"); visitor.visitUnaryOperator(node); assertOut("typeof(a)"); }
694695696697698699700701702
@Ignore @Test public void testVisitUnaryOperatorNode_Typeof_NoParens() { // TODO (erikdebruin/mschmalle) this notation is also valid in AS/JS IUnaryOperatorNode node = getUnaryNode("typeof a"); visitor.visitUnaryOperator(node); assertOut("typeof a"); }