use of org.whole.lang.java.codebase.Factorial in project whole by wholeplatform.
the class ScannerTest method testSkip.
@Test
public void testSkip() {
IEntity fact = new Factorial().create();
ScannerIterator<IEntity> s = IteratorFactory.descendantOrSelfScannerIterator();
s.reset(fact);
try {
s.skipTo(JavaEntityDescriptorEnum.SingleVariableDeclaration);
s.next();
String str1 = s.nextString();
String str2 = s.nextString();
Assert.assertEquals("int", str1);
Assert.assertEquals("false", str2);
} catch (Exception e) {
Assert.fail();
}
}
use of org.whole.lang.java.codebase.Factorial in project whole by wholeplatform.
the class ScannerTest method testNext.
@Test
public void testNext() {
IEntity fact = new Factorial().create();
ScannerIterator<IEntity> s = IteratorFactory.descendantOrSelfScannerIterator();
s.reset(fact);
try {
IEntity e1 = s.next(JavaEntityDescriptorEnum.CompilationUnit);
IEntity e2 = s.next();
s.next();
s.next();
s.next();
s.next();
String str = s.nextString();
Assert.assertEquals(JavaEntityDescriptorEnum.CompilationUnit, e1.wGetEntityDescriptor());
Assert.assertEquals(JavaEntityDescriptorEnum.PackageDeclaration, e2.wGetEntityDescriptor());
Assert.assertEquals("Copyright 2004-2016 Riccardo Solmi.", str);
} catch (Exception e) {
Assert.fail();
}
}
use of org.whole.lang.java.codebase.Factorial in project whole by wholeplatform.
the class TraversalFactoryTest method testTraverseParent.
@Test
public void testTraverseParent() {
IEntity fact = new Factorial().create();
CommonsEntityFactory.instance.createRootFragment(fact.wGetAdapter(CommonsEntityDescriptorEnum.Any));
List<IEntity> c = new ArrayList<IEntity>();
tf.spineTopDown(tf.collect(tf.identity(), c), false).visit(fact);
assertTrue(c.size() > 1);
IEntity leaf = (IEntity) c.get(c.size() - 1);
List<IEntity> c2 = new ArrayList<IEntity>();
tf.ancestors(tf.collect(tf.identity(), c2)).visit(leaf);
c.add(0, fact.wGetParent());
Collections.reverse(c2);
assertEquals(c, c2);
}
use of org.whole.lang.java.codebase.Factorial in project whole by wholeplatform.
the class TraversalFactoryTest method testMatchDescriptor.
@Test
public void testMatchDescriptor() {
IEntity fact = new Factorial().create();
Set<IEntity> c = new HashSet<IEntity>();
tf.collect(mf.hasTypeMatcher(JavaEntityDescriptorEnum.CompilationUnit), c).visit(fact);
assertFalse(c.isEmpty());
}
use of org.whole.lang.java.codebase.Factorial in project whole by wholeplatform.
the class TraversalFactoryTest method testMatchKind.
@Test
public void testMatchKind() {
IEntity fact = new Factorial().create();
Set<IEntity> c = new HashSet<IEntity>();
tf.collect(mf.hasKindMatcher(EntityKinds.SIMPLE), c).visit(fact);
assertFalse(c.isEmpty());
}