Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make basic Perl 6 tests pass #366

Closed
p6rt opened this issue Oct 20, 2008 · 18 comments
Closed

Make basic Perl 6 tests pass #366

p6rt opened this issue Oct 20, 2008 · 18 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Oct 20, 2008

Migrated from rt.perl.org#60016 (status was 'resolved')

Searchable as RT60016$

@p6rt
Copy link
Author

p6rt commented Oct 5, 2008

From @jkeenan

I don't often build Rakudo, so I'm not even sure whether this is the
correct place to report this bug. In any event, this was run on
Linux at r31685.

make && make test

t/00-parrot/06-op-inplace (Wstat​: 0 Tests​: 11 Failed​: 0)
  Parse errors​: Tests out of sequence. Found (1) but expected (8)
  Tests out of sequence. Found (7) but expected (10)

Thank you very much.
kid51

@p6rt
Copy link
Author

p6rt commented Oct 6, 2008

From @jkeenan

On Sun Oct 05 16​:53​:10 2008, jkeen@​verizon.net wrote​:

I don't often build Rakudo, so I'm not even sure whether this is the
correct place to report this bug. In any event, this was run on
Linux at r31685.

make && make test

FWIW, the error was reproduced when I typed​:

make perl6 && make test

@p6rt
Copy link
Author

p6rt commented Oct 6, 2008

@jkeenan - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Oct 6, 2008

From @jkeenan

Hope this additional diagnostic info helps​:

$ perl t/harness --verbosity=1 t/00-parrot/06-op-inplace.t
t/00-parrot/06-op-inplace....
1..11
ok 1
ok 2
ok 3
ok 4
ok 5
ok 6
ok 7
ok 1
ok 9
ok 7
ok 11
All 11 subtests passed

Test Summary Report


t/00-parrot/06-op-inplace (Wstat​: 0 Tests​: 11 Failed​: 0)
  Parse errors​: Tests out of sequence. Found (1) but expected (8)
  Tests out of sequence. Found (7) but expected (10)
Files=1, Tests=11, 2 wallclock secs ( 0.01 usr 0.00 sys + 1.05 cusr
0.04 csys = 1.10 CPU)
Result​: FAIL

@p6rt
Copy link
Author

p6rt commented Oct 19, 2008

From @jkeenan

Tonight I got this​:

t/00-parrot/06-op-inplace.......... All 11 subtests passed

... but then I subsequently got this​:

Test Summary Report


t/00-parrot/06-op-inplace (Wstat​: 0 Tests​: 11 Failed​: 0)
  Parse errors​: Tests out of sequence. Found (3) but expected (9)
  Tests out of sequence. Found (8) but expected (10)
  Tests out of sequence. Found (12) but expected (11)

I've never seen a test report like this, i.e., one which reports when
tests were run out of sequence. Granted, having tests run out of
sequence doesn't sound good. But what exactly is the problem here?

kid51

@p6rt
Copy link
Author

p6rt commented Oct 20, 2008

From publiustemp-perl6internals2@yahoo.com

If you do this after building parrot​:

  cd languages/perl6
  make test

This basic test suite will fail. That's because of this test program​:

  t/00-parrot/06-op-inplace.t

It was written before modules could be loaded and manually printed out "ok $num" lines, but it did so out of sequence. This causes Test​::Harness to note a parse error and report a failure for the test suite, even though all tests pass.

I've updated it to "use Test" and output test numbers in sequence without altering the semantics of the test. "make test" in languages/perl6 now passes on my MacBook.

Cheers,
Ovid
--
Buy the book - http://www.oreilly.com/catalog/perlhks/
Tech blog - http://use.perl.org/~Ovid/journal/
Twitter - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6

@p6rt
Copy link
Author

p6rt commented Oct 20, 2008

From publiustemp-perl6internals2@yahoo.com

perl6tests.patch
Index: languages/perl6/t/00-parrot/06-op-inplace.t
===================================================================
--- languages/perl6/t/00-parrot/06-op-inplace.t	(revision 32047)
+++ languages/perl6/t/00-parrot/06-op-inplace.t	(working copy)
@@ -4,52 +4,48 @@
 
 use v6;
 
-say '1..11';
+use Test;
+plan 11;
 
 my $a = 0;
 $a += 1;
-print 'ok ';
-say $a;
+is $a, 1, '$var += Int';
+
 ++$a;
-print 'ok ';
-say $a;
+is $a, 2, '++$var';
+
 $a = 4;
 $a -= 1;
