Esempio n. 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());
  }
Esempio n. 2
0
 public void testConstSerialisation() throws IOException {
   field.setConst(true);
   field.setName("renamed");
   unit = CodeMirror.assertReflection(fact, unit);
   field = ((ASClassType) unit.getType()).getField("renamed");
   assertNotNull(field);
   assertTrue(field.isConst());
 }
Esempio n. 3
0
 public void testName() {
   assertEquals("test", field.getName());
   field.setName("foobar");
   assertEquals("foobar", field.getName());
   try {
     field.setName("bad.name");
     fail("should not have accepted field name containing '.'");
   } catch (SyntaxException e) {
     // expected
   }
 }
Esempio n. 4
0
 public void testStatic() {
   assertFalse("new fields should be non-static by default", field.isStatic());
   field.setStatic(false);
   assertFalse("seting non-static when already non-static should be ok", field.isStatic());
   field.setStatic(true);
   assertTrue("changing to static failed", field.isStatic());
   field.setStatic(true);
   assertTrue("static static when already static didn't work", field.isStatic());
   field.setStatic(false);
   assertFalse("removing static again didn't work", field.isStatic());
 }
Esempio n. 5
0
  public void testType() {
    assertEquals("Bar", field.getType());
    // overwrite the old type,
    field.setType("Foo");
    assertEquals("Foo", field.getType());

    field.setType(null);
    assertNull(field.getType());
    field.setType(null); // when already absent

    field.setType("Foo");
    assertEquals("Foo", field.getType());
  }
Esempio n. 6
0
  public void testConst() {
    assertFalse(field.isConst());
    field.setConst(true);
    assertTrue(field.isConst());
    field.setConst(false);
    assertFalse(field.isConst());

    // set it to the value it already has,
    field.setConst(false);
    assertFalse(field.isConst());
  }
Esempio n. 7
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);
  }
Esempio n. 8
0
  public void testDocComment() {
    // initial add,
    String comment = "foo\n bar";
    field.setDocComment(comment);
    assertEquals(comment, field.getDocComment());

    // modify,
    comment = "blat";
    field.setDocComment(comment);
    assertEquals(comment, field.getDocComment());

    // delete,
    field.setDocComment(null);
    assertNull(field.getDocComment());
  }