Skip to content

Commit

Permalink
fixing the example. Seems to have lost the changes from the zaphod42 …
Browse files Browse the repository at this point in the history
…fork
  • Loading branch information
Andrew Parker committed Oct 29, 2010
1 parent c9fb99c commit 0d6f665
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions examples/example_1/src/test/java/BasicArithmeticTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class BasicArithmeticTest {
You need to define an Actor to get started. The Actor performs various actions on the domain
objects - in this case we have just one object, the calculator.
*/
private Actor<Calculator> operator = new CalculatorActor();
private CalculatorActor operator = new CalculatorActor();

/*
The tests themselves, in given-when-then style. Narrative provides everything used here
Expand Down Expand Up @@ -49,10 +49,10 @@ except the press() and the_displayed_value() methods defined below, and the Hamc
Here we define press() and the_displayed_value(). They just delegate to the corresponding
actions on the calculator.
*/
private static Action<Calculator> press(final char keypress) {
return new Action<Calculator>() {
public void performFor(Calculator calculator, Stash stash) {
calculator.press(keypress);
private static Action<Calculator, CalculatorActor> press(final char keypress) {
return new Action<Calculator, CalculatorActor>() {
public void performFor(CalculatorActor actor) {
actor.tool().press(keypress);
}
};
}
Expand All @@ -68,15 +68,19 @@ public String grabFor(CalculatorActor actor) {
/*
The Actor that does all the work as commanded by the tests.
*/
private static class CalculatorActor implements Actor<Calculator> {
private static class CalculatorActor implements Actor<Calculator, CalculatorActor> {
private Calculator calculator = new Calculator();

public Calculator tool() {
return calculator;
}

public <DATA> DATA grabUsing(Extractor<DATA, Calculator> extractor) {
return extractor.grabFrom(calculator, new HashMapStash());
public void perform(Action<Calculator, CalculatorActor> action) {
action.performFor(this);
}

public <DATA> DATA grabUsing(Extractor<DATA, CalculatorActor> extractor) {
return extractor.grabFor(this);
}
}
}

0 comments on commit 0d6f665

Please sign in to comment.