[antlr-interest] API docs out of date
Austin Hastings
Austin_Hastings at Yahoo.com
Wed Oct 17 04:44:13 PDT 2007
I'm trying to refactor some code in gunit, and I came across this issue:
Testcase: testEmptyString took 0.006 sec
FAILED
expected:<1> but was:<0>
junit.framework.AssertionFailedError: expected:<1> but was:<0>
at
org.antlr.gunit.StringTestInput_Test.testEmptyString(StringTestInput_Test.java:37)
The test case is:
@Test
public void testEmptyString()
{
StringTestInput sti = new StringTestInput("");
CharStream cs = sti.getStream();
assertEquals(1, cs.size()); // This value includes a single EOF.
int c = cs.LT(1);
assertEquals(CharStream.EOF, c);
}
The assertion about cs.size() == 1 is failing (that's line 37).
According to the CharStream API docs
(http://www.antlr.org/api/Java/interfaceorg_1_1antlr_1_1runtime_1_1_int_stream.html#619c01eda0b090b1ce1877bd60378990),
the size() function returns the size, and "This value includes a single
EOF."
I have interpreted that to mean that size() will return 1 for an empty
stream, signifying that there is an EOF pending. Yet it returns 0. This
is easy enough for me to fix, but I think it indicates that either the
API is broke, or the docs are broke.
=Austin
More information about the antlr-interest
mailing list