Skip to content

Commit

Permalink
pugs fudges
Browse files Browse the repository at this point in the history
  • Loading branch information
coke committed Mar 4, 2012
1 parent 9a6c674 commit 246ed8d
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 3 deletions.
2 changes: 2 additions & 0 deletions S02-literals/char-by-name.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ plan 10;

# L<S02/Unicode codepoints>

#?pugs 4 todo
is "\c[LEFT CORNER BRACKET]", "", '\c[LEFT CORNER BRACKET]';
is "\c[RIGHT WHITE CORNER BRACKET]", "", '\c[RIGHT WHITE CORNER BRACKET]';
is "\c[FULLWIDTH RIGHT PARENTHESIS]", "", '\c[FULLWIDTH RIGHT PARENTHESIS]';
Expand All @@ -26,6 +27,7 @@ is("\c[LF]", "\c10", '\c[LF] works');
is "\c[LATIN CAPITAL LETTER A, LATIN CAPITAL LETTER B]", 'AB', 'two letters in \c[]';
is "\c[LATIN CAPITAL LETTER A, COMBINING GRAVE ACCENT]", "\x[0041,0300]", 'letter and combining char in \c[]';

#?pugs todo
ok "\c[LATIN SMALL LETTER A WITH DIAERESIS,COMBINING CEDILLA]" ~~ /\w/,
'RT 64918 (some strings throw "Malformed UTF-8 string" errors';

Expand Down
4 changes: 4 additions & 0 deletions S02-literals/char-by-number.t
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ is("\x[20]", ' ', '\x[20] normal space');
is("\x[a0]", chr(0xa0), '\x[a0] non-breaking space');
is("\x[263a]", '', '\x[263a] wide hex character (SMILEY)');
is("\x[6211]", '', '\x[597d] wide hex character (Chinese char)');
#?pugs 2 todo
eval_dies_ok('"\x[6211"', 'broken "\x[6211"');
eval_dies_ok('"\x [6211]"', 'broken "\x [6211]"');

Expand All @@ -27,6 +28,7 @@ is("\o[40]", ' ', '\o[40] normal space');
is("\o[240]", chr(160), '\o[240] non-breaking space');
is("\o[23072]", '', '\o[23072] wide hex character (SMILEY)');
is("\o[61021]", '', '\o[61021] wide hex character (Chinese char)');
#?pugs 2 todo
eval_dies_ok('"\o[6211"', 'broken "\o[6211"');
eval_dies_ok('"\o [6211]"', 'broken "\o [6211]"');

Expand All @@ -41,6 +43,7 @@ is("\c[32]", ' ', '\c[32] normal space');
is("\c[160]", chr(160), '\c[240] non-breaking space');
is("\c[9786]", '', '\c[9786] wide hex character (SMILEY)');
is("\c[25105]", '', '\c[25105] wide hex character (Chinese char)');
#?pugs 2 todo
eval_dies_ok('"\c[6211"', 'broken "\c[6211"');
eval_dies_ok('"\c [6211]"', 'broken "\c [6211]"');

Expand All @@ -55,6 +58,7 @@ is("\c65,66,67", 'A,66,67', '\clist not valid');
eval_dies_ok q{"\10"}, '"\10" form is no longer valid Perl 6';
}

#?pugs skip '\040'
{
is "\040", "\x[0]40", '\0stuff is actually valid';
}
Expand Down
7 changes: 7 additions & 0 deletions S02-literals/misc-interpolation.t
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ is("$number {$number}", '1 1', 'number inside and outside closure works');
is("$number {my $number=2}", '1 2', 'local version of number in closure works');
is("$number {my $number=2} $number", '1 2 1', 'original number still available after local version in closure: works' );

