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 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()); }
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 } }
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()); }
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()); }
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()); }
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); }
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()); }