/[VRac]/t/10-orao.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

Annotation of /t/10-orao.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 153 - (hide annotations)
Sun Aug 5 16:06:29 2007 UTC (16 years, 8 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1525 byte(s)
test append_to_file which, amazingly, work from test but not from emulator
1 dpavlin 82 #!/usr/bin/perl
2    
3     use warnings;
4     use strict;
5    
6     use blib;
7     use lib './lib';
8    
9 dpavlin 153 use Test::More tests => 27;
10 dpavlin 82 use Test::Exception;
11     use Data::Dump qw/dump/;
12    
13     BEGIN {
14     use_ok( 'Orao' );
15     }
16    
17 dpavlin 90 ok( my $orao = Orao->new(), 'new' );
18 dpavlin 82
19     isa_ok( $orao, 'Orao' );
20    
21     ok( $orao->scale( 1 ), 'scale' );
22     ok( ! $orao->show_mem( 0 ), 'show_mem' );
23     ok( ! $orao->debug( 0 ), 'debug' );
24     ok( ! $orao->trace( 0 ), 'trace' );
25    
26     is_deeply( $orao->prefs, { scale => 1, show_mem => 0, debug => 0, trace => 0 }, 'prefs' );
27    
28 dpavlin 132 *Orao::loop = sub {
29     my $self = shift;
30     isa_ok( $self->app, 'SDL::App' );
31     isa_ok( $self->event, 'SDL::Event' );
32     };
33 dpavlin 82
34 dpavlin 132 ok( $orao->run, 'run' );
35    
36 dpavlin 82 sub test_mem {
37     my $a = shift;
38     my @v = ( 0xff, 0x00, 0xff, 0xaa );
39    
40     my $l = $#v + 1;
41    
42     $orao->poke_code( $a, @v );
43    
44     diag sprintf(" %04x - %04x : ", $a, $a + $#v ), dump( @v );
45     diag "ram = ",dump( $orao->ram( $a, $a + $#v ) );
46     diag $orao->hexdump( $a, $a + $#v );
47    
48     is_deeply( [ $orao->ram( $a, $a + $#v ) ], [ @v ], 'ram' );
49     is_deeply( [ $orao->ram( $a, $a + $#v ) ], [ @v ], 'ram doesn\'t mutate' );
50    
51     $orao->poke_code( $a + 4, 0x11, 0x22, 0x33, 0x44 );
52    
53     like( $orao->hexdump( $a, $a + 4 ), qr/ ff 00 ff aa 11 22 33 44/, 'hexdump' );
54    
55     }
56    
57     test_mem( 0x1000 );
58     test_mem( 0x6000 );
59     test_mem( 0x7000 );
60 dpavlin 90 dies_ok { $orao->poke_code( 0xf000, 1 ) } 'access to ro memory';
61 dpavlin 82
62 dpavlin 153 my $path = '/tmp/foo';
63     unlink $path if -e $path;
64    
65     my $size = 0;
66    
67     foreach my $data ( qw/a b c foo bar aaaabbbbccccddddeeeeffff/ ) {
68     VRac->append_to_file( $path, $data );
69     $size += length($data);
70     cmp_ok(-s $path, '==', $size);
71     }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26