[antlr-interest] gUnit in ANTLR 3.3

Kunal Sawlani kunalsawlani at gmail.com
Thu Dec 2 11:59:19 PST 2010


Hi Terence,

I ran the following tests from for the SimpleC.gunit example mentioned in
the wiki.

===========================================================================================
gunit SimpleC;

//test rule:variable with 2 tests
variable:
"int x" FAIL     //expect failure, because of missing ';' in the input
string

"int x;" -> "x"  //expect standard output "x" from rule

//test rule:functionHeader with 1 test
functionHeader:
"void bar(int x)" returns ["int"]  //expect a return string "int" from rule

//test rule:program with 3 tests, input starts immediately after the initial
<< so the first test is a blank line
program:
<<
char c;
int x;
>> OK        //expect success (no error messages from ANTLR)


// test lexical rules
ID:
"abc123" OK    //expect success
"XYZ at 999" OK   //expect success
"123abc" FAIL  //expect failure

INT:
"00000" OK
"123456789" OK
===========================================================================================
*ANTLR 3.1.2*
Here is the output when I use the antlr-3.1.2.jar to run the unit tests.
These are consistent with the documentation in the Wiki

executing testsuite for grammar:SimpleC with 9 tests
-----------------------------------------------------------------------
3 failures found:
test2 (variable, line7) -
expected: x
actual: (VAR_DEF int x)

test3 (functionHeader, line11) -
expected: int
actual: (FUNC_HDR void bar (ARG_DEF int x))

test6 (ID, line24) -
expected: OK
actual: extra text found, '@999'


Tests run: 9, Failures: 3
===========================================================================================
*ANTLR 3.3*
And here is the output when I sue the antlr-3.3 jar to run the tests.

executing testsuite for grammar:SimpleC with 9 tests
-----------------------------------------------------------------------
4 failures found:
test2 (variable, line7) -
expected: x
actual: Invalid input

test3 (functionHeader, line11) -
expected: int
actual: Invalid input

test4 (program, line15) -
expected: OK
actual: FAIL

test6 (ID, line24) -
expected: OK
actual: extra text found, '@999'


Tests run: 9, Failures: 4
*
===========================================================================================
*
*
*
The problem seems to be occurring when testing for parser rules. The Lexer
unit tests behave the same in both.

Thanks,

*
*


On Thu, Dec 2, 2010 at 1:51 PM, Terence Parr <parrt at cs.usfca.edu> wrote:

> can you give us a sample? it should work fine
> Ter
> On Dec 2, 2010, at 9:17 AM, Kunal Sawlani wrote:
>
> > Hello,
> >
> > I was in the process of upgrading from ANTLR 3.1.2 to ANTLR 3.3, and the
> > target files get generated perfectly fine.
> >
> > However, the gUnit interpreter seems to be unable to parse the syntax of
> the
> > gUnit file and indicates all the tests as invalid inputs. I have been
> trying
> > to find some documentation to see if anything changed in gunit syntax
> from
> > ANTLR 3.1.2 to ANTLR 3.2( the tests fail with antlr3.2 as well) .
> >
> > Is this a known issue, or am I doing something wrong?
> >
> > --
> > Kunal
> >
> > List: http://www.antlr.org/mailman/listinfo/antlr-interest
> > Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>


-- 
Kunal


More information about the antlr-interest mailing list