1 |
#!/usr/bin/perl |
2 |
|
3 |
use warnings; |
4 |
use strict; |
5 |
|
6 |
use lib './lib'; |
7 |
|
8 |
use Test::More tests => 19; |
9 |
use Test::Exception; |
10 |
use Data::Dump qw/dump/; |
11 |
|
12 |
BEGIN { |
13 |
use_ok( 'Arch' ); |
14 |
} |
15 |
|
16 |
ok( my $orao = Arch->new, 'new' ); |
17 |
|
18 |
isa_ok( $orao, 'Arch' ); |
19 |
|
20 |
ok( $orao->scale( 1 ), 'scale' ); |
21 |
ok( ! $orao->show_mem( 0 ), 'show_mem' ); |
22 |
ok( ! $orao->debug( 0 ), 'debug' ); |
23 |
ok( ! $orao->trace( 0 ), 'trace' ); |
24 |
|
25 |
is_deeply( $orao->prefs, { scale => 1, show_mem => 0, debug => 0, trace => 0 }, 'prefs' ); |
26 |
|
27 |
ok( $orao->init, 'init' ); |
28 |
|
29 |
sub test_mem { |
30 |
my $a = shift; |
31 |
my @v = ( 0xff, 0x00, 0xff, 0xaa ); |
32 |
|
33 |
my $l = $#v + 1; |
34 |
|
35 |
$orao->poke_code( $a, @v ); |
36 |
|
37 |
diag sprintf(" %04x - %04x : ", $a, $a + $#v ), dump( @v ); |
38 |
diag "ram = ",dump( $orao->ram( $a, $a + $#v ) ); |
39 |
diag $orao->hexdump( $a, $a + $#v ); |
40 |
|
41 |
is_deeply( [ $orao->ram( $a, $a + $#v ) ], [ @v ], 'ram' ); |
42 |
is_deeply( [ $orao->ram( $a, $a + $#v ) ], [ @v ], 'ram doesn\'t mutate' ); |
43 |
|
44 |
$orao->poke_code( $a + 4, 0x11, 0x22, 0x33, 0x44 ); |
45 |
|
46 |
like( $orao->hexdump( $a, $a + 4 ), qr/ ff 00 ff aa 11 22 33 44/, 'hexdump' ); |
47 |
|
48 |
} |
49 |
|
50 |
test_mem( 0x1000 ); |
51 |
test_mem( 0x6000 ); |
52 |
test_mem( 0x7000 ); |
53 |
dies_ok { test_mem( 0xf000 ) } 'access to ro memory'; |
54 |
|