[perl #58744] Hashes flatten lists

2008-09-10 Thread via RT
# New Ticket Created by  Moritz Lenz 
# Please include the string:  [perl #58744]
# in the subject line of all future correspondence about this issue. 
# URL: http://rt.perl.org/rt3/Ticket/Display.html?id=58744 


Rakudo r30946:

08:35  masak rakudo: .perl.say for {a = [b, c]}.kv # I have a fun
bug
   for you, too! :)
08:35  polyglotbot OUTPUT[a␤b c␤]

that should have been [b, c] on the second line

08:38 @moritz rakudo: my %a = (a = [[3], [4,5]]); say %aa.perl
08:38  polyglotbot OUTPUT[[3, 4, 5]␤]

the should have been [[3], [4,5]]

It seems they are even stored flat:

08:56 @moritz rakudo: my %a = (a = [[3], [4,5]]); say %a.perl
08:56  polyglotbot OUTPUT[{a = [3, 4, 5]}␤]

This is the bug that makes t/spec/S29-num/rounders.t so ugly (take a
look at the fudge lines to see what I mean)

Moritz

-- 
Moritz Lenz
http://moritz.faui2k3.org/ |  http://perl-6.de/


Re: [perl #58744] Hashes flatten lists

2008-09-10 Thread Moritz Lenz
Moritz Lenz (via RT) wrote:
 # New Ticket Created by  Moritz Lenz 
 # Please include the string:  [perl #58744]
 # in the subject line of all future correspondence about this issue. 
 # URL: http://rt.perl.org/rt3/Ticket/Display.html?id=58744 
 
 
 Rakudo r30946:
 
 08:35  masak rakudo: .perl.say for {a = [b, c]}.kv # I have a fun
 bug
for you, too! :)
 08:35  polyglotbot OUTPUT[a␤b c␤]
 
 that should have been [b, c] on the second line
 
 08:38 @moritz rakudo: my %a = (a = [[3], [4,5]]); say %aa.perl
 08:38  polyglotbot OUTPUT[[3, 4, 5]␤]
 
 the should have been [[3], [4,5]]
 
 It seems they are even stored flat:
 
 08:56 @moritz rakudo: my %a = (a = [[3], [4,5]]); say %a.perl
 08:56  polyglotbot OUTPUT[{a = [3, 4, 5]}␤]

Some more insight, found out by bacek and Tene on #parrot:

$ ./perl6 -e '(a = [[1], [2]]).perl.say'
(a = [[1], [2]])
$ ./perl6 -e 'my %a = (a = [[1], [2]]); %a.perl.say'
{a = [1, 2]}
$ ./perl6 -e 'my $a = (a = [[1], [2]]); $a.perl.say'
(a = [[1], [2]])

So it seems that the flattening happens when assigning the hash to a %h
container, but not when assigning to a $a scalar container.

Moritz

-- 
Moritz Lenz
http://moritz.faui2k3.org/ |  http://perl-6.de/


Re: [perl #58744] Hashes flatten lists

2008-09-10 Thread Patrick R. Michaud
On Wed, Sep 10, 2008 at 12:22:01PM +0200, Moritz Lenz wrote:
 Moritz Lenz (via RT) wrote:
  08:35  masak rakudo: .perl.say for {a = [b, c]}.kv # I have a fun
  bug
 for you, too! :)
  08:35  polyglotbot OUTPUT[a␤b c␤]
  
  that should have been [b, c] on the second line

Now fixed in r30967.  The problem is that the .kv method was 
always stringifying the values of the output list.  To illustrate:

$ ../../parrot perl6.pbc
 my %a = ('a' = 3 );  say %a.perl;   say %a.kv.perl;
{a = 3}
[a, 3]

Note how the hash correctly has an Int 3 but the list produced
by .kv had a Str 3.

  08:38 @moritz rakudo: my %a = (a = [[3], [4,5]]); say %aa.perl
  08:38  polyglotbot OUTPUT[[3, 4, 5]␤]
  the should have been [[3], [4,5]]

