Skip to content

Commit

Permalink
[t] Convert another Timer PMC test from PASM to PIR
Browse files Browse the repository at this point in the history
  • Loading branch information
leto committed Jan 16, 2012
1 parent ceee527 commit 0a73c2c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 29 deletions.
29 changes: 1 addition & 28 deletions t/pmc/timer-old.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use strict;
use warnings;
use lib qw( . lib ../lib ../../lib );
use Test::More;
use Parrot::Test tests => 4;
use Parrot::Test tests => 3;
use Parrot::Config;

=head1 NAME
Expand Down Expand Up @@ -51,33 +51,6 @@ SKIP: {
returncc
CODE
/ok 2/
OUT

pasm_output_is( <<'CODE', <<'OUT', "Timer setup - initializer/start/stop" );
.include "timer.pasm"
new P1, ['FixedPMCArray']
set P1, 6
set P1[0], .PARROT_TIMER_NSEC
set P1[1], 0.5
set P1[2], .PARROT_TIMER_HANDLER
get_global P2, "_timer_sub"
set P1[3], P2
set P1[4], .PARROT_TIMER_RUNNING
set P1[5], 1
new P0, ['Timer'], P1
print "ok 1\n"
# stop the timer
set P0[.PARROT_TIMER_RUNNING], 0
sleep 1
print "ok 2\n"
end
.pcc_sub _timer_sub:
print "never\n"
returncc
CODE
ok 1
ok 2
OUT

my @todo = $ENV{TEST_PROG_ARGS} =~ /--runcore=jit/ ?
Expand Down
26 changes: 25 additions & 1 deletion t/pmc/timer.t
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ Tests the Timer PMC.
.sub main :main
.include 'test_more.pir'
.include "timer.pasm"
plan(5)
plan(7)
timer_setup()
timer_initialize()
timer_start_stop()
.end

.sub timer_setup
Expand Down Expand Up @@ -66,6 +67,29 @@ Tests the Timer PMC.
is($I4,1,'PARROT_TIMER_USEC')
.end

.sub timer_start_stop
$P1 = new ['FixedPMCArray'], 6
set $P1[0], .PARROT_TIMER_NSEC
set $P1[1], 0.5
set $P1[2], .PARROT_TIMER_HANDLER
get_global $P2, "_timer_sub"
set $P1[3], $P2
set $P1[4], .PARROT_TIMER_RUNNING
set $P1[5], 1

$P0 = new ['Timer'], $P1
ok(1,'created Timer PMC')

set $P0[.PARROT_TIMER_RUNNING], 0
sleep 1
ok(1,'slept after stopping timer')
.end

.sub _timer_sub
print "never\n"
returncc
.end

# Local Variables:
# mode: pir
# fill-column: 100
Expand Down

0 comments on commit 0a73c2c

Please sign in to comment.