Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions core/src/test/java/fj/ClassTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package fj;

import fj.data.List;
import fj.data.Natural;
import fj.data.Option;
import fj.data.Tree;
import org.junit.Test;

import java.lang.reflect.Type;
import java.util.Collection;
import java.util.Iterator;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

public class ClassTest {
@Test
public void testInheritance() {
Class<Natural> c = Class.clas(Natural.class);
List<Class<? super Natural>> l = c.inheritance();
assertThat(l.length(), is(3));
}

@Test
public void testClassParameters() {
Class c = Class.clas(Option.none().getClass());
Tree<Type> cp = c.classParameters();
assertThat(cp.length(), is(1));
}

@Test
public void testSuperclassParameters() {
Class c = Class.clas(Option.none().getClass());
Tree<Type> cp = c.superclassParameters();
assertThat(cp.length(), is(2));
}

@Test
public void testInterfaceParameters() {
Class c = Class.clas(Option.none().getClass());
List<Type> l =c.interfaceParameters();
assertThat(l.length(), is(0));
}

@Test
public void testTypeParameterTree() {
Class c = Class.clas(Option.none().getClass());
Collection<Type> coll = c.classParameters().toCollection();
for (Type t: coll) {
assertThat(Class.typeParameterTree(t).toString(), is("Tree(class fj.data.Option$None)"));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to assert something in this method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

}
}