Skip to content

Commit

Permalink
3 more passing test files.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Jan 28, 2013
1 parent 9108672 commit 67fa8fd
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
53 changes: 53 additions & 0 deletions t/nqp/13-op.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!./parrot nqp.pbc

# checking basic operands and circumfix:( )

plan(32);

##Additive operators
ok( 1+2 == 3, 'Checking addition 1+2');
ok( 10-9 == 1, 'Checking subtraction 10-9');
ok( 10-3+2 == 9, 'Checking compound statements 10-3+2');
ok( 10-(3+2) == 5, 'Checking parenthesized statement 10-(3+2)');

##Multiplicative operators
ok( 6*7 == 42, 'Checking multiplication 6*7');
ok( 36/6 == 6, 'Checking division 36/6');
ok( 4*3+5 == 17, 'Checking compound statements 4*3+5');
ok( 4*(3+5) == 32, 'Checking parenthesized statements 4*(3+5)');
ok( 12/4*3 == 9, 'Checking compound statements 12/4*3');
ok( 12/(4*3) == 1, 'Checking compound statements 12/(4*3)');
ok( 5-3*2 == -1, 'Checking compound statements 5-3*2');

##Modulo operator
ok( 8%3 == 2, 'Checking modulo 8%3');
ok( 8%3+2 == 4, 'Checking compound statement 8%3+2');
ok( 8%(3+2) == 3, 'Checking compound statement 8%(3+2)');

##Concatenation operator
ok( 'a' ~ 'b' eq 'ab', 'Checking concatenation "a" ~ "b"');
ok( 1 ~ 'b' eq '1b', 'Checking concatenation 1 ~ "b"');
ok( 'a' ~ 2 eq 'a2', 'Checking concatenation "a" ~ 2 ');

##Postfix operators
my $x := 0;
ok( $x++ == 0 );
ok( $x == 1 );
ok( $x-- == 1 );
ok( $x == 0 );

##Relational operators
ok( ?(1 < 2) );
ok( !(2 < 1) );
ok( ?(2 <= 2) );
ok( !(3 <= 2) );
ok( ?(2 > 1) );
ok( !(2 > 3) );
ok( ?(2 >= 1) );
ok( !(2 >= 3) );

#Bitwise operators
ok( (1 +| 3) == 3, 'Checking 1 +| 3' );
ok( (3 +& 2) == 2, 'Checking 3 +& 2' );
ok( (3 +^ 3) == 0, 'Checking 3 +^ 3' );

23 changes: 23 additions & 0 deletions t/nqp/16-ternary.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!./parrot nqp.pbc

# the ternary ?? !! operator

plan(8);

ok( 1 ?? 1 !! 0 );
ok( 0 ?? 0 !! 1 );

my $a := 1 ?? 'yes' !! 'no';
ok( $a eq 'yes' );

my $b := 0 ?? 'yes' !! 'no';
ok( $b eq 'no' );

my $c := 1 ?? 'yes' !! ( $a := 'no' );
ok( $c eq 'yes' );
ok( $a eq 'yes' );

my $d := 0 ?? ( $a := 'no' ) !! 'yes';
ok( $d eq 'yes' );
ok( $a eq 'yes' );

20 changes: 20 additions & 0 deletions t/nqp/39-pointy.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#! nqp

plan(7);

my $count := 1;

my $x := -> $a, $b { ok($a == $count++, $b); }

$x(1, 'basic pointy block');

my $y := -> $a, $b = 2 { ok($b == $count++, $a); }

$y('pointy block with optional');

$y('pointy block with optional + arg', 3);

for <4 pointy4 5 pointy5 6 pointy6> -> $a, $b { ok($a == $count++, $b); }

my $argless := -> { ok(1, 'argumentless pointy parses ok') }
$argless();

0 comments on commit 67fa8fd

Please sign in to comment.