-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' ); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' ); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |