Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
New operators: eq, ne, ===
  • Loading branch information
Stefan O'Rear committed Jul 14, 2010
1 parent a2eefa3 commit c5c98e7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions setting
Expand Up @@ -313,6 +313,13 @@ sub prefix:<?>($v) { $v.Bool }

sub prefix:<!>($v) { if $v { ?0 } else { ?1 } }

sub infix:<eq>($l,$r) { Q:NIL {
{$l.Str} @ unbox:String {$r.Str} @ unbox:String == box:Bool } }
sub infix:<ne>($l,$r) { Q:NIL {
{$l.Str} @ unbox:String {$r.Str} @ unbox:String != box:Bool } }
# this one is horribly wrong and only handles the ref eq case.
sub infix:<===>($l,$r) { Q:NIL { {$l} @ {$r} @ == box:Bool } }

# XXX: We can't use augment syntax because we don't have use working, so
# no MONKEY_TYPING.

Expand Down
9 changes: 8 additions & 1 deletion test.pl
Expand Up @@ -10,7 +10,7 @@ ($num)
say ("1.." ~ $num);
}

plan 24;
plan 29;

ok 1, "one is true";
ok 2, "two is also true";
Expand Down Expand Up @@ -90,3 +90,10 @@ ($num)
ok !Mu.defined, "type objects are undefined";
ok "Foo".defined, "strings are defined";
ok !Str.defined, "derived type objects are still undefined";

ok "foo" eq "foo", "equal strings are equal";
ok !("foo" ne "foo"), "equal strings are not not equal";
ok "foo" ne "bar", "unequal strings are unequal";

ok Mu === Mu, "identical objects are identical";
ok !(Mu === Any), "unidentical objects are unidentical";

0 comments on commit c5c98e7

Please sign in to comment.