Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Simple test for the sub form of 'X'
Closes #165
  • Loading branch information
jonathanstowe committed Oct 5, 2016
1 parent 4f03cdb commit f9950fa
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions S32-list/cross.t
@@ -0,0 +1,15 @@
use v6;


use Test;

plan 2;

# most of the tests for this are done in the S03-metaops/cross.t
# will just test the interface here;

is(cross(<a b>, <1 2>), <a 1 a 2 b 1 b 2>, "plain cross");
is(cross(<a b>, <1 2>, with => &[~]), <a1 a2 b1 b2>, "cross with operator");


# vim: expandtab shiftwidth=4 ft=perl6

6 comments on commit f9950fa

@MasterDuke17
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to do an is-deeply? Don't these tests depend on the stringification being the same?

@zoffixznet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to do an is-deeply?

Yes.

Don't these tests depend on the stringification being the same?

They do, by using eq that stringifies its operands (whereas is-deeply uses eqv)

@jonathanstowe
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably but the S03-metaops/cross.t also uses the is like this, so that would go broken if the stringification changed too.

@zoffixznet
Copy link
Contributor

@zoffixznet zoffixznet commented on f9950fa Oct 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That just means S03-metaops/cross.t tests are less than ideal too and abuse is 😸 It's not change of stringification that's the issue, but that you're failing to check correct return types and failing to check the entire output is correct: say [eq] ("a1 a2", "b1 b2"), <a1 a2 b1 b2>, ("a1", ("a2", ("b1", ("b2")))), [<a1 a2 b1 b2>] gives True, even though those items are vastly different.

Also, from tests' perspective, there's no relation between cross and infix:<X>. You're letting your knowledge of a single implementation's details seep into your tests.

For example, if I change this line in core to:

sub cross (*@, :$with) { $with ?? 'a1 a2 b1 b2' !! 'a 1 a 2 b 1 b 2' }

the entire spectest will still pass, but the sub will be abjectly broken; it won't even be returning lists 😹

@jonathanstowe
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. I'll change this one to use is-deeply, but I''ll put a issue to change the 'is' in the other tests.

@jonathanstowe
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with fa7da3d

I've added an issue #167 to pick up the rest :)

Please sign in to comment.