]> iEval git - app-scheme79asm.git/blob - t/App-Scheme79asm.t
Add compiler
[app-scheme79asm.git] / t / App-Scheme79asm.t
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4
5 use Test::More tests => 3;
6 BEGIN { use_ok('App::Scheme79asm') };
7
8 sub run_test {
9 my ($args, $input, $expected, $name) = @_;
10 my $actual = '';
11 open my $fh, '>', \$actual;
12 my $asm = App::Scheme79asm->new(%$args);
13 $asm->parse_and_print_verilog($input, $fh);
14 close $fh;
15 is $actual, $expected, $name
16 }
17
18 run_test {addr_bits => 5}, '(quoted (symbol 5))', <<'EOF', '(QUOTE 5)';
19 mem[0] <= 0; // (cdr part of NIL)
20 mem[1] <= 0; // (car part of NIL)
21 mem[2] <= 8'b00100000; // (cdr part of T)
22 mem[3] <= 8'b00100000; // (car part of T)
23 mem[4] <= 8'd8; // (free storage pointer)
24 mem[5] <= 8'b11100111; // QUOTED 7
25 mem[6] <= 0; // (result of computation)
26 mem[7] <= 8'b00100101; // SYMBOL 5
27 EOF
28
29 run_test {addr_bits => 13}, '(call (more (funcall 0) (proc (var -2))) (number 5))', <<'EOF', '((LAMBDA ID (X) X) 5)';
30 mem[ 0] <= 0; // (cdr part of NIL)
31 mem[ 1] <= 0; // (car part of NIL)
32 mem[ 2] <= 16'b0010000000000000; // (cdr part of T)
33 mem[ 3] <= 16'b0010000000000000; // (car part of T)
34 mem[ 4] <= 16'd12; // (free storage pointer)
35 mem[ 5] <= 16'b1100000000000111; // CALL 7
36 mem[ 6] <= 0; // (result of computation)
37 mem[ 7] <= 16'b0000000000001001; // MORE 9
38 mem[ 8] <= 16'b0010000000000101; // NUMBER 5
39 mem[ 9] <= 16'b1110000000000000; // FUNCALL 0
40 mem[10] <= 16'b1000000000001011; // PROC 11
41 mem[11] <= 16'b0101111111111110; // VAR -2
42 EOF
This page took 0.051835 seconds and 4 git commands to generate.