Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
loop + my test
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Garrett Rooney  
View profile  
 More options Mar 4 2005, 9:59 pm
Newsgroups: perl.perl6.compiler
From: roo...@electricjellyfish.net (Garrett Rooney)
Date: Fri, 04 Mar 2005 21:59:41 -0500
Local: Fri, Mar 4 2005 9:59 pm
Subject: [pugs] loop + my test

It seems that the loop statement currently doesn't let you declare
variables inside it, so the following code:

loop (my $i = 0; $i < 10; $i++) { }

doesn't work.  Here's a test for the problem.

-garrett

[ loop-my.diff < 1K ]
Index: t/base/loop.t
===================================================================
--- t/base/loop.t       (revision 567)
+++ t/base/loop.t       (working copy)
@@ -9,7 +9,7 @@

 =cut

-plan 6;
+plan 8;

 # basic loop

@@ -34,4 +34,10 @@
 my $i = 0;
 is($i, 0, 'verify our starting condition');
 loop (;;) { $i++; last(); }
-is($i, 1, 'verify our ending condition');
\ No newline at end of file
+is($i, 1, 'verify our ending condition');
+
+# declare variable inside loop
+my $count = 0;
+is($count, 0, 'verify our starting condition');
+eval 'loop (my $j = 0; $j < 10; $j++) { $count++; }';
+todo_is($count, 10, 'verify our ending condition');


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Luke Palmer  
View profile  
 More options Mar 4 2005, 10:04 pm
Newsgroups: perl.perl6.compiler
From: l...@luqui.org (Luke Palmer)
Date: Fri, 4 Mar 2005 20:04:50 -0700
Local: Fri, Mar 4 2005 10:04 pm
Subject: Re: [pugs] loop + my test

Garrett Rooney writes:
> It seems that the loop statement currently doesn't let you declare
> variables inside it, so the following code:

> loop (my $i = 0; $i < 10; $i++) { }

> doesn't work.  Here's a test for the problem.

Thanks, applied.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »