5.4. Calculator test with expected results

So we should write the expected value next to the correct one:

Example 5-4. examples/intro/t02_calc.t

#!/usr/bin/perl
use strict;
use warnings;

system "./mycalc 1  + 1";
print " 2\n";
system "./mycalc 2 + 2";
print " 4\n";
system "./mycalc 2 + 2 + 2";
print " 6\n";

Output:

Example 5-5. examples/intro/t02_calc.out

2 2
4 4
4 6

Now it is better.


If you are interested in on-site trainings by the author, please contact me directly.

Online courses:

Would you like to get
updated when I publish
the next article?

Follow me:

Google Plus Twitter RSS feed