-print 'ok ';
-say $a;
+is $a, 3, '$var -= Int';
+
 my $b = 1;
 $a += $b;
-print 'ok ';
-say $a;
-# 5
+is $a, 4, '$var += $var2';
 
 $a +|= $b;
-print 'ok ';
-say $a;
+is $a, 5, '$var +|= Int';
+
 $a +&= +^$b;
 $a +^= 2;
-print 'ok ';
-say $a;
+is $a, 6, '$var +&= +^$var2; $var +^= Int';
+
 $a++;
-print 'ok ';
-say $a;
+is $a, 7, '$var++';
+
 $a = 1;
 $a +<= 3;
-print 'ok ';
-say $a;
+is $a, 8, '$var +<= Int';
 
 #9
 $a +>= 1;
 $a -= 1;
 $a **= 2;
-print 'ok ';
-say $a;
+is $a, 3, '$var +>= Int; $var -= Int; $var **= Int';
 
+#1 2 3 4 5 6 7 8 3 8 12
 $a /= 3;
 $a += 7;
-print 'ok ';
-say $a;
+is $a, 8, '$var /= Int; $var += Int';
 
 $a %= 3;
-print 'ok ';
-say $a + 10;
+is $a + 10, 12, '$var %= Int; $var + Int';

@p6rt
Copy link
Author

p6rt commented Oct 20, 2008

From publiustemp-perl6internals2@yahoo.com

OK, I've updated the patch. I've made the following assumptions​:

1. I cannot load modules.
2. I cannot use subroutines.
3. I cannot use inline ops for the test counter (since that's what
  is being tested)

The problem is that I've made the tests pass by assuming that the value of $a at each point is the correct value. I'm assuming from what Jerry has pointed out that these number should be sequential. It's a trivial fix to remedy this in the tests, but I didn't want to try and second-guess what was going on.

I think this patch (or something similar) is important as those who want to play with Rakudo will see a test failure if they run 'make test' as the README instructs.

Cheers,
Ovid
--
Buy the book - http://www.oreilly.com/catalog/perlhks/
Tech blog - http://use.perl.org/~Ovid/journal/
Twitter - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6

@p6rt
Copy link
Author

p6rt commented Oct 20, 2008

From publiustemp-perl6internals2@yahoo.com

perl6tests.patch
Index: languages/perl6/t/00-parrot/06-op-inplace.t
===================================================================
--- languages/perl6/t/00-parrot/06-op-inplace.t	(revision 32047)
+++ languages/perl6/t/00-parrot/06-op-inplace.t	(working copy)
@@ -6,50 +6,69 @@
 
 say '1..11';
 
+my $test_num = 1;
 my $a = 0;
 $a += 1;
-print 'ok ';
-say $a;
+print 'not ' if $a != 1;
+say "ok $test_num";
+$test_num = $test_num + 1;
+
 ++$a;
-print 'ok ';
-say $a;
+print 'not ' if $a != 2;
+say "ok $test_num";
+$test_num = $test_num + 1;
+
 $a = 4;
 $a -= 1;
-print 'ok ';
-say $a;
+
+print 'not ' if $a != 3;
+say "ok $test_num";
+$test_num = $test_num + 1;
+
+
+
 my $b = 1;
 $a += $b;
-print 'ok ';
-say $a;
-# 5
+print 'not ' if $a != 4;
+say "ok $test_num";
+$test_num = $test_num + 1;
 
 $a +|= $b;
-print 'ok ';
-say $a;
+print 'not ' if $a != 5;
+say "ok $test_num";
+$test_num = $test_num + 1;
+
 $a +&= +^$b;
 $a +^= 2;
-print 'ok ';
-say $a;
+print 'not ' if $a != 6;
+say "ok $test_num";
+$test_num = $test_num + 1;
+
 $a++;
-print 'ok ';
-say $a;
+print 'not ' if $a != 7;
+say "ok $test_num";
+$test_num = $test_num + 1;
+
 $a = 1;
 $a +<= 3;
-print 'ok ';
-say $a;
+print 'not ' if $a != 8;
+say "ok $test_num";
+$test_num = $test_num + 1;
 
-#9
 $a +>= 1;
 $a -= 1;
 $a **= 2;
-print 'ok ';
-say $a;
+print 'not ' if $a != 3;
+say "ok $test_num";
+$test_num = $test_num + 1;
 
 $a /= 3;
 $a += 7;
