Skip to content
Browse files

[t/statemets] deleted until.t, since the same version was already in …

…t/spec/S04-statements

git-svn-id: http://svn.pugscode.org/pugs@22072 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
1 parent 10b3165 commit 1407f9daa378ed404e8b5a43867a53966d4f2c7d dr_df0 committed
Showing with 74 additions and 0 deletions.
  1. +74 −0 S04-statements/for_with_only_one_item.t
View
74 S04-statements/for_with_only_one_item.t
@@ -0,0 +1,74 @@
+use v6;
+
+use Test;
+
+# Test primarily aimed at PIL2JS
+
+plan 8;
+
+# sanity tests
+{
+ my $res='';
+
+ for <a b c> { $res ~= $_ }
+ is $res, "abc", "for works with an <...> array literal";
+}
+
+{
+ my $res='';
+
+ for (<a b c>) { $res ~= $_ }
+ is $res, "abc", "for works with an (<...>) array literal";
+}
+
+# for with only one item, a constant
+{
+ my $res='';
+
+ for ("a",) { $res ~= $_ }
+ is $res, "a", "for works with an (a_single_constant,) array literal";
+}
+
+{
+ my $res='';
+
+ for ("a") { $res ~= $_ }
+ is $res, "a", "for works with (a_single_constant)";
+}
+
+{
+ my $res='';
+
+ for "a" { $res ~= $_ }
+ is $res, "a", "for works with \"a_single_constant\"";
+}
+
+# for with only one item, an arrayref
+# See thread "for $arrayref {...}" on p6l started by Ingo Blechschmidt,
+# L<"http://www.nntp.perl.org/group/perl.perl6.language/22970">
+{
+ my $arrayref = [1,2,3];
+
+ my $count=0;
+ for ($arrayref,) { $count++ }
+
+ is $count, 1, 'for ($arrayref,) {...} executes the loop body only once';
+}
+
+{
+ my $arrayref = [1,2,3];
+
+ my $count=0;
+ for ($arrayref) { $count++ }
+
+ is $count, 1, 'for ($arrayref) {...} executes the loop body only once';
+}
+
+{
+ my $arrayref = [1,2,3];
+
+ my $count=0;
+ for $arrayref { $count++ }
+
+ is $count, 1, 'for $arrayref {...} executes the loop body only once';
+}

0 comments on commit 1407f9d

Please sign in to comment.
Something went wrong with that request. Please try again.