Skip to content

Commit ae8864e

Browse files
committed
Merge pull request #262 from gliptak/coverage4
Add tests for fj.Class
2 parents f831eb5 + e93d78a commit ae8864e

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package fj;
2+
3+
import fj.data.List;
4+
import fj.data.Natural;
5+
import fj.data.Option;
6+
import fj.data.Tree;
7+
import org.junit.Test;
8+
9+
import java.lang.reflect.Type;
10+
import java.util.Collection;
11+
import java.util.Iterator;
12+
13+
import static org.hamcrest.core.Is.is;
14+
import static org.junit.Assert.assertThat;
15+
16+
public class ClassTest {
17+
@Test
18+
public void testInheritance() {
19+
Class<Natural> c = Class.clas(Natural.class);
20+
List<Class<? super Natural>> l = c.inheritance();
21+
assertThat(l.length(), is(3));
22+
}
23+
24+
@Test
25+
public void testClassParameters() {
26+
Class c = Class.clas(Option.none().getClass());
27+
Tree<Type> cp = c.classParameters();
28+
assertThat(cp.length(), is(1));
29+
}
30+
31+
@Test
32+
public void testSuperclassParameters() {
33+
Class c = Class.clas(Option.none().getClass());
34+
Tree<Type> cp = c.superclassParameters();
35+
assertThat(cp.length(), is(2));
36+
}
37+
38+
@Test
39+
public void testInterfaceParameters() {
40+
Class c = Class.clas(Option.none().getClass());
41+
List<Type> l =c.interfaceParameters();
42+
assertThat(l.length(), is(0));
43+
}
44+
45+
@Test
46+
public void testTypeParameterTree() {
47+
Class c = Class.clas(Option.none().getClass());
48+
Collection<Type> coll = c.classParameters().toCollection();
49+
for (Type t: coll) {
50+
assertThat(Class.typeParameterTree(t).toString(), is("Tree(class fj.data.Option$None)"));
51+
}
52+
}
53+
}

0 commit comments

Comments
 (0)