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