Skip to content

Commit

Permalink
[Scheme]
Browse files Browse the repository at this point in the history
Start with implementation of 'display' and 'newline'.
Add some TODO tests.


git-svn-id: https://svn.parrot.org/parrot/trunk@22136 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
bschmalhofer committed Oct 16, 2007
1 parent d07f840 commit bdc2179
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 3 deletions.
20 changes: 20 additions & 0 deletions languages/scheme/lib/Scheme/Generator.pm
Expand Up @@ -1694,6 +1694,9 @@ sub _op_char_ready_p {
sub _op_write {
my ( $self, $node ) = @_;

$self->_add_comment( 'start of _op_write' );
# die Dumper( $self, $node );

my $temp = 'none';

for ( _get_args($node) ) {
Expand All @@ -1707,13 +1710,30 @@ sub _op_write {
}
}

$self->_add_comment( 'end of _op_write' );

return $temp; # We need to return something
}

sub _op_display {
my ( $self, $node ) = @_;

return _op_write( @_ );
}

sub _op_newline {
my ( $self, $node ) = @_;

_num_arg( $node, 0, 'newline' );

return $self->_generate(
{ children => [ { value => 'write' },
{ children => [ { value => q{"\n"} },
]
},
],
}
);
}

sub _op_write_char {
Expand Down
47 changes: 44 additions & 3 deletions languages/scheme/t/io/basic.t
Expand Up @@ -8,17 +8,58 @@ use warnings;
use FindBin;
use lib "$FindBin::Bin/../../lib";

use Test::More tests => 2;
use Test::More tests => 9;
use Parrot::Test;

language_output_is( 'Scheme', <<'CODE', '0', "basic write" );
language_output_is( 'Scheme', <<'CODE', '0', 'write, one integer' );
(write 0)
CODE

language_output_is( 'Scheme', <<'CODE', '01', "basic write" );
language_output_is( 'Scheme', <<'CODE', '01', 'write, two integers' );
(write 0 1)
CODE

TODO:
{
local $TODO = 'no support for strings yet';

language_output_is( 'Scheme', <<'CODE', 'asdf', 'write, one string' );
(write "asdf")
CODE

language_output_is( 'Scheme', <<'CODE', 'hello world', 'write, three strings' );
(write "hello", " ", "world")
CODE
}

language_output_is( 'Scheme', <<'CODE', '0', 'display, one integer' );
(display 0)
CODE

language_output_is( 'Scheme', <<'CODE', '01', 'display, two integers' );
(display 0 1)
CODE

TODO:
{
local $TODO = 'no support for strings yet';

language_output_is( 'Scheme', <<'CODE', 'asdf', 'display, one string' );
(display "asdf")
CODE

language_output_is( 'Scheme', <<'CODE', 'hello world', 'display, three strings' );
(display "hello", " ", "world")
CODE

language_output_is( 'Scheme', <<'CODE', "\n17\n", 'display, three strings' );
(newline)
(write 17)
(newline)
CODE
}


# Local Variables:
# mode: cperl
# cperl-indent-level: 4
Expand Down

0 comments on commit bdc2179

Please sign in to comment.