Help wanted: C/C++/C#/Java Test Code

Programming, for all ages and all languages.
Post Reply
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Help wanted: C/C++/C#/Java Test Code

Post by Solar »

Hi there,

I'm helping out on AStyle, a source code reformatter / pretty printer for C, C++, C#, and Java source code.

That project has, so far, no formal testing - if you change some part of it, you might actually miss the effect it has on how AStyle formats code.

Hence, I am looking for help. The job would be to write up code pieces that are as "complete" as possible: Using all keywords the language has (including ugly stuff like 'goto'), and all the syntactical "uglies" that might confuse a pretty printer: Templates, anonymous classes, classes within classes, line comments nested in block, you name it.

That code does not need to do something meaningful (since it's a pretty printer, not a compiler), but it should be syntactically correct (dito).

I could probably write up test cases myself (except for C# which I know next to nothing about), but usually it is better if someone other than the developer writes the test cases.

I hope that some of you guys here might have some really ugly code sitting somewhere in your closet that you might want to share for this purpose. Note that formatting isn't really important here, I'll "uglify" that myself - the point is that I don't know all the syntactical trickery of all the languages in question.

If you have some such code fragment for me, I'll happily accept your contribution at [email protected].
Every good solution is obvious once you've found it.
Schol-R-LEA

Re:Help wanted: C/C++/C#/Java Test Code

Post by Schol-R-LEA »

Aside from any code we can provide, I would recommend pillaging the IOCC archives (if that didn't already occur to you). The examples there are guaranteed to be both a) complete, operative programs (though some may be a bit dusty) and b) hideously ugly. If AStyle can handle that sort of nightmarish code, it should be ready for anything. Mind you, given the outrageous abuse of the formatting that typifies obfuscated C, some of the programs may make less sense when pretty-printed, but that's a risk you'll have to take.

However, I'll try to come up with some stuff for C++ and Java as well. I don't know C#, so I can't help there.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Help wanted: C/C++/C#/Java Test Code

Post by Solar »

The idea is to diff the output of astyle_old.exe against the output of astyle_new.exe to find out whether the latest changes to astyle make any sense.

Whether the source makes any sense is secondary. ;-)

The IOCC was indeed a good idea. Too bad there's no "obfuscated C++" contest, but - as one from the C++ standards committee once put it - "that would be like shooting dead fish in a barrel". ;-)
Every good solution is obvious once you've found it.
Post Reply