3 posts tagged “testing”
celtic@sohma:~/code/linux/rubyex/translator$ make
g++ -enable-rtti -I. -c -o out/tests.o tests.cpp
g++ -o ruby out/ruby.tab.o out/lex.yy.o out/expr.o out/global.o out/main.o out/pretty.o out/tests.o
8 test(s) run, 8 test(s) succeeded.
234 assertion(s), 234 assertion(s) succeeded.
celtic@sohma:~/code/linux/rubyex/translator$
There's almost full test coverage for what's parseable so far. Blocks are also included.
celtic@sohma:~/code/linux/rubyex/translator$ ./test
test: "identifier": failure: Assertion failed on line 53: p.expressions.size() == 0
1 test(s) run, 0 test(s) succeeded.
celtic@sohma:~/code/linux/rubyex/translator$
これでテストコードがある:
And here we have the test code:
void _identifier()
{
Program p = parse_code("abc");
ASSERT(p.expressions.size() == 0);
}
The next question, of course, is of the best way to test parsers written in bison. I could just put all the parsing code in a separate library and have it compile two programs instead of the one big thing (i.e. one the parser, one the testing parser which just asserts all the output). I have no idea about test frameworks for C or C++, so I'll have a look now, I think.