This looks to me like the generic problem that Rakudo is having
with nested arrays in general, and not specific to hashes.  So I'll
close this ticket for the .kv problem and we can open another one 
that deals with Rakudo incorrectly constructing arrays (not having
anything to do with hashes).

Thanks!

Pm


[perl #58560] [BUG] !flatten does not handle references

2008-09-10 Thread Patrick R. Michaud via RT
On Wed Sep 03 21:07:57 2008, s1n wrote:
 The List !flatten method does not properly recurse into references.
 List.pir:188 retrieves the elements opcode and does not check the pmc type
 for recursion.
 
 This functionality is needed for .elems and :prefix+ to function
properly
 for cases such as those in t/spec/S02-builtin_data_types/array_ref.t
(array
 reference slices).

Could you provide some example code, or point to specific tests in
array_ref.t that you're referring to?  That makes it much easier to
isolate the bug.

Pm



Re: [perl #57530] Fwd: Parallelize the Perl 6 tests

2008-09-10 Thread Moritz Lenz
Ron Schmidt via RT wrote:
 It'd be nice if we used the same env var for this as we did for the
 main harness. (that one is currently TEST_JOBS, iirc.)
 
 Per request from moritz I have come up with an updated patch that seems
 to apply cleanly and tested it on Ubuntu and cygwin/Windows Vista.  It
 gives the expected output for make test and make spectest in both
 cases and gives a nice performance boost under Ubuntu.  

Thank you very much. On Debian with two cores I get
2 jobs: 4m04
1 job:  2m35

Which is good enough for me ;-)

 Under
 cygwin/Windows Vista however the performance seems a bit slower and I
 wonder if we shouldn't really check for the OS or use 'jobs:1' in
 languages/perl6/t/harness rather than 'jobs:3'.

Is there a good reason to test in parallel at all if TEST_JOBS isn't set
as an environment? That's how perl and parrot core tests do it, and I
think it's quite a good practice. People who test often will just define
that environment variable globally.

 Per the suggestion above the controlling environment variable in the
 patch is TEST_JOBS.

++ for that, and ++ for the patch.

Now we need some feedback from MacOS X and windows/msvc users, then I'll
apply the patch.

Cheers,
Moritz

-- 
Moritz Lenz
http://moritz.faui2k3.org/ |  http://perl-6.de/


Re: [perl #57530] Fwd: Parallelize the Perl 6 tests

2008-09-10 Thread Moritz Lenz
Moritz Lenz wrote:
 Thank you very much. On Debian with two cores I get
 2 jobs: 4m04
 1 job:  2m35

Well, actually it's the other way round ;-)

-- 
Moritz Lenz
http://moritz.faui2k3.org/ |  http://perl-6.de/


Re: [perl #57530] Fwd: Parallelize the Perl 6 tests

2008-09-10 Thread Moritz Lenz
Ron Schmidt via RT wrote:
 It'd be nice if we used the same env var for this as we did for the
 main harness. (that one is currently TEST_JOBS, iirc.)
 
 Per request from moritz I have come up with an updated patch that seems
 to apply cleanly and tested it on Ubuntu and cygwin/Windows Vista.  It
 gives the expected output for make test and make spectest in both
 cases and gives a nice performance boost under Ubuntu.  Under
 cygwin/Windows Vista however the performance seems a bit slower and I
 wonder if we shouldn't really check for the OS or use 'jobs:1' in
 languages/perl6/t/harness rather than 'jobs:3'.
 
 Per the suggestion above the controlling environment variable in the
 patch is TEST_JOBS.

Attached is a slightly improved patch:
1) doesn't have trailing spaces in t/harness
2) 'make localtest_loud' works as before
(with the old patch you wouldn't see the verbose output, which is
crucial when you try to fudge tests for rakudo)
3) 'make t/spec/$path_to_file.t' is now verbose by default (which also
makes sense because you usually don't want to run many of those from the
command line)

