Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 75 lines (52 sloc) 1.287 kB
1407f9d [t/statemets] deleted until.t, since the same version was already in …
dr_df0 authored
1 use v6;
2
3 use Test;
4
5 # Test primarily aimed at PIL2JS
6
7 plan 8;
8
9 # sanity tests
10 {
11 my $res='';
12
13 for <a b c> { $res ~= $_ }
14 is $res, "abc", "for works with an <...> array literal";
15 }
16
17 {
18 my $res='';
19
20 for (<a b c>) { $res ~= $_ }
21 is $res, "abc", "for works with an (<...>) array literal";
22 }
23
24 # for with only one item, a constant
25 {
26 my $res='';
27
28 for ("a",) { $res ~= $_ }
29 is $res, "a", "for works with an (a_single_constant,) array literal";
30 }
31
32 {
33 my $res='';
34
35 for ("a") { $res ~= $_ }
36 is $res, "a", "for works with (a_single_constant)";
37 }
38
39 {
40 my $res='';
41
42 for "a" { $res ~= $_ }
43 is $res, "a", "for works with \"a_single_constant\"";
44 }
45
46 # for with only one item, an arrayref
47 # See thread "for $arrayref {...}" on p6l started by Ingo Blechschmidt,
48 # L<"http://www.nntp.perl.org/group/perl.perl6.language/22970">
49 {
50 my $arrayref = [1,2,3];
51
52 my $count=0;
53 for ($arrayref,) { $count++ }
54
55 is $count, 1, 'for ($arrayref,) {...} executes the loop body only once';
56 }
57
58 {
59 my $arrayref = [1,2,3];
60
61 my $count=0;
62 for ($arrayref) { $count++ }
63
64 is $count, 1, 'for ($arrayref) {...} executes the loop body only once';
65 }
66
67 {
68 my $arrayref = [1,2,3];
69
70 my $count=0;
71 for $arrayref { $count++ }
72
73 is $count, 1, 'for $arrayref {...} executes the loop body only once';
74 }
Something went wrong with that request. Please try again.