This repository has been archived by the owner on Feb 3, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement given BLOCK and when BLOCK, make postifix when match as $_ ~~
EXPR rather than EXPR ~~ $_. Added tests.
- Loading branch information
Showing
2 changed files
with
54 additions
and
4 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#! nqp | ||
|
||
say('1..6'); | ||
|
||
given 42 { | ||
say('ok 1 - code inside given'); | ||
print('not ') if $_ != 42; | ||
say('ok 2 - $_ is 42'); | ||
} | ||
|
||
class Foo { } | ||
class Bar { } | ||
|
||
my $_ := Foo.new; | ||
say('ok 3 - postfix when') when Foo; | ||
|
||
given Foo.new { | ||
say('ok 4 - code before match run'); | ||
when Bar { | ||
say('not ok 5 - matches Foo'); | ||
} | ||
when Foo { | ||
say('ok 5 - matches Foo'); | ||
} | ||
print('not '); | ||
} | ||
say('ok 6 - code after match not run'); |