Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 47 lines (33 sloc) 1.138 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
#! nqp

plan(18);

my $a;
$a := (8);
ok( pir::typeof__SP($a) eq 'Integer', 'basic parens');

$a := (8,9);
ok( pir::typeof__SP($a) eq 'ResizablePMCArray', 'paren list');
ok( +$a == 2, 'paren list elems' );

$a := (8,);
ok( pir::typeof__SP($a) eq 'ResizablePMCArray', 'paren comma');
ok( +$a == 1, 'paren comma' );

$a := ();
ok( pir::typeof__SP($a) eq 'ResizablePMCArray', 'empty parens');
ok( +$a == 0, 'paren list elems' );

$a := [8];
ok( pir::typeof__SP($a) eq 'ResizablePMCArray', 'brackets of one elem');
ok( +$a == 1, 'brackets of one elem' );

$a := [7,8,9];
ok( pir::typeof__SP($a) eq 'ResizablePMCArray', 'brackets of 3 elems');
ok( +$a == 3, 'brackets of 3 elems' );

$a := [];
ok( pir::typeof__SP($a) eq 'ResizablePMCArray', 'brackets of 0 elems');
ok( +$a == 0, 'brackets of 0 elems' );

$a := {};
ok( pir::typeof__SP($a) eq 'Hash', 'empty braces');

$a := { 1 };
ok( pir::typeof__SP($a) eq 'Sub', 'non-empty braces');

sub xyz(*@a) {
    ok( +@a == 1, "brackets as single argument #1" );
    ok( +@a[0] == 2, "brackets as single argument #2");
    ok( @a[0][1] == 'b', "brackets as single argument #3");
}

xyz(['a', 'b']);

Something went wrong with that request. Please try again.