Unit Tests


If you are interested in helping with tiles, vaults, patches or documentation, this is the place for that.

Dungeon Dilettante

Posts: 4

Joined: Saturday, 19th October 2013, 15:59

Post Sunday, 6th April 2014, 13:45

Unit Tests

Good day, I have been browsing through DCSS source code looking for unit tests and all I found was the test folder and the lua scripts inside. Would anyone be so kind as to enlighten me about the way they work? I could not find any specific unit test regarding the functions used in the source files, do they exist? if yes where are they stored? if they do not, would a contribution using unit tests from a framework such as CPPuTest be accepted?
User avatar

Dungeon Master

Posts: 762

Joined: Thursday, 25th April 2013, 02:43

Post Monday, 7th April 2014, 01:35

Re: Unit Tests

No, there aren't any Unit Tests. Yes, this is terrible. I'm sure a proper set up of Unit Tests would be enthusiastically accepted by the developers. Current refactorings work on "edit and pray" principle. Note we have not move to C++11 yet, if that is a problem. There's trouble supporting builds on old mac (ex. Power PCs) if we go that route.

If you're wondering how we got this way, here is a quote of Henzell, the original creator of Crawl:
You see, I gave up on Borland's [C++] manual (which is very good, I'm just lazy)
when it started talking about pointers, because I just didn't (and still don't
really) understand what they're supposed to be so useful for. After pointers
came structs, enums, pragmas, classes, macros, and a whole lot of other stuff
which still means nothing to me. It also took me several months to realise
that putting every single function into one huge module was not going to work
if I wanted my game to have more that 64K of code, and even then I did weird
things like putting heaps of code into .h files and including them
directly... you can still see the legacy of this in the code. I even had the
dungeon generator in a separate file which was spawned, created the level,
saved it to disk, then passed control back to the main program which then read
the level from disk again. new_game still works on a similar principle.

origin of the quote

The source is a bit better now (enums are used where they make sense, for example) but there are still very few classes in the system, and the few classes which do exist tend to be bloated monsters. Also most of the important function have between 6-9 arguments. etc.
On IRC my nick is reaverb. I play online under the name reaver, though.

For this message the author reaver has received thanks:
ForgottenBeast

Return to Contributions

Who is online

Users browsing this forum: No registered users and 6 guests

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.