forked from functionaljava/functionaljava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIOTest.java
More file actions
30 lines (23 loc) · 858 Bytes
/
IOTest.java
File metadata and controls
30 lines (23 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package fj;
import fj.data.IO;
import fj.data.IOFunctions;
import org.junit.Test;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
public class IOTest {
@Test
public void testLift() throws IOException {
final IO<String> readName = () -> new BufferedReader(new StringReader("foo")).readLine();
final F<String, IO<String>> upperCaseAndPrint = F1Functions.<String, IO<String>, String>o(this::println).f(String::toUpperCase);
final IO<String> readAndPrintUpperCasedName = IOFunctions.bind(readName, upperCaseAndPrint);
assertThat(readAndPrintUpperCasedName.run(), is("FOO"));
}
public IO<String> println(final String s) {
return () -> {
return s;
};
}
}