コード例 #1
0
 public void testDeleteAsPropertyExpression() {
   Script script = parse("a.delete = function(){}");
   assertFalse(reporter.hasErrors());
   BinaryOperation assignment = uniqueResult(ASTUtil.select(script, BinaryOperation.class));
   assertEquals("a.delete", PropertyExpressionUtils.getPath(assignment.getLeftExpression()));
   assertTrue(assignment.getRightExpression() instanceof FunctionStatement);
 }
コード例 #2
0
 public void testDeleteInObjectLiteral() {
   final Script script = parse("var keywords={delete:1}");
   assertFalse(reporter.hasErrors());
   final VariableDeclaration var = uniqueResult(ASTUtil.select(script, VariableDeclaration.class));
   final ObjectInitializer object = (ObjectInitializer) var.getInitializer();
   assertEquals(1, object.getInitializers().size());
   assertIdentifier("delete", object.getPropertyInitializers()[0].getName());
   assertDecimal("1", object.getPropertyInitializers()[0].getValue());
 }