Skip to content
Newer
Older
100644 47 lines (33 sloc) 934 Bytes
2471f02 @pmichaud Add ability to create empty lists with (), lists with [...], and
pmichaud authored
1 #! nqp
2
5ea3604 @pmichaud Fix passing a single []-list as an argument.
pmichaud authored
3 plan(18);
2471f02 @pmichaud Add ability to create empty lists with (), lists with [...], and
pmichaud authored
4
5 my $a;
6 $a := (8);
2524810 @jnthn Update a test to not use pir:: ops.
jnthn authored
7 ok( !nqp::islist($a), 'basic parens');
2471f02 @pmichaud Add ability to create empty lists with (), lists with [...], and
pmichaud authored
8
9 $a := (8,9);
2524810 @jnthn Update a test to not use pir:: ops.
jnthn authored
10 ok( nqp::islist($a), 'paren list');
2471f02 @pmichaud Add ability to create empty lists with (), lists with [...], and
pmichaud authored
11 ok( +$a == 2, 'paren list elems' );
12
13 $a := (8,);
2524810 @jnthn Update a test to not use pir:: ops.
jnthn authored
14 ok( nqp::islist($a), 'paren comma');
2471f02 @pmichaud Add ability to create empty lists with (), lists with [...], and
pmichaud authored
15 ok( +$a == 1, 'paren comma' );
16
17 $a := ();
2524810 @jnthn Update a test to not use pir:: ops.
jnthn authored
18 ok( nqp::islist($a), 'empty parens');
2471f02 @pmichaud Add ability to create empty lists with (), lists with [...], and
pmichaud authored
19 ok( +$a == 0, 'paren list elems' );
20
21 $a := [8];
2524810 @jnthn Update a test to not use pir:: ops.
jnthn authored
22 ok( nqp::islist($a), 'brackets of one elem');
2471f02 @pmichaud Add ability to create empty lists with (), lists with [...], and
pmichaud authored
23 ok( +$a == 1, 'brackets of one elem' );
24
25 $a := [7,8,9];
2524810 @jnthn Update a test to not use pir:: ops.
jnthn authored
26 ok( nqp::islist($a), 'brackets of 3 elems');
2471f02 @pmichaud Add ability to create empty lists with (), lists with [...], and
pmichaud authored
27 ok( +$a == 3, 'brackets of 3 elems' );
28
29 $a := [];
2524810 @jnthn Update a test to not use pir:: ops.
jnthn authored
30 ok( nqp::islist($a), 'brackets of 0 elems');
2471f02 @pmichaud Add ability to create empty lists with (), lists with [...], and
pmichaud authored
31 ok( +$a == 0, 'brackets of 0 elems' );
32
33 $a := {};
2524810 @jnthn Update a test to not use pir:: ops.
jnthn authored
34 ok( nqp::ishash($a), 'empty braces');
2471f02 @pmichaud Add ability to create empty lists with (), lists with [...], and
pmichaud authored
35
36 $a := { 1 };
2524810 @jnthn Update a test to not use pir:: ops.
jnthn authored
37 ok( !nqp::ishash($a), 'non-empty braces');
2471f02 @pmichaud Add ability to create empty lists with (), lists with [...], and
pmichaud authored
38
5ea3604 @pmichaud Fix passing a single []-list as an argument.
pmichaud authored
39 sub xyz(*@a) {
40 ok( +@a == 1, "brackets as single argument #1" );
41 ok( +@a[0] == 2, "brackets as single argument #2");
42 ok( @a[0][1] == 'b', "brackets as single argument #3");
43 }
44
45 xyz(['a', 'b']);
46
Something went wrong with that request. Please try again.