-print 'ok ';
-say $a;
+print 'not ' if $a != 8;
+say "ok $test_num";
+$test_num = $test_num + 1;
 
 $a %= 3;
-print 'ok ';
-say $a + 10;
+print 'not ' if ( $a +10 ) != 12;
+say "ok $test_num";
+$test_num = $test_num + 1;

@p6rt
Copy link
Author

p6rt commented Oct 20, 2008

From publiustemp-perl6internals2@yahoo.com

Sorry for the patch spam. I'm embarrassed that I didn't have this correct the first time (hey, YOU stay home and write tests for a strange platform while sick)

The test will now fail, but they'll fail for the correct reason​: **= is being misparsed, as pointed out earlier.

You might not notice the tests failing, but that's because "make test" seems to run the harness 3 times and the failing test is in the first run. If you don't notice this, you won't notice these tests failing.

Cheers,
Ovid
--
Buy the book - http://www.oreilly.com/catalog/perlhks/
Tech blog - http://use.perl.org/~Ovid/journal/
Twitter - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6

@p6rt
Copy link
Author

p6rt commented Oct 20, 2008

From publiustemp-perl6internals2@yahoo.com

perl6tests.patch
Index: languages/perl6/t/00-parrot/06-op-inplace.t
===================================================================
--- languages/perl6/t/00-parrot/06-op-inplace.t	(revision 32047)
+++ languages/perl6/t/00-parrot/06-op-inplace.t	(working copy)
@@ -6,50 +6,70 @@
 
 say '1..11';
 
+my $test_num = 1;
 my $a = 0;
 $a += 1;
-print 'ok ';
-say $a;
+print 'not ' if $a != 1;
+say "ok $test_num";
+$test_num = $test_num + 1;
+
 ++$a;
-print 'ok ';
-say $a;
+print 'not ' if $a != 2;
+say "ok $test_num";
+$test_num = $test_num + 1;
+
 $a = 4;
 $a -= 1;
-print 'ok ';
-say $a;
+
+print 'not ' if $a != 3;
+say "ok $test_num";
+$test_num = $test_num + 1;
+
+
+
 my $b = 1;
 $a += $b;
-print 'ok ';
-say $a;
-# 5
+print 'not ' if $a != 4;
+say "ok $test_num";
+$test_num = $test_num + 1;
 
 $a +|= $b;
-print 'ok ';
-say $a;
+print 'not ' if $a != 5;
+say "ok $test_num";
+$test_num = $test_num + 1;
+
 $a +&= +^$b;
 $a +^= 2;
-print 'ok ';
-say $a;
+print 'not ' if $a != 6;
+say "ok $test_num";
+$test_num = $test_num + 1;
+
 $a++;
-print 'ok ';
-say $a;
+print 'not ' if $a != 7;
+say "ok $test_num";
+$test_num = $test_num + 1;
+
 $a = 1;
 $a +<= 3;
-print 'ok ';
-say $a;
+print 'not ' if $a != 8;
+say "ok $test_num";
+$test_num = $test_num + 1;
 
-#9
 $a +>= 1;
 $a -= 1;
 $a **= 2;
-print 'ok ';
-say $a;
+print 'not ' if $a != 9;
+say "ok $test_num";
+$test_num = $test_num + 1;
 
+$a = 9;
 $a /= 3;
 $a += 7;
-print 'ok ';
-say $a;
+print 'not ' if $a != 10;
+say "ok $test_num";
+$test_num = $test_num + 1;
 
 $a %= 3;
-print 'ok ';
-say $a + 10;
+print 'not ' if ( $a +10 ) != 11;
+say "ok $test_num";
+$test_num = $test_num + 1;

@p6rt
Copy link
Author

p6rt commented Oct 21, 2008

From @jkeenan

On Mon Oct 20 09​:46​:08 2008, publiustemp-perl6internals2@​yahoo.com wrote​:
\> This basic test suite will fail. That's because of this test program​:

t/00-parrot/06-op-inplace.t

I've reported this a couple of times in
http://rt.perl.org/rt3/Ticket/Display.html?id=59634 -- but no one paid
attention.

Since you're proposing a patch, I'll merge 59634 into this one.

kid51

@p6rt
Copy link
Author

p6rt commented Oct 21, 2008

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Oct 21, 2008

From publiustemp-perl6internals2@yahoo.com

--- On Tue, 21/10/08, James Keenan via RT <perl6-bugs-followup@​perl.org>

\> This basic test suite will fail. That's
because of this test program​:

