-
-
Save timo/5810910 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PB::SubMsg { | |
} | |
class PB::Option { | |
has Str $.name; | |
has $.constant; | |
has PB::SubMsg $.sub-message; | |
method gist() { | |
"<Option {$.name}={$.constant || 'Any'}>" | |
} | |
} | |
multi infix:<eq>(PB::Option $a, PB::Option $b) { | |
return | |
[&&] ($a.name eq $b.name), | |
($a.constant // "") eq ($b.constant // ""), | |
($a.sub-message // "") eq ($b.sub-message // ""); | |
} | |
use Test; | |
plan 3; | |
my $o = PB::Option.new(name=>'hello'); | |
my $oo = PB::Option.new(name=>'hello'); | |
my $a = PB::Option.new(:name<hello>, :constant<greetings>); | |
my $aa = PB::Option.new(:name<hello>, :constant<greetings>); | |
ok $o eq $oo; | |
ok $a eq $aa; | |
nok $o eq $a; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment