Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
pugs fudge
  • Loading branch information
coke committed Apr 9, 2012
1 parent 99f26b6 commit e33900b
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 2 deletions.
1 change: 1 addition & 0 deletions S02-literals/subscript.t
Expand Up @@ -11,6 +11,7 @@ plan 2;
lives_ok({ all(@newval2) < any(@oldval); all(@newval1) > all(@oldval) }, "parses correctly, second statement is true");

my %hash = ("foo", "bar");
#?pugs todo
dies_ok { eval '%hash <foo>; 1'}, '%hash \s+ <subscript> doesnt parse';
};

Expand Down
5 changes: 5 additions & 0 deletions S03-operators/misc.t
Expand Up @@ -53,6 +53,7 @@ is("text " ~ "stitching", "text stitching", 'concatenation with ~ operator');

# L<S03/Tight or precedence/short-circuit inclusive-or>
is(2 || 3, 2, "|| returns first true value");
#?pugs skip 'Mu'
ok(!(defined( 0 || Mu)), "|| returns last false value of list?");

{
Expand All @@ -66,9 +67,12 @@ is(2 ?| 3, True, "boolean or (?|) returns True or False");
is(0 ?| Any, False, "boolean or (?|) returns True or False");

# L<S03/Junctive operators/They thread through operations>
#?pugs skip 'autothread'
ok(?((all((4|5|6) + 3) == one(7|8|9))), "all elements in junction are incremented");
#?pugs skip 'autothread'
ok(?((any(1..6) == one(1|2|3|4|5|6))), "any elements will match via junction");

#?pugs skip 'autothread'
{
ok( ?(7 > any(4..12)), "any test against scalar" );

Expand Down Expand Up @@ -97,6 +101,7 @@ ok(?((any(1..6) == one(1|2|3|4|5|6))), "any elements will match via junction");
# L<S03/Traversing arrays in parallel/"but a short list may always be extended arbitrarily">
#?rakudo todo "nom regression"
#?niecza todo
#?pugs todo
{
is (1, 2, * Z <a b c d>).join('|'),
'1|a|2|b|2|c|2|d',
Expand Down
3 changes: 3 additions & 0 deletions S04-phasers/first.t
Expand Up @@ -5,6 +5,7 @@ use Test;
plan 4;

# L<S04/Phasers/FIRST "at loop initialization time">
#?pugs todo
{
my $str = '';
for 1..2 {
Expand All @@ -23,6 +24,7 @@ plan 4;
}

# L<S04/Phasers/can occur multiple times>
#?pugs todo
{
my $str = '';
for 1..2 {
Expand All @@ -34,6 +36,7 @@ plan 4;
}

# L<S04/Phasers/FIRST "at loop initialization time" "before any ENTER">
#?pugs todo
{
my $str = '';
for 1..2 {
Expand Down
26 changes: 26 additions & 0 deletions S05-metasyntax/charset.t
Expand Up @@ -17,71 +17,97 @@ plan 34;
# Broken:
# L<S05/Extensible metasyntax (C<< <...> >>)/"A leading [ ">

#?pugs todo
ok("zyxaxyz" ~~ m/(<[aeiou]>)/, 'Simple set');
#?pugs todo
is($0, 'a', 'Simple set capture');

# L<S05/Extensible metasyntax (C<< <...> >>)/"A leading - indicates">
ok(!( "a" ~~ m/<-[aeiou]>/ ), 'Simple neg set failure');
#?pugs todo
ok("f" ~~ m/(<-[aeiou]>)/, 'Simple neg set match');
#?pugs todo
is($0, 'f', 'Simple neg set capture');

# L<S05/Extensible metasyntax (C<< <...> >>)/Character classes can be combined>
ok(!( "a" ~~ m/(<[a..z]-[aeiou]>)/ ), 'Difference set failure');
#?pugs todo
ok("y" ~~ m/(<[a..z]-[aeiou]>)/, 'Difference set match');
#?pugs todo
is($0, 'y', 'Difference set capture');
ok(!( "a" ~~ m/(<+alpha-[aeiou]>)/ ), 'Named difference set failure');
#?pugs todo
ok("y" ~~ m/(<+alpha-[aeiou]>)/, 'Named difference set match');
#?pugs todo
is($0, 'y', 'Named difference set capture');
ok(!( "y" ~~ m/(<[a..z]-[aeiou]-[y]>)/ ), 'Multi-difference set failure');
#?pugs todo
ok("f" ~~ m/(<[a..z]-[aeiou]-[y]>)/, 'Multi-difference set match');
#?pugs todo
is($0, 'f', 'Multi-difference set capture');

#?pugs todo
ok(']' ~~ m/(<[\]]>)/, 'quoted close LSB match');
#?pugs todo
is($0, ']', 'quoted close LSB capture');
#?pugs todo
ok('[' ~~ m/(<[\[]>)/, 'quoted open LSB match');
#?pugs todo
is($0, '[', 'quoted open LSB capture');
#?pugs todo
ok('{' ~~ m/(<[\{]>)/, 'quoted open LCB match');
#?pugs todo
is($0, '{', 'quoted open LCB capture');
#?pugs todo
ok('}' ~~ m/(<[\}]>)/, 'quoted close LCB match');
#?pugs todo
is($0, '}', 'quoted close LCB capture');

# RT #67124
#?rakudo todo 'comment in charset (RT #67124)'
eval_lives_ok( '"foo" ~~ /<[f] #`[comment] + [o]>/',
'comment embedded in charset can be parsed' );
#?rakudo skip 'comment in charset (RT #67124)'
#?pugs todo
ok( "foo" ~~ /<[f] #`[comment] + [o]>/, 'comment embedded in charset works' );

# RT #67122
#?rakudo skip 'large \\x char spec in regex (RT #67122) (noauto)'
#?pugs todo
ok "\x[10001]" ~~ /<[\x10000..\xEFFFF]>/, 'large \\x char spec';

#?niecza todo
#?pugs todo
eval_dies_ok( "'RT 71702' ~~ /<[d..b]>? RT/",
'reverse range in charset is lethal (RT 71702)' );

# RT #64220
#?pugs todo
ok 'b' ~~ /<[. .. b]>/, 'weird char class matches at least its end point';

# RT #69682
#?pugs todo
{
try { eval "/<[a-z]>/"; }
ok ~$! ~~ / 'Unsupported use of - as character range; in Perl 6 please use ..'/,
"STD error message for - as character range";
}

#?pugs todo
ok 'ab' ~~ /^(.*) b/,
'Quantifiers in capture groups work (RT 100650)';

# RT #74012
# backslashed characters in char classes
#?pugs todo
ok '[]\\' ~~ /^ <[ \[ .. \] ]>+ $ /, 'backslashed chars in char classes';
nok '^' ~~ / <[ \[ .. \] ]> /, '... does not match outside its range';

# RT #89470
{
nok '' ~~ / <[a..z]-[x]> /, 'Can match empty string against char class';
nok 'x' ~~ / <[a..z]-[x]> /, 'char excluded from class';
#?pugs todo
ok 'z' ~~ / <[a..z]-[x]> /, '... but others are fine';
}

Expand Down
6 changes: 6 additions & 0 deletions S05-metasyntax/prior.t
Expand Up @@ -20,17 +20,23 @@ plan 11;

ok("A" !~~ m/<.prior>/, 'No prior successful match');

#?pugs todo
ok("A" ~~ m/<[A..Z]>/, 'Successful match');

#?pugs todo
ok("ABC" ~~ m/<.prior>/, 'Prior successful match');
ok("B" !~~ m/<.prior>/, 'Prior successful non-match');

ok("C" !~~ m/B/, 'Unsuccessful match');

#?pugs todo
ok("A" ~~ m/<.prior>/, 'Still prior successful match');
#?pugs todo
ok("A" ~~ m/<.prior>/, 'And still prior successful match');

#?pugs todo
ok("BA" ~~ m/B <.prior>/, 'Nested prior successful match');
#?pugs todo
is ~$/, 'BA', 'matched all we wanted';

# now the prior match is "BA"
Expand Down
17 changes: 17 additions & 0 deletions S09-hashes/objecthash.t
Expand Up @@ -10,15 +10,18 @@ plan 25;
my %h{Any};
%h{$a} = 'blubb';
is %h{$a}, 'blubb', 'Any-typed hash access (+)';
#?pugs todo
nok %h{A.new}, 'and the hash really uses ===-semantics';
dies_ok { %h{Mu.new} = 3 }, 'Any-typed hash does not like Mu keys';
#?pugs todo
ok %h.keys[0] === $a, 'returned key is correct';
}

{
my %h{Int};
%h{2} = 3;
is %h{1 + 1}, 3, 'value-type semantics';
#?pugs todo
dies_ok { %h{'foo'} }, 'non-conformant type dies';
}

Expand All @@ -27,23 +30,36 @@ plan 25;
my Int %h{Rat};
%h{0.5} = 1;
%h{0.3} = 2;
#?pugs todo
dies_ok { %h{2} = 3 }, 'key type mismatch';
#?pugs todo
dies_ok { %h{0.5} = 0.2 }, 'value type mismatch';
#?pugs todo
dies_ok { %h{2} = 0.5 }, 'key and value type mismatch';
#?pugs todo
is %h.keys.sort.join(','), '0.3,0.5', '.keys';
#?pugs todo
is ~%h.values.sort, '1 2', '.values';
#?pugs skip 'flat'
isa_ok %h.kv.flat[0], Rat, '.kv types (1)';
#?pugs skip 'flat'
isa_ok %h.kv.flat[1], Int, '.kv types (2)';
#?pugs todo
isa_ok %h.pairs[0].key, Rat, '.pairs.key type';
isa_ok %h.pairs[0].value, Int, '.pairs.value type';
#?pugs todo
is %h.elems, 2, '.elems';
lives_ok { %h{0.2} := 3 }, 'binding to typed objecthash elements';
#?pugs todo
is %h.elems, 3, 'updated .elems';
#?pugs todo
dies_ok { %h{ 3 } := 3 }, 'binding key type check failure';
#?pugs todo
dies_ok { %h{0.2} := 'a' }, 'binding value type check failure';
#?rakudo todo '%h.push on typed hashes'
dies_ok { %h.push: 0.5 => 2 },
'Hash.push fails when the resulting array conflicts with the type check';
#?pugs todo
lives_ok { %h.push: 0.9 => 3 }, 'Hash.push without array creation is OK';
dies_ok { %h.push: 1 => 3 }, 'Hash.push key type check failure';
dies_ok { %h.push: 1.1 => 0.2 }, 'Hash.push value type check failure';
Expand All @@ -52,5 +68,6 @@ plan 25;
{
my %h{Any};
%h = 1, 2;
#?pugs todo
ok %h.keys[0] === 1, 'list assignment + object hashes';
}
3 changes: 3 additions & 0 deletions S12-class/lexical.t
Expand Up @@ -17,6 +17,7 @@ eval_lives_ok '{ my class B {} }; { my class B {} }',
'declare classes with the same name in two scopes.';
eval_lives_ok '{ my class B {}; B.new; }',
'can instantiate lexical class';
#?pugs todo
eval_dies_ok '{ my class B {}; B.new; }; B.new',
'scope is correctly restricted';

Expand All @@ -29,6 +30,7 @@ eval_dies_ok '{ my class B {}; B.new; }; B.new',
ok $pint ~~ WeissBier, 'can smart-match against lexical class';
is $pint.name, 'Erdinger', 'attribute in lexical class works';
is $pint.describe, 'outstanding flavour', 'method call on lexical class works';
#?pugs skip 'gist'
is WeissBier.gist, 'WeissBier()', 'lexical type object stringifies correct';

my class LessThanAmazingWeissBier is WeissBier {
Expand All @@ -43,6 +45,7 @@ eval_dies_ok '{ my class B {}; B.new; }; B.new',
}

# RT #69316
#?pugs skip 'bless'
{
class Forest {
class Frog {
Expand Down
2 changes: 2 additions & 0 deletions S28-named-variables/inc.t
Expand Up @@ -16,7 +16,9 @@ my $number_in_inc = +@*INC;
push @*INC, 'test';
is(+@*INC, $number_in_inc + 1, 'we added something to @INC');

#?pugs emit # cannot pop scalar
pop @*INC;
#?pugs skip 'cannot pop scalar'
is(+@*INC, $number_in_inc, 'we removed something from @INC');

lives_ok { @*INC = <a b c> }, 'Can assign to @*INC';
Expand Down
23 changes: 22 additions & 1 deletion S32-list/join.t
Expand Up @@ -6,6 +6,7 @@ plan 34;

# test all variants of join()

#?pugs skip 'empty join NYI'
is join(), '', 'empty join is empty string (sub)';
is ().join, '', 'empty join is empty string (method)';

Expand All @@ -16,12 +17,15 @@ my @list = ("a", "b", "c");
is(@list.join("|"), "a|b|c", '@list.join("|") works');

my $joined2 = join("|", @list);
#?pugs todo
is($joined2, "a|b|c", 'join("|", @list) works');

my $joined3 = join("|", "a", "b", "c");
#?pugs todo
is($joined3, "a|b|c", 'join("|", 1, 2, 3) works');

my $joined4 = join("|", [ "a", "b", "c" ]);
#?pugs todo
is($joined4, "a b c", 'join("|", []) should not join anything');

# join() without a separator (defaults to '', per S32)
Expand All @@ -36,32 +40,41 @@ is(["a", "b", "c"].join($sep), "a, b, c", '[].join($sep) works');
is(@list.join($sep), "a, b, c", '@list.join($sep) works');

my $joined2a = join($sep, @list);
#?pugs todo
is($joined2a, "a, b, c", 'join($sep, @list) works');

my $joined3a = join($sep, "a", "b", "c");
#?pugs todo
is($joined3a, "a, b, c", 'join($sep, "a", "b", "c") works');

my $joined4a = join($sep, [ "a", "b", "c" ]);
#?pugs todo
is($joined4a, "a b c", 'join($sep, []) works');

# join ... without parens

my $joined2b = join $sep, @list;
#?pugs todo
is($joined2b, "a, b, c", 'join $sep, @list works');

my $joined2c = join ":", @list;
#?pugs todo
is($joined2c, "a:b:c", 'join ":", @list works');

my $joined3b = join $sep, "a", "b", "c";
#?pugs todo
is($joined3b, "a, b, c", 'join $sep, "a", "b", "c" works');

my $joined3c = join ":", "a", "b", "c";
#?pugs todo
is($joined3c, "a:b:c", 'join(":", "a", "b", "c") works');

my $joined4b = join $sep, [ "a", "b", "c" ];
#?pugs todo
is($joined4b, "a b c", 'join $sep, [] should not join anything');

my $joined4c = join ":", [ "a", "b", "c" ];
#?pugs todo
is($joined4c, "a b c", 'join ":", [] should not join anything');

# join() with empty string as separator
Expand All @@ -73,12 +86,15 @@ is(["a", "b", "c"].join(''), "abc", '[].join("") works');
is(@list.join(''), "abc", '@list.join("") works');

my $joined2d = join('', @list);
#?pugs todo
is($joined2d, "abc", 'join("", @list) works');

my $joined3d = join('', "a", "b", "c");
#?pugs todo
is($joined3d, "abc", 'join("", 1, 2, 3) works');

my $joined4d = join("", [ "a", "b", "c" ]);
#?pugs todo
is($joined4d, "a b c", 'join("", []) works');

# some odd edge cases
Expand All @@ -87,11 +103,15 @@ my $undefined;
my @odd_list1 = (1, $undefined, 2, $undefined, 3);

my $joined2e = join(':', @odd_list1);
#?pugs todo
is($joined2e, "1::2::3", 'join(":", @odd_list1) works');

#?pugs emit # Mu
my @odd_list2 = (1, Mu, 2, Mu, 3);

#?pugs emit # Mu
my $joined2f = join(':', @odd_list2);
#?pugs skip 'Mu'
is($joined2f, "1::2::3", 'join(":", @odd_list2) works');

# should these even be tests ???
Expand All @@ -105,7 +125,9 @@ is($joined1, "a|b|c", '().join("|") should dwim');
my $joined1a = ("a", "b", "c").join($sep);
is($joined1a, "a, b, c", '().join($sep) should dwim');

#?pugs todo
is(join("!", "hi"), "hi", "&join works with one-element lists (1)");
#?pugs todo
is(join("!", <hi>), "hi", "&join works with one-element lists (2)");
is(("hi",).join("!"), "hi", "&join works with one-element lists (3)");

Expand Down Expand Up @@ -138,7 +160,6 @@ is(("hi",).join("!"), "hi", "&join works with one-element lists (3)");
##
## I want the result to be 'str'.

#?pugs todo 'bug'
is('hi'.join(':'), 'hi', '"foo".join(":") should be the same as join(":", "foo")');
is(('hi').join(':'), 'hi', '("foo").join(":") should be the same as join(":", "foo")');

Expand Down

0 comments on commit e33900b

Please sign in to comment.