t/00-parrot/06-op-inplace.t

I've reported this a couple of times in
http://rt.perl.org/rt3/Ticket/Display.html?id=59634 -- but
no one paid
attention.

Since you're proposing a patch, I'll merge 59634
into this one.

Thanks. Hopefully this time there will be some traction because there does appear to be a bug in Perl 6, as evidenced by this one-liner​:

  perl6 $ ../../parrot perl6.pbc -e 'my $x = 3; $x **= 2; say $x'
  3

Unless, of course, this isn't supposed to be implemented yet, but that seems strange since it's in the basic tests.

Cheers,
Ovid
--
Buy the book - http://www.oreilly.com/catalog/perlhks/
Tech blog - http://use.perl.org/~Ovid/journal/
Twitter - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6

@p6rt
Copy link
Author

p6rt commented Oct 21, 2008

From @pmichaud

On Tue, Oct 21, 2008 at 12​:21​:24AM -0700, Ovid wrote​:

--- On Tue, 21/10/08, James Keenan via RT <perl6-bugs-followup@​perl.org>
Thanks. Hopefully this time there will be some traction because there
does appear to be a bug in Perl 6, as evidenced by this one-liner​:

perl6 $ ../../parrot perl6.pbc -e 'my $x = 3; $x **= 2; say $x'
3

Unless, of course, this isn't supposed to be implemented yet, but
that seems strange since it's in the basic tests.

The infix​:<**=> code broke as part of the mmd branch merge, because
the meaning of Parrot's 'pow' opcode has changed. The infix​:<**=>
function used the Parrot opcode (src/builtins/assign.pir​:80)

  a = a ** b # pow a, a, b

Before the MMD merge, this opcode meant "raise a to the power
of b and store the result back in a". However, after the mmd
branch merge this opcode now means "create a new PMC containing
the value of a raised to the b power and set register a to point
to that new PMC, leaving the value of its original PMC alone".
So, the pow opcode is no longer able to act as an inplace modifier.

I've corrected this in r32071, by explicitly assigning the new
result back to the PMC referenced by 'a'.

I've also applied Ovid's patch (with some fixes) in r32072, so
that the test correctly reports failures instead of simply
saying there are misnumbered tests.

Lastly, we've now reorganized the 'make test' target to make it more
obvious when there is a failure in the t/00-parrot/ or t/01-sanity/
tests, and removed the coding standards tests from 'make test'.

Thanks, closing ticket!

Pm

@p6rt
Copy link
Author

p6rt commented Oct 21, 2008

@pmichaud - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Oct 21, 2008
@p6rt
Copy link
Author

p6rt commented Oct 24, 2008

From @allison

Patrick R. Michaud wrote​:

The infix​:<**=> code broke as part of the mmd branch merge, because
the meaning of Parrot's 'pow' opcode has changed. The infix​:<**=>
function used the Parrot opcode (src/builtins/assign.pir​:80)

a = a \*\* b          \#  pow a, a, b

Before the MMD merge, this opcode meant "raise a to the power
of b and store the result back in a". However, after the mmd
branch merge this opcode now means "create a new PMC containing
the value of a raised to the b power and set register a to point
to that new PMC, leaving the value of its original PMC alone".
So, the pow opcode is no longer able to act as an inplace modifier.

The other math opcodes have two argument versions that call the 'i_'
inplace vtable function. I can add these for 'pow' if needed.

Allison
_______________________________________________
http://lists.parrot.org/mailman/listinfo/parrot-dev

@p6rt
Copy link
Author

p6rt commented Oct 24, 2008

From @pmichaud

On Thu, Oct 23, 2008 at 08​:14​:19PM -0700, Allison Randal via RT wrote​:

a = a \*\* b          \#  pow a, a, b

Before the MMD merge, this opcode meant "raise a to the power
of b and store the result back in a". However, after the mmd
branch merge this opcode now means "create a new PMC containing
the value of a raised to the b power and set register a to point
to that new PMC, leaving the value of its original PMC alone".
So, the pow opcode is no longer able to act as an inplace modifier.

The other math opcodes have two argument versions that call the 'i_'
inplace vtable function. I can add these for 'pow' if needed.

I'm not sure that every opcode needs an inplace form. And in Rakudo's
case it's not likely to matter much, as the (Perl 6) inplace operators
are unlikely to be able to use Parrot's inplace opcodes anyway.

Thanks,

Pm

@p6rt p6rt added the patch label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant