Example #1
0
  public void testRenameWithInit() {
    field.setInitializer(fact.newStringLiteral("foo"));
    assertTrue(field.getInitializer() instanceof ASStringLiteral);

    field.setName("foo");
    // renaming the field should cause the initialiser to vanish
    assertNotNull(field.getInitializer());
  }
 public void testBasic() {
   // pathenthesised expressions control evaluation order, but
   // don't have any other meaning, therefore metaas doesn't
   // expose them in the DOM, except in their implied effect on
   // the expression tree structure.
   Expression expr = fact.newExpression("(1+1)");
   assertTrue(expr instanceof ASBinaryExpression);
   assertEquals(ASBinaryExpression.Op.ADD, ((ASBinaryExpression) expr).getOperator());
 }
Example #3
0
  public void testInit() throws IOException {
    // should no none to start with,
    assertNull(field.getInitializer());

    field.setInitializer(fact.newStringLiteral("foo"));
    assertTrue(field.getInitializer() instanceof ASStringLiteral);

    field.setInitializer("1");
    assertTrue(field.getInitializer() instanceof ASIntegerLiteral);

    field.setInitializer((String) null); // remove it again
    assertNull(field.getInitializer());

    field.setInitializer((Expression) null); // when already absent

    // complicated initialiser value,
    field.setInitializer("function() { trace('test'); }");
    CodeMirror.assertReflection(fact, unit);
  }
Example #4
0
 protected void setUp() {
   unit = fact.newClass("Test");
   ASClassType clazz = (ASClassType) unit.getType();
   field = clazz.newField("test", Visibility.PUBLIC, "Bar");
 }
Example #5
0
 public void testMultiplicative() {
   expr = (ASBinaryExpression) fact.newExpression("1 * 2 * 2");
   Expression left = fact.newIntegerLiteral(1);
   expr.setLeftSubexpression(left);
 }
Example #6
0
 public void testAdditive() {
   expr = (ASBinaryExpression) fact.newExpression("1 + 2 + 2");
   Expression left = fact.newIntegerLiteral(1);
   expr.setLeftSubexpression(left);
 }
Example #7
0
 public void testShift() {
   expr = (ASBinaryExpression) fact.newExpression("a << b << c");
   Expression left = fact.newExpression("foo");
   expr.setLeftSubexpression(left);
 }
Example #8
0
 public void testRelational() {
   // not strictly possible (I wonder if the grammar should forbid?)
   expr = (ASBinaryExpression) fact.newExpression("a < b < c");
   Expression left = fact.newExpression("foo");
   expr.setLeftSubexpression(left);
 }
Example #9
0
 public void testEquality() {
   expr = (ASBinaryExpression) fact.newExpression("a == b == c");
   Expression left = fact.newExpression("foo");
   expr.setLeftSubexpression(left);
 }
Example #10
0
 public void testBitAnd() {
   expr = (ASBinaryExpression) fact.newExpression("a & b & c");
   Expression left = fact.newExpression("foo");
   expr.setLeftSubexpression(left);
 }
Example #11
0
 public void testXor() {
   expr = (ASBinaryExpression) fact.newExpression("a ^ b ^ c");
   Expression left = fact.newExpression("foo");
   expr.setLeftSubexpression(left);
 }
Example #12
0
 public void testLogicalOr() {
   expr = (ASBinaryExpression) fact.newExpression("a || b || c");
   Expression left = fact.newExpression("foo");
   expr.setLeftSubexpression(left);
 }