#?pugs skip '?'
{
is "$(my $x = 2) $x", '2 2', 'Variable should interpolate and still be available in the outer scope.';
is("$(my $y = 2)" ~ $y, '22', 'Variable should interpolate and still be available in the outer scope.');
Expand All @@ -50,6 +51,7 @@ is("&func_w_args("foo","bar"))", '[foo][bar])', '"&func_w_args(...)" should inte
# L<S02/Method calls/"In order to interpolate the result of a method call">
is("$world.chars()", '5', 'method calls with parens should interpolate');
is("$world.chars", 'World.chars', 'method calls without parens should not interpolate');
#?pugs skip '.flip'
is("$world.flip.chars()", '5', 'cascade of argumentless methods, last ending in paren');
is("$world.substr(0,1)", 'W', 'method calls with parens and args should interpolate');

Expand All @@ -70,11 +72,13 @@ is(qq{a{chr 98}c}, 'abc', "curly brace delimiters don't interfere with closure i
# Quoting constructs
# The next test will always succeed, but if there's a bug it probably
# won't compile.
#?pugs 3 skip 'parsefail'
is(Q"abc\\d\\'\/", Q"abc\\d\\'\/", "raw quotation works");
is(q"abc\\d\"\'\/", Q|abc\d"\'\/|, "single quotation works"); #"
is(qq"abc\\d\"\'\/", Q|abc\d"'/|, "double quotation works"); #"
#?rakudo 3 skip 'qa qb and array/hash interpolation'
#?niecza skip 'No value for parameter \$index in postcircumfix:<[ ]>'
#?pugs skip 'parsefail'
is(qa"$world @list[] %hash{}", Q"$world 1 2 %hash{}", "only interpolate array");
is(qb"$world \\\"\n\t", "\$world \\\"\n\t", "only interpolate backslash");
#?niecza skip 'No value for parameter \$index in postcircumfix:<[ ]>'
Expand All @@ -85,15 +89,18 @@ is(" \c[111] \c[107] ", ' o k ', "\\c[] respects whitespaces around it");
# L<S02/Radix interpolation/separating the numbers with comma:>
is("x \x[41,42,43] x", "x ABC x", "\\x[] allows multiple chars (1)");
is("x \x[41,42,00043] x", "x ABC x", "\\x[] allows multiple chars (2)"); #OK not indicate octal
#?pugs todo
is("x \x[ 41, 42, 43 ] x", "x ABC x", "\\x[] allows multiple chars with white space");
is("x \c[65,66,67] x", "x ABC x", "\\c[] allows multiple chars (1)");
is("x \c[65,66,000067] x", "x ABC x", "\\c[] allows multiple chars (2)"); #OK not indicate octal
#?pugs todo
is("x \c[ 65, 66, 67 ] x", "x ABC x", "\\c[] allows multiple chars with white space");

is("x \x[41,42,43]] x", "x ABC] x", "\\x[] should not eat following ]s");
is("x \c[65,66,67]] x", "x ABC] x", "\\c[] should not eat following ]s");

# L<S12/Fancy method calls/Within an interpolation, the double-quoted form>
#?pugs skip 'parsefail'
{
class InterpolationTest {
method f { 'int' }
Expand Down
9 changes: 8 additions & 1 deletion S02-literals/pairs.t
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ plan 79;

sub f1n (:$a) { $a.WHAT.gist }
sub f1p ( $a) { $a.WHAT.gist }
#?pugs skip 'gist'
{
is f1n(a => 42), 'Int()', "'a => 42' is a named";
is f1n(:a(42)), 'Int()', "':a(42)' is a named";
Expand Down Expand Up @@ -71,6 +72,7 @@ sub f2 (:$a!) { WHAT($a) }
isa_ok $f2(:a), Bool, "in '\$f2(:a)', ':a' is a named";
isa_ok $f2.(:a), Bool, "in '\$f2.(:a)', ':a' is a named";

#?pugs 7 skip 'Missing required parameters'
dies_ok { f2("a" => 42) }, "'\"a\" => 42' is a pair";
dies_ok { f2(("a") => 42) }, "'(\"a\") => 42' is a pair";
dies_ok { f2((a => 42)) }, "'(a => 42)' is a pair";
Expand All @@ -79,6 +81,7 @@ sub f2 (:$a!) { WHAT($a) }
dies_ok { f2((:a)) }, "'(:a)' is a pair";
dies_ok { &f2.((:a)) }, 'in \'&f2.((:a))\', \'(:a)\' is a pair';

#?pugs 4 skip 'Missing required parameters'
dies_ok { $f2((:a)) }, "in '\$f2((:a))', '(:a)' is a pair";
dies_ok { $f2.((:a)) }, "in '\$f2.((:a))', '(:a)' is a pair";
dies_ok { $f2(((:a))) }, "in '\$f2(((:a)))', '(:a)' is a pair";
Expand All @@ -90,7 +93,7 @@ sub f3 ($a) { WHAT($a) }
my $pair = (a => 42);

isa_ok f3($pair), Pair, 'a $pair is not treated magically...';
#?pugs todo '[,]'
##?pugs todo '[,]'
#?rakudo skip 'prefix:<|>'
isa_ok f3(|$pair), Int, '...but |$pair is';
}
Expand Down Expand Up @@ -128,6 +131,7 @@ sub f6 ($a) { WHAT($a) }
}

sub f7 (:$bar!) { WHAT($bar) }
#?pugs skip 'Missing required parameter'
{
my $bar = 'bar';

Expand All @@ -136,6 +140,7 @@ sub f7 (:$bar!) { WHAT($bar) }
}

sub f8 (:$bar!) { WHAT($bar) }
#?pugs skip 'Missing required parameter'
{
my @array = <bar>;

Expand All @@ -144,13 +149,15 @@ sub f8 (:$bar!) { WHAT($bar) }
}

sub f9 (:$bar!) { WHAT($bar) }
#?pugs skip 'Missing required parameter'
{
my $arrayref = <bar>;

dies_ok { f9($arrayref => 42) },
"variables cannot be keys of syntactical pairs (3)";
}

#?pugs todo
{
is (a => 3).elems, 1, 'Pair.elems';
}
Expand Down
1 change: 1 addition & 0 deletions S03-operators/ternary.t
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ my $str3 = "bbb";
}

is(($str2 eq $str1 ?? 8 * 8 !! 9 * 9), 64, "?? !! in parenthesis");
#?pugs skip 'div'
is(($str2 eq $str3 ?? 8 + 8 !! 9 div 9), 1, "?? !! in parenthesis");

is(1 ?? 2 ?? 3 !! 4 !! 5 ?? 6 !! 7, 3, "nested ?? !!");
Expand Down
20 changes: 20 additions & 0 deletions S05-modifier/pos.t
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ plan 40;

for ("abcdef") {
ok(m:pos/abc/, "Matched 1: '$/'" );
#?pugs todo
is($/.to, 3, 'Interim position correct');
ok(m:pos/ghi|def/, "Matched 2: '$/'" );
#?pugs todo
is($/.to, 6, 'Final position correct');
}

Expand All @@ -26,9 +28,11 @@ for ("abcdef") {
$_ = "foofoofoo foofoofoo";
my $/;
ok(s:global:pos/foo/FOO/, 'Globally contiguous substitution');
#?pugs todo
is($_, "FOOFOOFOO foofoofoo", 'Correctly substituted contiguously');
}

#?pugs todo
{
my $str = "abcabcabc";
my $/;
Expand All @@ -51,21 +55,25 @@ for ("abcdef") {
{
my $str = "abcabcabc";
my @x = $str ~~ m:i:g:p/abc/;
#?pugs todo
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?
is($/.to, 3, 'Insensitive scalar repeated continued match pos');
}

#?pugs skip 'Cannot parse regex'
{
my $str = "abcabcabc";
my $match = $str.match(/abc/, :p(0));
Expand All @@ -91,22 +99,34 @@ for ("abcdef") {
{
my $str = "abcabcabc";
my $match = $str.match(/abc/, :pos(0));
#?pugs skip 'coercion'
ok $match.Bool, "Match anchored to 0";
is $match.from, 0, "and the match is in the correct position";
#?pugs skip 'coercion'
nok $str.match(/abc/, :pos(1)).Bool, "No match anchored to 1";
#?pugs skip 'coercion'
nok $str.match(/abc/, :pos(2)).Bool, "No match anchored to 2";

$match = $str.match(/abc/, :pos(3));
#?pugs skip 'coercion'
ok $match.Bool, "Match anchored to 3";
#?pugs todo
is $match.from, 3, "and the match is in the correct position";
#?pugs skip 'coercion'
nok $str.match(/abc/, :pos(4)).Bool, "No match anchored to 4";

$match = $str.match(/abc/, :pos(6));
#?pugs skip 'coercion'
ok $match.Bool, "Match anchored to 6";
#?pugs todo
is $match.from, 6, "and the match is in the correct position";
#?pugs skip 'coercion'
nok $str.match(/abc/, :pos(7)).Bool, "No match anchored to 7";
#?pugs skip 'coercion'
nok $str.match(/abc/, :pos(8)).Bool, "No match anchored to 8";
#?pugs skip 'coercion'
nok $str.match(/abc/, :pos(9)).Bool, "No match anchored to 9";
#?pugs skip 'coercion'
nok $str.match(/abc/, :pos(10)).Bool, "No match anchored to 10";
}

Expand Down
9 changes: 7 additions & 2 deletions S05-modifier/sigspace.t
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,29 @@ Perl6::Rules, version 0.3 (12 Apr 2004), file t/word.t.

plan 11;

#?pugs emit force_todo(3,4,5);

ok(!( "abc def" ~~ m/abc def/ ), 'Literal space nonmatch' );
#?pugs todo
ok( "abcdef" ~~ m/abc def/, 'Nonspace match' );
#?pugs todo
ok( "abc def" ~~ m:s/abc def/, 'Word space match' );
#?pugs todo
ok( "abc\ndef" ~~ m:sigspace/abc def/, 'Word newline match' );
ok(!( "abcdef" ~~ m:sigspace/abc def/ ), 'Word nonspace nonmatch' );
#?pugs todo
ok( "abc def" ~~ m:sigspace/abc <.ws> def/, 'Word explicit space match');

#?pugs todo
ok 'abc def' ~~ m/:s abc def/, 'inline :s (+)';
ok 'zabc def' !~~ m/:s abc def/, 'inline :s implies <.ws> immediately (-)';
#?pugs todo
ok 'zabc def' ~~ m/:s'abc' def/, 'inline :s implies <.ws> immediately (+)';


# L<S05/Modifiers/The :s modifier is considered sufficiently important>

#?rakudo 2 skip 'mm'
#?niecza 2 skip 'Action method quote:mm not yet implemented'
#?pugs todo
ok 'abc def' ~~ mm/c d/, 'mm// works, implies :s (+)';
ok 'abcdef' !~~ mm/c d/, 'mm// works, implies :s (-)';

Expand Down
1 change: 1 addition & 0 deletions S06-signature/closure-over-parameters.t
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ sub factorial (Int $n) {

is factorial(0), 1, "closing over params of outer subs (0)";
is factorial(1), 1, "closing over params of outer subs (1)";
#?pugs 2 todo
is factorial(2), 2, "closing over params of outer subs (2)";
is factorial(3), 6, "closing over params of outer subs (3)";

Expand Down
4 changes: 4 additions & 0 deletions S06-signature/code.t
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,19 @@ tester(sub ($x) { $collector = 3 * $x });
ok $collector == 12, 'same with anonymous sub';

sub tester2(&my_sub) { 1 } #OK not used
#?pugs todo
dies_ok {eval 'tester2(42)' }, "can't pass thing that doesn't do Callable";

sub not_returns_a_sub { 3 };
#?pugs todo
dies_ok { eval 'tester2(not_returns_a_sub)' },
"can't pass thing that doesn't do Callable";

is tester2({ 'block' }), 1, 'Can pass a block to a &parameter';

# RT #68578
#?niecza todo
#?pugs todo
{
sub rt68578( Callable &x ) {} #OK not used
dies_ok { rt68578({ 'block' }) },
Expand All @@ -48,6 +51,7 @@ is tester2({ 'block' }), 1, 'Can pass a block to a &parameter';
#?rakudo todo 'RT 67932'
lives_ok { foo },
'can call a sub with a code object defaulting to something of its own name';
#?pugs todo
ok !$tracker.defined, 'the inner &foo is undefined (scoping)';
}

Expand Down
16 changes: 16 additions & 0 deletions S32-num/stringify.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ plan 76;

#?DOES 4
sub Complex_str_test($value, $str_nucleus) {
#?pugs todo
is ~$value, $str_nucleus, "~<$str_nucleus>";
#?pugs skip 'coercion'
is $value.Str, $str_nucleus, "<$str_nucleus>.Str";
#?pugs skip '.gist'
is $value.gist, $str_nucleus, "<$str_nucleus>.gist";
#?rakudo todo 'Complex.perl'
#?pugs todo
is $value.perl, "<$str_nucleus>", "<$str_nucleus>.perl";
}

Expand All @@ -22,20 +26,26 @@ Complex_str_test (3.5 + 4i), '3.5+4i';
Complex_str_test (3 + 4.5i), '3+4.5i';
# infinities
Complex_str_test (Inf + 3i), 'Inf+3i';
#?pugs skip 'parsefail'
Complex_str_test (0 + Inf\i), '0+Inf\i';
Complex_str_test (-Inf + 3i), '-Inf+3i';
#?pugs skip 'parsefail'
Complex_str_test (0 - Inf\i), '0-Inf\i';
Complex_str_test (NaN + 3i), 'NaN+3i';
#?pugs skip 'parsefail'
Complex_str_test (0 + NaN\i), '0+NaN\i';

# quick check that type objects stringify correctly - this has been a problem
# for Niecza in the past

#?pugs skip 'gist'
is Complex.gist, 'Complex()', 'Complex.gist';
#?pugs todo
is Complex.perl, 'Complex', 'Complex.perl';
# XXX Should ~Complex and Complex.Str return something specific? For now
# just make sure they don't die
lives_ok { ~Complex }, '~Complex does not die';
#?pugs skip 'coercion'
lives_ok { Complex.Str }, 'Complex.Str does not die';

# L<S32::Numeric/Rat/"=item gist">
Expand All @@ -45,10 +55,13 @@ lives_ok { Complex.Str }, 'Complex.Str does not die';
# converters)
#?DOES 4
sub Rat_str_test($value, $str_nucleus) {
#?pugs 2 skip 'coercion'
is ~$value, ~$value.Num, "~<$str_nucleus>";
is $value.Str, ~$value.Num, "<$str_nucleus>.Str";
#?pugs skip '.gist'
is $value.gist, ~$value.Num, "<$str_nucleus>.gist";
#?rakudo todo 'Rat.perl'
#?pugs todo
is $value.perl, "<$str_nucleus>", "<$str_nucleus>.perl";
}

Expand All @@ -63,9 +76,12 @@ Rat_str_test 13/39, '1/3';
# Bignum sanity
Rat_str_test (4.5 ** 60), '1797010299914431210413179829509605039731475627537851106401/1152921504606846976';

#?pugs skip '.gist'
is Rat.gist, 'Rat()', 'Rat.gist';
#?pugs todo
is Rat.perl, 'Rat', 'Rat.perl';
lives_ok { ~Rat }, '~Rat does not die';
#?pugs todo
lives_ok { Rat.Str }, 'Rat.Str does not die';

# TODO: FatRat, Num (once better specced), Int (maybe, but hard to mess up)
Expand Down

0 comments on commit 246ed8d

Please sign in to comment.