Skip to content

Commit 5043362

Browse files
committed
Add test for IO
1 parent 12b6163 commit 5043362

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

core/src/test/java/fj/IOTest.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package fj;
2+
3+
import fj.data.IO;
4+
import fj.data.IOFunctions;
5+
import org.junit.Test;
6+
7+
import java.io.BufferedReader;
8+
import java.io.IOException;
9+
import java.io.StringReader;
10+
11+
import static org.hamcrest.core.Is.is;
12+
import static org.junit.Assert.assertThat;
13+
14+
15+
public class IOTest {
16+
17+
@Test
18+
public void testLift() throws IOException {
19+
final IO<String> readName = () -> new BufferedReader(new StringReader("foo")).readLine();
20+
final F<String, IO<String>> upperCaseAndPrint = F1Functions.<String, IO<String>, String>o(this::println).f(String::toUpperCase);
21+
final IO<String> readAndPrintUpperCasedName = IOFunctions.bind(readName, upperCaseAndPrint);
22+
assertThat(readAndPrintUpperCasedName.run(), is("FOO"));
23+
}
24+
25+
public IO<String> println(final String s) {
26+
return () -> {
27+
return s;
28+
};
29+
}
30+
}

0 commit comments

Comments
 (0)