Created
July 25, 2008 00:05
-
-
Save nkpart/2344 to your computer and use it in GitHub Desktop.
undefined
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.vlc.beach.zoning; | |
import static com.googlecode.instinct.expect.Expect.expect; | |
import com.googlecode.instinct.integrate.junit4.InstinctRunner; | |
import com.googlecode.instinct.marker.annotate.Mock; | |
import com.googlecode.instinct.marker.annotate.Specification; | |
import static com.vlc.beach.zoning.SpecNotWorkingContext.Applicator.applicator; | |
import fj.F; | |
import org.jmock.Expectations; | |
import org.junit.runner.RunWith; | |
@RunWith(InstinctRunner.class) | |
public final class SpecNotWorkingContext { | |
@Mock private F<String, String> mockF; | |
// This is what breaks it, instinct tries to force this to a @Dummy, but it's a concrete class. | |
private String dummyString = "foo"; | |
@Specification (state = Specification.SpecificationState.PENDING) | |
public void shouldLoadFile() throws Exception { | |
final Applicator<String, String> a = applicator(mockF, dummyString); | |
expect.that(new Expectations() { | |
{ | |
one(mockF).f(dummyString); | |
will(returnValue("lulz")); | |
} | |
}); | |
expect.that(a.apply()).isEqualTo("lulz"); | |
} | |
public static final class Applicator<A, B> { | |
private final F<A,B> f; | |
private final A a; | |
public Applicator(final F<A, B> f, final A a) { | |
this.f = f; | |
this.a = a; | |
} | |
public B apply() { | |
return f.f(a); | |
} | |
public static <A, B> Applicator<A, B> applicator(final F<A, B> f, final A a) { | |
return new Applicator<A, B>(f, a); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment