mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-30 14:42:03 -08:00
The directory includes a Perl script to test the port (roulette-test.t) and a Perl script to generate the test based on output from the BASIC implementation (make-roulette-test.pl).
16 lines
1.1 KiB
Markdown
16 lines
1.1 KiB
Markdown
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
|
|
|
|
Conversion to [Perl](https://www.perl.org/)
|
|
|
|
This conversion consists of three files in `75_Roulette/perl/`:
|
|
|
|
- `roulette.pl` is the port of the BASIC to Perl;
|
|
- `roulette-test.t` is a Perl test for correctness of display and payout;
|
|
- `make-roulette-test.pl` generates roulette-test.t from roulette.bas.
|
|
|
|
The ported version of the game numbers the slots from 0 rather than 1, and uses a dispatch table to figure out the payout.
|
|
|
|
The Perl test loads `roulette.pl` and verifies the Perl slot display and payout logic against the BASIC for all combinations of slots and bets. If any tests fail that fact will be noted at the end of the output.
|
|
|
|
The test code is generated by reading the BASIC, retaining only the slot display and payout logic (based on line numbers), and wrapping this in code that generates all combinations of bet and spin result. The result is run, and the result is captured and parsed to produce `roulette-test.t`. `make-roulette-test.pl` has some command-line options that may be of interest. `--help` will display the documentation.
|