Skip to content

Commit

Permalink
More S05 test unfudges, skip->todo and additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Sep 2, 2013
1 parent 6ef1b5d commit fa508be
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 31 deletions.
6 changes: 3 additions & 3 deletions S05-metasyntax/angle-brackets.t
Expand Up @@ -155,18 +155,18 @@ character classes), and those are referenced at the correct spot.

# A leading @ matches like a bare array except that each element is
# treated as a subrule (string or Regex object) rather than as a literal
#?rakudo skip 'TODO: array interpolation into regexes'
{
my @first = <a b c .**4>;
ok('dddd' ~~ /<@first>/, 'strings are treated as a subrule in <@foo>');

my @second = rx/\.**2/, rx/'.**2'/;
#?rakudo todo 'array interpolation into regexes'
ok('abc.**2def' ~~ /<@second>/, 'Regexes are left alone in <@foo> subrule');
}

# A leading % matches like a bare hash except that
# a string value is always treated as a subrule
#?rakudo skip '<%hash> not implemented'
#?rakudo todo '<%hash> not implemented'
#?niecza skip 'Sigil % is not allowed for regex assertions'
{
my %first = {'<alpha>' => '', 'b' => '', 'c' => ''};
Expand Down Expand Up @@ -236,12 +236,12 @@ character classes), and those are referenced at the correct spot.
# The <...>, <???>, and <!!!> special tokens have the same "not-defined-yet"
# meanings within regexes that the bare elipses have in ordinary code
#?rakudo skip '..., !!! and ??? in regexes'
#?niecza skip 'Action method assertion:sym<???> not yet implemented'
{
eval_dies_ok('"foo" ~~ /<...>/', '<...> dies in regex match');
# XXX: Should be warns_ok, but we don't have that yet
lives_ok({'foo' ~~ /<???>/}, '<???> lives in regex match');
#?rakudo todo '!!! in regexes'
eval_dies_ok('"foo" ~~ /<!!!>/', '<!!!> dies in regex match');
}
Expand Down
2 changes: 1 addition & 1 deletion S05-metasyntax/repeat.t
Expand Up @@ -60,9 +60,9 @@ is(~('foo,bar,baz,' ~~ m/[<alpha>+]+ %% ','/), 'foo,bar,baz,', '%% with a term w
#?pugs todo
is(~('foo, bar,' ~~ m/[<alpha>+]+ % [','\s*]/), 'foo, bar', '% with a more complex term');

#?rakudo 3 skip 'nom regression'
ok 'a, b, c' !~~ /:s^<alpha>+%\,$/, 'with no spaces around %, no spaces can be matched';
#?pugs todo
#?rakudo 2 todo 'nom regression'
ok 'a, b, c' ~~ /:s^ <alpha>+ % \, $/, 'with spaces around %, spaces can be matched';
#?pugs todo
ok 'a , b ,c' ~~ /:s^ <alpha>+ % \, $/, 'same, but with leading spaces';
Expand Down
2 changes: 1 addition & 1 deletion S05-modifier/counted-match.t
Expand Up @@ -45,7 +45,7 @@ my $data = "f fo foo fooo foooo fooooo foooooo";
#

# more interesting variations of :nth(...)
#?rakudo skip 'nom regression'
#?rakudo skip 'hangs'
#?niecza skip 'hangs'
{
my @match = $data.match(/fo+/, :nth(2, 3)).list;
Expand Down
5 changes: 2 additions & 3 deletions S05-modifier/counted.t
Expand Up @@ -211,7 +211,6 @@ $sub6 = "f bar bar bar bar bar bar";

# :Nx...

#?rakudo skip 's{} = ...'
{
my $try = $data;
ok(!( $try ~~ s:0x{fo+}=q{bar} ), "Can't substitute 0x" );
Expand Down Expand Up @@ -242,8 +241,8 @@ $sub6 = "f bar bar bar bar bar bar";
is($try, $sub6, 'substituted 6x correctly');

$try = $data;
ok($try ~~ s:7x{fo+}=q{bar}, 'substitute 7x');
is($try, $data, 'substituted 7x correctly');
nok($try ~~ s:7x{fo+}=q{bar}, 'substitute 7x');
is($try, $data, 'did not substitute 7x');
}

# vim: ft=perl6
17 changes: 11 additions & 6 deletions S05-modifier/ii.t
Expand Up @@ -32,23 +32,28 @@ for @tests -> $t {
#L<S05/Modifiers/"If the pattern is matched with :sigspace">

# target, substution, result, name
my @smart_tests = (
my @passing = (
['HELLO', 'foo', 'FOO', 'uc()'],
['HE LO', 'foo', 'FOO', 'uc()'],
['hello', 'fOo', 'foo', 'lc()'],
);
my @todo = (
['HE LO', 'foo', 'FOO', 'uc()'],
['he lo', 'FOOOoO', 'fooooo', 'lc()'],
['He lo', 'FOOO', 'Fooo', 'ucfrst(lc())'],
['hE LO', 'fooo', 'fOOO', 'lcfrst(uc())'],
['hE LO', 'foobar', 'fOOBAR', 'lcfrst(uc())'],
['Ab Cd E', 'abc de gh i', 'Abc De Gh I', 'wordcase()'],
);

for @smart_tests -> $t {
for @passing -> $t {
my $test_str = $t[0];
$test_str ~~ s:i:ii:sigspace/.*/$t[1]/;
is $test_str, $t[2], ":i:ii:sigspace modifier: {$t[0]} ~~ s:ii:s/.*/{$t[1]}/ => {$t[2]}";
}
for @todo -> $t {
my $test_str = $t[0];
$test_str ~~ s:i:ii:sigspace/.*/$t[1]/;
# some of these tests actuall pass in Rakudo, so skipping them to avoid
# too many passing TODOs
#?rakudo skip 'some NYI'
#?rakudo todo 'NYI'
is $test_str, $t[2], ":i:ii:sigspace modifier: {$t[0]} ~~ s:ii:s/.*/{$t[1]}/ => {$t[2]}";
}

Expand Down
4 changes: 2 additions & 2 deletions S05-modifier/overlapping.t
Expand Up @@ -10,7 +10,7 @@ It probably needs a few syntax updates to remove p5isms
=end pod

plan 21;
plan 22;

#?pugs emit force_todo(2,3,5,6,10);

Expand All @@ -26,7 +26,7 @@ my @expected = (
[ 7, 'Abbra' ],
);

#?rakudo skip "m:overlap// NYI"
#?rakudo todo 'm:overlap NYI'
{
for (1..2) -> $rep {
ok($str ~~ m:i:overlap/ a .+ a /, "Repeatable overlapping match ($rep)" );
Expand Down
6 changes: 2 additions & 4 deletions S05-modifier/perl5_5.t
Expand Up @@ -30,7 +30,7 @@ is(("<&OUT" ~~ rx:P5/^[<>]&/ && $/), "<&", 're_tests 631/0 (815)');
is(("aaaaaaaaaa" ~~ rx:P5/^(a\1?){4}$/ && $0), "aaaa", 're_tests 633/1 (817)');
ok((not ("aaaaaaaaa" ~~ rx:P5/^(a\1?){4}$/)), 're_tests 635 (819)');
ok((not ("aaaaaaaaaaa" ~~ rx:P5/^(a\1?){4}$/)), 're_tests 637 (821)');
#?rakudo 3 skip "(?(1)...) syntax NYI"
#?rakudo todo "unknown issue"
is(("aaaaaaaaaa" ~~ rx:P5/^(a(?(1)\1)){4}$/ && $0), "aaaa", 're_tests 639/1 (823)');
ok((not ("aaaaaaaaa" ~~ rx:P5/^(a(?(1)\1)){4}$/)), 're_tests 641 (825)');
ok((not ("aaaaaaaaaaa" ~~ rx:P5/^(a(?(1)\1)){4}$/)), 're_tests 643 (827)');
Expand Down Expand Up @@ -101,10 +101,8 @@ is(("Ab4ab" ~~ rx:P5/(?i)(ab)\d\1/ && $0), "Ab", 're_tests 728/1 (924)');
is(("ab4Ab" ~~ rx:P5/(?i)(ab)\d\1/ && $0), "ab", 're_tests 730/1 (926)');
is(("foobar1234baz" ~~ rx:P5/foo\w*\d{4}baz/ && $/), "foobar1234baz", 're_tests 732/0 (928)');
#?pugs skip "PCRE hard parsefail"
#?rakudo skip "code blocks in P5 regexes NYI"
is(("cabd" ~~ rx:P5/a(?{})b/ && $/), "ab", 're_tests 734/0 (930)');
#?pugs skip "PCRE hard parsefail"
#?rakudo skip "code blocks in P5 regexes NYI"
is(("cabd" ~~ rx:P5/a(?{"\{"})b/ && $/), "ab", 're_tests 735/0 (931)');
ok(("x~~" ~~ rx:P5/x(~~)*(?:(?:F)?)?/), 're_tests 736 (932)');
is(("aaac" ~~ rx:P5/^a(?#xxx){3}c/ && $/), "aaac", 're_tests 738/0 (934)');
Expand All @@ -114,7 +112,7 @@ is(("dbaacb" ~~ rx:P5/(?<![cd])[ab]/ && $/), "a", 're_tests 742/0 (938)');
ok((not ("dbcb" ~~ rx:P5/(?<!(c|d))b/)), 're_tests 744 (940)');
is(("dbaacb" ~~ rx:P5/(?<!(c|d))[ab]/ && $/), "a", 're_tests 746/0 (942)');
is(("cdaccb" ~~ rx:P5/(?<!cd)[ab]/ && $/), "b", 're_tests 748/0 (944)');
#?rakudo skip "loops"
#?rakudo skip "hangs"
ok((not ("a--" ~~ rx:P5/^(?:a?b?)*$/)), 're_tests 750 (946)');
is(("a\nb\nc\n" ~~ rx:P5/((?m)^b$)/ && $0), "b", 're_tests 752/1 (948)');
is(("a\nb\n" ~~ rx:P5/(?m)^b/ && $/), "b", 're_tests 753/0 (949)');
Expand Down
2 changes: 1 addition & 1 deletion S05-modifier/perl5_8.t
Expand Up @@ -64,7 +64,7 @@ ok((not ("b\nca" ~~ rx:P5/(?m)abb\z/)), 're_tests 1104 (1308)');
ok((not ("b\nca" ~~ rx:P5/(?m)abb$/)), 're_tests 1105 (1309)');
is(("ca" ~~ rx:P5/(^|x)(c)/ && $1), "c", 're_tests 1106/2 (1310)');
ok((not ("x" ~~ rx:P5/a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz/)), 're_tests 1108 (1312)');
#?rakudo skip '(?>...) not implemented'
#?rakudo todo '(?>...) not implemented'
is(("_I(round(xs * sz),1)" ~~ rx:P5/round\(((?>[^()]+))\)/ && $0), "xs * sz", 're_tests 1110/1 (1314)');
ok(("foo.bart" ~~ rx:P5/foo.bart/), 're_tests 1112 (1316)');
ok(("abcd\ndxxx" ~~ rx:P5/(?m)^d[x][x][x]/), 're_tests 1114 (1318)');
Expand Down
6 changes: 3 additions & 3 deletions S05-modifier/pos.t
Expand Up @@ -21,12 +21,12 @@ for ("abcdef") {
is($/.to, 6, 'Final position correct');
}

#?rakudo skip "s:pos/// NYI"
{
$_ = "foofoofoo foofoofoo";
my $/;
ok(s:global:pos/foo/FOO/, 'Globally contiguous substitution');
#?pugs todo
#?rakudo todo "s:pos/// NYI"
is($_, "FOOFOOFOO foofoofoo", 'Correctly substituted contiguously');
}

Expand All @@ -48,26 +48,26 @@ for ("abcdef") {
ok($/.to == 9, 'Insensitive recontinued match pos');
}

#?rakudo skip 'm:g'
#?niecza skip ':i'
{
my $str = "abcabcabc";
my @x = $str ~~ m:i:g:p/abc/;
#?pugs todo
#?rakudo todo 'm:g'
is("@x", "abc abc abc", 'Insensitive repeated continued match');
#?pugs todo
ok($/.to == 9, 'Insensitive repeated continued match pos');

ok ($str !~~ m:i:p/abc/, 'no more match, string exhausted');
}

#?rakudo skip "m:p:i:g// NYI"
#?niecza skip ':i'
#?pugs todo
{
my $str = "abcabcabc";
my @x = ?($str ~~ m:p:i:g/abc/);
# XXX is that correct?
#?rakudo todo "m:p:i:g// NYI"
is($/.to, 3, 'Insensitive scalar repeated continued match pos');
}

Expand Down
4 changes: 2 additions & 2 deletions S05-modifier/repetition.t
Expand Up @@ -7,11 +7,11 @@ plan 12;

#?pugs emit skip_rest("Not yet implemented");

#?rakudo 2 skip ':2x'
#?rakudo todo ':2x'
ok('abab' ~~ m:2x/ab/, ':2x (repetition) modifier (+)');
nok('ab' ~~ m:2x/ab/, ':2x (repetition) modifier (-)');

#?rakudo 2 skip ':x(2)'
#?rakudo todo ':x(2)'
ok('abab' ~~ m:x(2)/ab/, ':2x (repetition) modifier (+)');
nok('ab' ~~ m:x(2)/ab/, ':2x (repetition) modifier (-)');

Expand Down
8 changes: 4 additions & 4 deletions S05-transliteration/trans.t
Expand Up @@ -100,7 +100,7 @@ is("I\xcaJ".trans('I..J' => 'i..j'), "i\xcaj");
is("\x12c\x190".trans("\x12c" => "\x190"), "\x190\x190");

# should these be combined?
#?rakudo skip 'disambiguate ranges'
#?rakudo todo 'disambiguate ranges'
#?niecza todo
#?pugs todo
is($b.trans('A..H..Z' => 'a..h..z'), $a,
Expand All @@ -124,9 +124,9 @@ is("hello".trans("l" => ""), "heo", "can replace with empty string");

# complement, squeeze/squash, delete

#?rakudo 2 skip 'flags'
#?niecza 2 skip 'trans flags NYI'
#?pugs todo
#?rakudo todo 'flags'
is('bookkeeper'.trans(:s, 'a..z' => 'a..z'), 'bokeper',
':s flag (squash)');

Expand All @@ -138,7 +138,7 @@ is('bookkeeper'.trans(:d, 'ok' => ''), 'beeper',
is('ABC123DEF456GHI'.trans('A..Z' => 'x'), 'xxx123xxx456xxx',
'no flags');

#?rakudo 4 skip 'flags'
#?rakudo 4 todo 'flags'
#?niecza 4 skip 'trans flags NYI'
#?pugs todo
is('ABC123DEF456GHI'.trans(:c, 'A..Z' => 'x'),'ABCxxxDEFxxxGHI',
Expand All @@ -160,7 +160,7 @@ is('ABC111DEF222GHI'.trans(:c, :d, 'A..Z' => ''),'ABCDEFGHI',
is('Good&Plenty'.trans('len' => 'x'), 'Good&Pxxxty',
'no flags');

#?rakudo 5 skip 'flags'
#?rakudo 5 todo 'flags'
#?niecza 5 skip 'trans flags NYI'
#?pugs todo
is('Good&Plenty'.trans(:s, 'len' => 'x',), 'Good&Pxty',
Expand Down
2 changes: 1 addition & 1 deletion S05-transliteration/with-closure.t
Expand Up @@ -54,7 +54,7 @@ is $y, 2, 'Closure invoked twice (once per replacemen
}

my $orig = 'hello';
#?rakudo skip '.ord on Match unimplemented'
#?rakudo skip 'Unable to resolve method ord in class Any'
#?niecza skip 'Unable to resolve method ord in class Any'
is $orig.trans(/(l)/ => { $_[0].ord }), 'he108108o', 'capturing regex + closure with .ord on $_';
is $orig, 'hello', 'original string unchanged';
Expand Down

0 comments on commit fa508be

Please sign in to comment.