DASM
test-assemble-fail/Tests.pm
Go to the documentation of this file.
00001 #!/usr/bin/perl -w
00002 ##
00003 # Test rules for the test-assemble directory: nagative tests.
00004 #
00005 # These routines provide regression tests to ensure that the assemble
00006 # routines generate the same results in repeated runs.
00007 # We process the files in this directories:
00008 #
00009 #    *.fail.output
00010 #        The file *.dasm is assembled and is expected to fail.
00011 #        The result output is compared to this file to check that the
00012 #        output does not change.
00013 #        If they do not match, the differences are printed and we terminate.
00014 #        This tests that the assembler is reporting errors as we expect.
00015 #
00016 
00017 
00018 ##
00019 # Assemble the .dasm file; comparing to the expectation.
00020 addTest('name' => 'Assemble and fail',
00021         'input'    => '\.dasm$',
00022         'expect'   => '.fail.output',
00023         'generate' => sub {
00024                 my ($directory, $input) = @_;
00025 
00026                 my $cmd = "./dasm.pl -i $directory/$input";
00027                 my ($rc, $output) = capture_output($cmd);
00028 
00029                 return ($rc, $output, $cmd);
00030             },
00031 
00032         'compare' => \&comparefail,
00033        );
00034 
00035 # Must return true
00036 1;