/[VRac]/M6502/t/05-M6502.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /M6502/t/05-M6502.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 199 by dpavlin, Sun Apr 13 11:40:01 2008 UTC revision 200 by dpavlin, Sun Apr 13 12:17:07 2008 UTC
# Line 6  use strict; Line 6  use strict;
6  use blib;  use blib;
7  use lib './lib';  use lib './lib';
8    
9  use Test::More tests => 168;  use Test::More tests => 280;
10  use Test::Exception;  use Test::Exception;
11  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
12    
# Line 72  my @flip_tests = ( Line 72  my @flip_tests = (
72          { fill => 0b11110011, expect => 0b11001111, callbacks => 0x00 },          { fill => 0b11110011, expect => 0b11001111, callbacks => 0x00 },
73  );  );
74    
75    sub dump_callbacks {
76            my $out = 'callbacks:';
77            $out .= sprintf(" %02x", M6502::get_callback( $_ )) foreach ( 0x6000 .. 0x6020 );
78            diag $out;
79    }
80    
81  foreach my $test ( @flip_tests ) {  foreach my $test ( @flip_tests ) {
82    
83          diag "test ",dump( $test );          diag "test ",dump( $test );
84    
85            dump_callbacks;
86    
87          ok( M6502::reset(), 'reset again' );          ok( M6502::reset(), 'reset again' );
88          is( M6502::set_all_callbacks( $test->{callbacks} ), $test->{callbacks}, 'set_all_callbacks' );          is( M6502::set_all_callbacks( $test->{callbacks} ), $test->{callbacks}, 'set_all_callbacks' );
89            
90            dump_callbacks;
91    
92            # manually hook callbacks
93            if ( $test->{callbacks} == 0 ) {
94                    M6502::set_write_callback( $_ ) foreach ( 0x6000 .. 0x6010 );
95            }
96    
97            dump_callbacks;
98    
99          # flip bytes 6502 asm          # flip bytes 6502 asm
100          my $a = 0x1000;          my $a = 0x1000;
# Line 108  foreach my $test ( @flip_tests ) { Line 125  foreach my $test ( @flip_tests ) {
125                  cmp_ok( $mem[$a], '==', $test->{expect}, sprintf('flipped %04x %08b -> %08b',$a, $test->{fill}, $mem[$a]) );                  cmp_ok( $mem[$a], '==', $test->{expect}, sprintf('flipped %04x %08b -> %08b',$a, $test->{fill}, $mem[$a]) );
126                  cmp_ok( M6502::get_callback( $a ), '==', $test->{callbacks}, 'callback' );                  cmp_ok( M6502::get_callback( $a ), '==', $test->{callbacks}, 'callback' );
127          }          }
128    
129            dump_callbacks;
130    
131            $PC = 0x1000;
132            ok( M6502::exec( 1001 ), 'M6502::exec again' );
133            cmp_ok( $PC, '==', 0x1016, 'PC moved' );
134    
135            foreach my $a ( 0x6000 .. 0x600c ) {
136                    cmp_ok( $mem[$a], '==', $test->{fill}, sprintf('flipped %04x %08b -> %08b',$a, $test->{fill}, $mem[$a]) );
137                    cmp_ok( M6502::get_callback( $a ), '==', $test->{callbacks}, 'callback' );
138            }
139    
140            dump_callbacks;
141  }  }

Legend:
Removed from v.199  
changed lines
  Added in v.200

  ViewVC Help
Powered by ViewVC 1.1.26