1 package Parrot
::Test
::Tcl
;
3 # Copyright (C) 2004-2007, The Perl Foundation.
8 use vars
qw($language);
15 =head1 Parrot::Test::Tcl
17 Provide language specific testing routines here...
19 This is currently alarmingly similar to the generated subs in Parrot::Test.
20 Perhaps someone can do a better job of delegation here.
28 my %language_test_map = (
30 output_like
=> 'like',
31 output_isnt
=> 'isnt_eq'
34 foreach my $func ( keys %language_test_map ) {
36 *{"Parrot::Test::Tcl::$func"} = sub ($$;$) {
38 my ( $self, $code, $output, $desc ) = @_;
40 my $count = $self->{builder
}->current_test + 1;
42 $desc = $language unless $desc;
44 # Figure out how many levels we have to go back to get to parrot.
45 # And, conversely, how many levels we have to go down to get to
48 # There are basically 3 choices: run in one of:
53 my $path_to_parrot = $INC{'Parrot/Config.pm'};
54 $path_to_parrot =~ s
:/lib/Parrot
/Config
.pm
$::;
55 my $dir_count = scalar( File
::Spec
->splitdir($path_to_parrot) );
57 if ( $dir_count == 0 ) {
58 $path_to_tcl = File
::Spec
->join( 'languages', 'tcl' );
60 elsif ( $dir_count == 1 ) {
63 elsif ( $dir_count == 2 ) {
66 elsif ( $dir_count > 2 ) {
67 $path_to_tcl = File
::Spec
->join( File
::Spec
->updir() x
( $dir_count - 2 ) );
70 my $lang_f = Parrot
::Test
::per_test
( '.tcl', $count );
71 my $out_f = Parrot
::Test
::per_test
( '.out', $count );
73 my $args = $ENV{TEST_PROG_ARGS
} || '';
75 Parrot
::Test
::write_code_to_file
( $code, $lang_f );
82 File
::Spec
->join( $path_to_parrot, $self->{parrot
} )
84 . File
::Spec
->join( $path_to_tcl, 'tcl.pbc' );
85 if ( defined( $ENV{PARROT_TCLSH
} ) ) {
86 $executable = $ENV{PARROT_TCLSH
};
88 $cmd = "$executable $lang_f";
90 $exit_code = Parrot
::Test
::run_command
(
95 #CD => $self->{relpath},
99 my $file = Parrot
::Test
::slurp_file
($out_f);
100 my $builder_func = $language_test_map{$func};
107 ->$builder_func( Parrot
::Test
::slurp_file
($out_f), $output, $desc );
109 $self->{builder
}->diag("'$cmd' failed with exit code $exit_code")
110 if $exit_code and not $pass;
113 unless ( $ENV{POSTMORTEM
} ) {
125 # cperl-indent-level: 4
128 # vim: expandtab shiftwidth=4: