1+ package com .jnape .palatable .lambda .functions .builtin .fn2 ;
2+
3+ import com .jnape .palatable .lambda .adt .hlist .Tuple2 ;
4+ import com .jnape .palatable .lambda .functions .Fn1 ;
5+ import com .jnape .palatable .lambda .monoid .builtin .Concat ;
6+ import com .jnape .palatable .traitor .annotations .TestTraits ;
7+ import com .jnape .palatable .traitor .runners .Traits ;
8+ import org .junit .Test ;
9+ import org .junit .runner .RunWith ;
10+ import testsupport .traits .EmptyIterableSupport ;
11+ import testsupport .traits .FiniteIteration ;
12+ import testsupport .traits .ImmutableIteration ;
13+ import testsupport .traits .InfiniteIterableSupport ;
14+ import testsupport .traits .Laziness ;
15+
16+ import static com .jnape .palatable .lambda .functions .builtin .fn2 .Eq .eq ;
17+ import static com .jnape .palatable .lambda .functions .builtin .fn2 .Into .into ;
18+ import static com .jnape .palatable .lambda .functions .builtin .fn2 .Span .span ;
19+ import static java .util .Arrays .asList ;
20+ import static org .junit .Assert .assertThat ;
21+ import static testsupport .matchers .IterableMatcher .iterates ;
22+
23+ @ RunWith (Traits .class )
24+ public class SpanTest {
25+
26+ @ TestTraits ({EmptyIterableSupport .class , InfiniteIterableSupport .class , FiniteIteration .class , ImmutableIteration .class , Laziness .class })
27+ public Fn1 <Iterable <Integer >, Iterable <Integer >> testSubject () {
28+ return span (eq (0 )).fmap (into (Concat ::concat ));
29+ }
30+
31+ @ Test
32+ public void splitsIterableAfterPredicateFailure () {
33+ Tuple2 <Iterable <Integer >, Iterable <Integer >> spanned = span (eq (1 ), asList (1 , 1 , 1 , 2 , 3 , 1 ));
34+ assertThat (spanned ._1 (), iterates (1 , 1 , 1 ));
35+ assertThat (spanned ._2 (), iterates (2 , 3 , 1 ));
36+ }
37+ }
0 commit comments