-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathRunner.java
More file actions
31 lines (24 loc) · 1.33 KB
/
Runner.java
File metadata and controls
31 lines (24 loc) · 1.33 KB
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
31
import java.util.concurrent.ExecutionException;
public class Runner {
private static final String OUTPUT_METHOD = "toString";
private static final String MOVE_METHOD = "move";
private static final String CLONE_METHOD = "cloneAsActor";
public static void main(String[] args) throws ExecutionException, InterruptedException {
Actor actor = ActorClosureFactory.createActor(Point.class, 10, 20);
// "toString" function must return string with coords
String output = (String) actor.send(OUTPUT_METHOD).get();
System.out.println(output); // "(10, 20)"
// "cloneAsActor" function must create another actor
Actor clone = (Actor) actor.send(CLONE_METHOD).get();
System.out.println(actor == clone); // false
// "move" function should not return anything
Object move = clone.send(MOVE_METHOD, -5, 10).get();
System.out.println(move); // null
// "toString" on CLONED object must return changed coords
String movedClonedOutput = (String) clone.send(OUTPUT_METHOD).get();
System.out.println(movedClonedOutput); // "(5, 30)"
// "toString" on SOURCE object must return original unchanged coords
String movedSourceOutput = (String) actor.send(OUTPUT_METHOD).get();
System.out.println(movedSourceOutput); // "(10, 20)"
}
}