I am currently implementing my own programming language. Until now I have written:
Errorclass for errors (to be thrown) encountered while processing the input source code;
SyntaxErrorfunctions (each one with a different tag, passed with a template, like
SyntaxError<unexpected_symbol>) which help constructing
Errorobjects with different error messages (for now I only got this, but I will soon have
IndexErrors and so on);
Tokenclass which contains the informations about each token (line in the string at which it was when it was encountered, the type which can be
number... things like that);
lexerfunction which takes as imput a string of source code and returns a
std::list<Token*>object. Internally, it uses a few helper functions (
skipcomment...) to help mantain the code organized.
I didn't follow any particular programming technique will coding this, but I now feel the urge to follow those that go under the Test Developement Programming name.
But I have a few concerns:
First, what do I have to test in the above code? Of course the
lexerfunction should be tested deeply, and maybe also the helper functions it uses (I guess), but what about the other things?
Second, how do I test functions with a non-trivial output? Online I see a lot of examples comparing simple numbers or strings, but how does one write a test for a function which returns a list of pointers to objects whitout having to write too much for a single test case?