/[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

Contents of /t/10-orao.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 153 - (show annotations)
Sun Aug 5 16:06:29 2007 UTC (11 years, 11 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 #!/usr/bin/perl
2
3 use warnings;
4 use strict;
5
6 use blib;
7 use lib './lib';
8
9 use Test::More tests => 27;
10 use Test::Exception;
11 use Data::Dump qw/dump/;
12
13 BEGIN {
14 use_ok( 'Orao' );
15 }
16
17 ok( my $orao = Orao->new(), 'new' );
18
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 *Orao::loop = sub {
29 my $self = shift;
30 isa_ok( $self->app, 'SDL::App' );
31 isa_ok( $self->event, 'SDL::Event' );
32 };
33
34 ok( $orao->run, 'run' );
35
36 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 dies_ok { $orao->poke_code( 0xf000, 1 ) } 'access to ro memory';
61
62 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