1 // A test case for the LEMON parser generator. Run as follows:
3 // lemon lemon-test01.y && gcc -g lemon-test01.c && ./a.out
9 static int nSyntaxError
= 0;
10 static int nAccept
= 0;
11 static int nFailure
= 0;
28 #include "lemon-test01.h"
31 static int testCase
(int testId
, int shouldBe
, int actual
){
33 if
( shouldBe
==actual
){
34 printf
("test %d: ok\n", testId
);
36 printf
("test %d: got %d, expected %d\n", testId
, actual
, shouldBe
);
40 int main
(int argc
, char **argv
){
47 testCase
(100, 0, nSyntaxError
);
48 testCase
(110, 1, nAccept
);
49 testCase
(120, 0, nFailure
);
50 nSyntaxError
= nAccept
= nFailure
= 0;
56 testCase
(200, 1, nSyntaxError
);
57 testCase
(210, 1, nAccept
);
58 testCase
(220, 0, nFailure
);
59 nSyntaxError
= nAccept
= nFailure
= 0;
65 testCase
(200, 1, nSyntaxError
);
66 testCase
(210, 0, nAccept
);
67 testCase
(220, 0, nFailure
);
69 printf
("%d tests pass\n", nTest
);
71 printf
("%d errors out %d tests\n", nErr
, nTest
);