Skip to content

Commit c700f79

Browse files
committed
reenable testNulls()
1 parent 49f49c0 commit c700f79

3 files changed

Lines changed: 19 additions & 13 deletions

File tree

dot-parse/src/main/java/com/google/common/labs/parse/Parser.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -497,23 +497,23 @@ public static Parser<Integer> bmpCodeUnit() {
497497
/**
498498
* Sequentially matches {@code left} then {@code right}, and then combines the results using the
499499
* {@code combiner} function.
500-
*
501-
* @since 10.0
502500
*/
503501
public static <A, B, C> Parser<C> sequence(
504-
Parser<A> left, Production<B> right, BiFunction<? super A, ? super B, ? extends C> combiner) {
505-
return sequence(left, maybeZeroWidth(right), combiner);
502+
Parser<A> left, Parser<B> right, BiFunction<? super A, ? super B, ? extends C> combiner) {
503+
requireNonNull(right);
504+
requireNonNull(combiner);
505+
return left.flatMap(v1 -> right.map(v2 -> combiner.apply(v1, v2)));
506506
}
507507

508508
/**
509509
* Sequentially matches {@code left} then {@code right}, and then combines the results using the
510510
* {@code combiner} function.
511+
*
512+
* @since 10.0
511513
*/
512514
public static <A, B, C> Parser<C> sequence(
513-
Parser<A> left, Parser<B> right, BiFunction<? super A, ? super B, ? extends C> combiner) {
514-
requireNonNull(right);
515-
requireNonNull(combiner);
516-
return left.flatMap(v1 -> right.map(v2 -> combiner.apply(v1, v2)));
515+
Parser<A> left, Production<B> right, BiFunction<? super A, ? super B, ? extends C> combiner) {
516+
return sequence(left, maybeZeroWidth(right), combiner);
517517
}
518518

519519
/**

dot-parse/src/main/java/com/google/common/labs/parse/Production.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import java.util.function.BiFunction;
44
import java.util.function.Function;
55

6-
import com.google.common.labs.parse.Parser.OrEmpty;
76
import com.google.common.labs.parse.Parser.ParseException;
87
import com.google.mu.util.CharPredicate;
98

@@ -16,7 +15,7 @@
1615
*
1716
* @since 10.0
1817
*/
19-
public sealed interface Production<T> permits Parser, OrEmpty {
18+
public sealed interface Production<T> permits Parser, Parser.OrEmpty {
2019

2120
/**
2221
* Parses the entire input string and returns the result. Upon successful return, the {@code

dot-parse/src/test/java/com/google/common/labs/parse/ParserTest.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@
3636
import java.io.StringReader;
3737
import java.util.List;
3838
import java.util.Optional;
39+
import java.util.function.BiFunction;
3940
import java.util.function.UnaryOperator;
4041
import java.util.stream.Collector;
4142
import java.util.stream.Stream;
4243

43-
import org.junit.Ignore;
4444
import org.junit.Test;
4545
import org.junit.runner.RunWith;
4646
import org.junit.runners.JUnit4;
@@ -52,7 +52,10 @@
5252
import com.google.common.labs.parse.Parser.ParseException;
5353
import com.google.common.testing.NullPointerTester;
5454
import com.google.errorprone.annotations.CanIgnoreReturnValue;
55+
import com.google.mu.function.Function4;
56+
import com.google.mu.function.TriFunction;
5557
import com.google.mu.util.CharPredicate;
58+
import com.google.mu.util.stream.BiCollector;
5659

5760
@RunWith(JUnit4.class)
5861
public class ParserTest {
@@ -536,15 +539,19 @@ public void bmpCodeUnit_emoji() {
536539
}
537540

538541
@Test
539-
@Ignore("Production is a sealed interface, unsupported by NPT")
540542
public void testNulls() throws Exception {
541543
NullPointerTester tester =
542544
new NullPointerTester()
543545
.setDefault(Parser.class, string("a"))
544546
.setDefault(Parser.OrEmpty.class, string("a").orElse("default"))
545547
.setDefault(String.class, "test")
546548
.setDefault(char.class, '`');
547-
tester.testAllPublicStaticMethods(Parser.class);
549+
tester
550+
.ignore(Parser.class.getMethod("sequence", Parser.class, Production.class, BiFunction.class))
551+
.ignore(Parser.class.getMethod("sequence", Parser.class, Production.class, Production.class, TriFunction.class))
552+
.ignore(Parser.class.getMethod("sequence", Parser.class, Production.class, Production.class, Production.class, Function4.class))
553+
.ignore(Parser.class.getMethod("zeroOrMoreDelimited", Parser.class, Production.class, String.class, BiCollector.class))
554+
.testAllPublicStaticMethods(Parser.class);
548555
tester
549556
.ignore(Parser.class.getMethod("orElse", Object.class))
550557
.ignore(Parser.class.getMethod("thenReturn", Object.class))

0 commit comments

Comments
 (0)