Skip to content
This repository has been archived by the owner on Apr 3, 2018. It is now read-only.

Commit

Permalink
Fix recent regression with CharacterScanner_ReaderHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno-medeiros committed Oct 6, 2016
1 parent cffe82d commit 8826f46
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
Expand Up @@ -31,6 +31,11 @@ protected ICharacterReader createParseSource(String source) {
return new CharacterScanner_ReaderHelper(charScanner);
}

@Override
protected void test_consumeBeyondEnd() {
// Do nothing, not allowed with this class
}

@Override
protected void checkBufferedCount(ICharSource<?> parseSource, int expected) {
// Ignore
Expand Down
Expand Up @@ -34,7 +34,7 @@ protected void invariant() {

@Override
protected void consume_next_invariant(int next) {
// allow EOS
// allow consume at EOS
}

@Override
Expand Down
Expand Up @@ -69,17 +69,8 @@ protected void doTest______() throws Exception {
assertTrue(parseSource.lookaheadMatches("def"));
parseSource.consumeAmount(3);
assertTrue(parseSource.lookaheadMatches(""));
// Design aspect: allow consuming beyond end?
{
parseSource.consumeAmount(2);
assertTrue(parseSource.lookaheadIsEOS());
parseSource.consume();
assertTrue(parseSource.lookaheadIsEOS());
parseSource.unread();
parseSource.unread();
parseSource.unread();
assertTrue(parseSource.lookaheadIsEOS());
}

test_consumeBeyondEnd();
parseSource.unread();
assertTrue(parseSource.lookaheadMatches("f"));

Expand All @@ -101,6 +92,20 @@ protected void doTest______() throws Exception {
assertTrue(parseSource.lookaheadMatches("f"));
}

protected void test_consumeBeyondEnd() {
assertTrue(parseSource.lookaheadIsEOS());
assertTrue(parseSource.lookaheadMatches(""));

parseSource.consumeAmount(2);
assertTrue(parseSource.lookaheadIsEOS());
parseSource.consume();
assertTrue(parseSource.lookaheadIsEOS());
parseSource.unread();
parseSource.unread();
parseSource.unread();
assertTrue(parseSource.lookaheadIsEOS());
}

protected void testCharSource() throws Exception {

// Test lookahead
Expand Down

0 comments on commit 8826f46

Please sign in to comment.