Pattern { public final Pattern atMost(int max) { return new UpperBoundedPattern(Checks.checkMax(max), this); }  abstract int match(CharSequence src, int begin, int end); final Pattern next(Pattern next); final Pattern optional(); final Pattern many(); @Deprecated final Pattern many(int min); final Pattern atLeast(int min); final Pattern many1(); @Deprecated final Pattern some(int max); final Pattern atMost(int max); @Deprecated final Pattern some(int min, int max); final Pattern times(int min, int max); final Pattern not(); final Pattern peek(); final Pattern ifelse(Pattern consequence, Pattern alternative); @Deprecated final Pattern repeat(int n); final Pattern times(int n); final Pattern or(Pattern p2); @SuppressWarnings("deprecation") final Parser<Void> toScanner(String name); static final int MISMATCH; }
@Test public void testSome_throwsForNegativeMax() { try { Patterns.ALWAYS.atMost(-1); fail(); } catch (IllegalArgumentException e) { assertEquals("max < 0", e.getMessage()); } }