Moritz

-- 
Moritz Lenz
http://moritz.faui2k3.org/ |  http://perl-6.de/
Index: lib/Parrot/Test/Harness.pm
===
--- lib/Parrot/Test/Harness.pm	(revision 30954)
+++ lib/Parrot/Test/Harness.pm	(working copy)
@@ -166,12 +166,13 @@
 exit unless my @files = get_files(%options);
 
 if (eval { require TAP::Harness; 1 }) {
-my %opts =
+my %harness_options =
   $options{exec} ? ( exec = $options{exec} )
 : $options{compiler} ? ( exec = [ '../../parrot', './' . $options{compiler} ] )
 :  ();
-$opts{verbosity} = $options{verbosity} ? $options{verbosity} : 0;
-TAP::Harness-new( \%opts )-runtests( @files );
+$harness_options{verbosity} = $options{verbosity} ? $options{verbosity} : 0;
+$harness_options{jobs} = $ENV{TEST_JOBS} || $options{jobs} || 1;
+TAP::Harness-new( \%harness_options )-runtests( @files );
 
 return;
 }
Index: languages/perl6/t/harness
===
--- languages/perl6/t/harness	(revision 30969)
+++ languages/perl6/t/harness	(working copy)
@@ -24,6 +24,9 @@
 'tests-from-file=s' = \my $list_file,
 'fudge' = \my $do_fudge,
 'verbosity=i'   = \$harness_args{verbosity},
+# A sensible default is num_cores + 1.
+# Many people have two cores these days.
+'jobs:3'= \$harness_args{jobs},
 );
 
 
Index: languages/perl6/config/makefiles/root.in
===
--- languages/perl6/config/makefiles/root.in	(revision 30969)
+++ languages/perl6/config/makefiles/root.in	(working copy)
@@ -197,21 +197,22 @@
 # NOTE: eventually, we should remove --keep-exit-code and --fudge
 #   as the goal is that all tests must pass without fudge
 HARNESS_WITH_FUDGE = $(PERL) t/harness --fudge --keep-exit-code
+HARNESS_WITH_FUDGE_JOBS = $(HARNESS_WITH_FUDGE) --jobs
 
 spectest: all t/spec
 	-cd t/spec  svn up
-	$(HARNESS_WITH_FUDGE) t/spec
+	$(HARNESS_WITH_FUDGE_JOBS) t/spec
 
 # Run the spectests that we know work.
 spectest_regression: all t/spec t/spectest_regression.data
 	-cd t/spec  svn up
-	$(HARNESS_WITH_FUDGE) --tests-from-file=t/spectest_regression.data
+	$(HARNESS_WITH_FUDGE_JOBS) --tests-from-file=t/spectest_regression.data
 
 fulltest: coretest spectest_regression codetest
 
 # Run the tests in t/localtest.data
 localtest: all t/spec t/localtest.data
-	@$(HARNESS_WITH_FUDGE) --tests-from-file=t/localtest.data
+	@$(HARNESS_WITH_FUDGE_JOBS) --tests-from-file=t/localtest.data
 
 # Run the tests in t/localtest.data with a higher verbosity
 localtest_loud: all t/spec t/localtest.data
@@ -220,11 +221,11 @@
 # Run many tests of your choise.
 # make somtests TESTFILES=t/foo/bar
 sometests: all
-	@$(HARNESS_WITH_FUDGE) $(TESTFILES)
+	@$(HARNESS_WITH_FUDGE_JOBS) $(TESTFILES)
 
 # Run a single test
 t/*.t t/*/*.t t/*/*/*.t: all
-	@$(HARNESS_WITH_FUDGE) $@
+	@$(HARNESS_WITH_FUDGE) --verbosity=1 $@
 
 t/localtest.data:
 	$(PERL) -MExtUtils::Command -e test_f $@