Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[t/spec] begin cleansing of eval and todos that should skip
git-svn-id: http://svn.pugscode.org/pugs@27987 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information
kyle committed Aug 14, 2009
1 parent 83d098b commit ea4d235
Show file tree
Hide file tree
Showing 19 changed files with 46 additions and 84 deletions.
12 changes: 1 addition & 11 deletions S02-builtin_data_types/enum.t
Expand Up @@ -2,7 +2,7 @@ use v6;

use Test;

plan 40;
plan 35;
# L<S12/Enums>
{
my %hash; eval '%hash = enum «:Mon(1) Tue Wed Thu Fri Sat Sun»';
Expand Down Expand Up @@ -111,32 +111,22 @@ is %hash.values, (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'A', 'B', 'C', 'D', 'E', 'F'), '
# RT #63826
{
class EnumClass { enum C <a b c> }
#?rakudo todo 'RT #63826'
lives_ok { EnumClass::C::a }, 'can refer to enum element in class';
#?rakudo skip 'RT #63826'
is EnumClass::C::a, 0, 'enum element in class has the right value';

module EnumModule { enum M <a b c> }
#?rakudo todo 'RT #63826'
lives_ok { EnumModule::M::a }, 'can refer to enum element in module';
#?rakudo skip 'RT #63826'
is EnumModule::M::b, 1, 'enum element in module has the right value';

package EnumPackage { enum P <a b c> }
#?rakudo todo 'RT #63826'
lives_ok { EnumPackage::P::a }, 'can refer to enum element in package';
#?rakudo skip 'RT #63826'
is EnumPackage::P::c, 2, 'enum element in package has the right value';

role EnumRole { enum R <a b c> }
#?rakudo todo 'RT #63826'
lives_ok { EnumRole::R::a }, 'can refer to enum element in role';
#?rakudo skip 'RT #63826'
is EnumRole::R::a, 0, 'enum element in role has the right value';

grammar EnumGrammar { enum G <a b c> }
#?rakudo todo 'RT #63826'
lives_ok { EnumGrammar::G::a }, 'can refer to enum element in grammar';
#?rakudo skip 'RT #63826'
is EnumGrammar::G::b, 1, 'enum element in grammar has the right value';
}
Expand Down
6 changes: 3 additions & 3 deletions S03-operators/inplace.t
Expand Up @@ -4,7 +4,7 @@ use Test;

# L<S03/Assignment operators/A op= B>

plan 24;
plan 22;

#?rakudo skip '.= with spaces'
{
Expand Down Expand Up @@ -68,10 +68,10 @@ is ~@b, "a b d e z", "inplace sort";
my @b = @a.sort: {1};
is @b, @a_orig, 'worked: @a.sort: {1}';

lives_ok { @a.=sort: {1} }, 'lives: @a.=sort: {1}';
@a.=sort: {1};
is @a, @a_orig, 'worked: @a.=sort: {1}';

lives_ok { @a.=sort }, 'lives: @a.=sort';
@a.=sort;
is @a, (1,2,3), 'worked: @a.=sort';
}

Expand Down
4 changes: 1 addition & 3 deletions S03-operators/misc.t
Expand Up @@ -7,7 +7,7 @@ use Test;
Tests for Synopsis 3
=end kwid

plan 62;
plan 61;

my $str1 = "foo";
my $str2 = "bar";
Expand Down Expand Up @@ -162,8 +162,6 @@ ok(?(42 > 12 & 20 & 32), "test the all infix operator");
# RT #63778
{
my @a = 1, 2, 3;
#?rakudo todo 'RT #63778'
lives_ok { @a min 4 }, 'lives: @array min 4';
#?rakudo skip 'RT #63778'
is @a min 4, 1, 'works: @array min 4';
}
Expand Down
4 changes: 2 additions & 2 deletions S03-operators/smartmatch.t
Expand Up @@ -410,7 +410,7 @@ ok NaN ~~ NaN, 'NaN ~~ NaN is True';

# need to test in eval() since class defintions happen at compile time,
# ie before the plan is set up.
eval_lives_ok 'class A { method foo { diag "" ~~ * } }; A.new.foo',
'smartmatch in a class lives (RT #62196)';
eval_lives_ok 'class A { method foo { return "" ~~ * } }; A.new.foo',
'smartmatch in a class lives (RT 62196)';

# vim: ft=perl6
2 changes: 1 addition & 1 deletion S03-operators/ternary.t
Expand Up @@ -67,6 +67,6 @@ is((4 or 5 ?? 6 !! 7), 4, "operator priority");
is($foo, "yay", "defining a postfix<!> doesn't screw up ternary op");
}

eval_dies_ok q[ 1 ?? 2,3 !! 4,5 ], 'Ternary error (RT #66840)';
eval_dies_ok q[ 1 ?? 2,3 !! 4,5 ], 'Ternary error (RT 66840)';

# vim: ft=perl6
6 changes: 3 additions & 3 deletions S04-declarations/state.t
Expand Up @@ -273,9 +273,9 @@ plan 37;
# Test for RT #67058
sub bughunt1 { (state $svar) }
{
sub bughunt2 { state $x //= 17; $x++ }
lives_ok { bughunt2() },
'a state variable in parens lives with a state variable with //= init';
sub bughunt2 { state $x //= 17; ++$x }
is bughunt2(), 18,
'a state variable in parens works with a state variable with //= init';
}

# vim: ft=perl6
2 changes: 2 additions & 0 deletions S04-statement-modifiers/for.t
Expand Up @@ -86,6 +86,8 @@ plan 14;

eval 'say for 1';
ok $! ~~ Exception, '"say for 1" (two spaces) is an error';
# XXX The problem with this test is the error messages might differ
# for innocuous reasons (e.g., a line number)
#?rakudo 2 todo 'RT #61494'
is "$!", $errmsg, 'error for two spaces is the same as one space';
ok "$!" ~~ /\b say \b/, 'error message is for "say"';
Expand Down
8 changes: 4 additions & 4 deletions S04-statements/try.t
Expand Up @@ -4,7 +4,7 @@ use Test;

# L<S04/"Statement parsing"/"or try {...}">

plan 29;
plan 28;

{
# simple try
Expand Down Expand Up @@ -197,9 +197,9 @@ plan 29;
CATCH { return 73313 if ! $catches++; }
}
}
lives_ok { rt63430() }, 'can call rt63430()';
#?rakudo todo 'Null PMC access'
lives_ok { rt63430().perl }, 'can call rt63430() and examine the result';

#?rakudo skip 'Null PMC access'
is rt63430().perl, 63430.perl, 'can call rt63430() and examine the result';
#?rakudo skip 'Null PMC access in type()'
is rt63430(), 63430, 'CATCH does not intercept return from try block';
#?rakudo todo 'RT #63430'
Expand Down
4 changes: 1 addition & 3 deletions S05-interpolation/regex-in-variable.t
Expand Up @@ -8,7 +8,7 @@ version 0.3 (12 Apr 2004), file t/patvar.t.
=end pod

plan 15;
plan 14;

# L<S05/Variable (non-)interpolation>

Expand All @@ -30,8 +30,6 @@ ok("aaaaab" ~~ m/<{$var}>/, 'Rulish scalar match');
# RT #61960
{
my $a = 'a';
#?rakudo todo 'Null PMC access in get_string()'
lives_ok { 'a' ~~ / $a / }, 'can match with a string as a rx';
#?rakudo skip 'Null PMC access in get_string()'
ok 'a' ~~ / $a /, 'match with string as rx works';
}
Expand Down
2 changes: 1 addition & 1 deletion S05-metasyntax/charset.t
Expand Up @@ -58,7 +58,7 @@ ok( "foo" ~~ /<[f] #`[comment] + [o]>/, 'comment embedded in charset works' );

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

}

Expand Down
13 changes: 4 additions & 9 deletions S05-metasyntax/regex.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 27;
plan 26;

# L<S05/Regexes are now first-class language, not strings>

Expand Down Expand Up @@ -70,20 +70,15 @@ lives_ok { my Regex $x = rx/foo/ }, 'Can store regexes in typed variables';
ok 'mmm, pasta' ~~ m/<food>/, 'named rule outside of a grammar works';
}

# RT #67234
{
#?rakudo todo 'RT #67234'
lives_ok { undef ~~ / x / }, 'match against undef lives';
#?rakudo skip 'RT #67234'
ok not undef ~~ / x /, 'match against undef does not match';
}
#?rakudo skip 'RT #67234'
ok not undef ~~ / 'RT #67234' /, 'match against undef does not match';

#?rakudo todo 'RT #67612'
eval_dies_ok q['x' ~~ m/RT (#)67612 /], 'commented capture end = parse error';

# L<S05/Simplified lexical parsing of patterns/The semicolon character>

eval_dies_ok 'rx/;/', 'bare ";" is rx is not allowed';
eval_dies_ok 'rx/;/', 'bare ";" in rx is not allowed';
eval_dies_ok q{';' ~~ /;/}, 'bare ";" in match is not allowed';
isa_ok rx/\;/, Regex, 'escaped ";" in rx// works';
ok ';' ~~ /\;/, 'escaped ";" in m// works';
Expand Down
21 changes: 6 additions & 15 deletions S06-advanced_subroutine_features/return.t
Expand Up @@ -15,7 +15,7 @@ See also t/blocks/return.t, which overlaps in scope.
# reference for the spec for 'return', but I couldn't find
# one either.

plan 77;
plan 73;

# These test the returning of values from a subroutine.
# We test each data-type with 4 different styles of return.
Expand Down Expand Up @@ -301,24 +301,15 @@ is Foo::official(), 44,

# RT #61732
{
eval_lives_ok 'sub rt61732_a { 1;; }', 'parse sub { 1;; }';
eval_lives_ok 'sub rt61732_b { 1; CATCH {} }', 'parse sub { 1; CATCH {} }';
}
#?rakudo todo 'RT #61732'
{
my $x;

sub rt61732_c { 1; CATCH {} }
lives_ok { $x = rt61732_c() }, 'can call sub ending with empty CATCH';
is $x, 1, 'sub with empty catch block returns last value before block';
#?rakudo skip 'RT #61732'
is rt61732_c(), 1, 'sub with empty catch block returns value before block';
}
#?rakudo todo 'RT #61732'
{
my $x;

{
sub rt61732_d { 1;; }
lives_ok { $x = rt61732_d() }, 'can call sub ending with double ;';
is $x, 1, 'get right value from sub with double ;';
#?rakudo skip 'RT #61732'
is rt61732_d(), 1, 'get right value from sub with double ;';
}

# RT #63912
Expand Down
5 changes: 2 additions & 3 deletions S12-construction/BUILD.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 8;
plan 7;

# L<S12/Construction and Initialization/The default BUILD and BUILDALL>

Expand Down Expand Up @@ -78,8 +78,7 @@ is $obj.gather, 'Parent(a): (7) | Child(a, b): (7, 5)',
class RT63900_C is RT63900_P {
}

my $c;
lives_ok { $c = RT63900_C.new() }, 'can create child class';
my $c = RT63900_C.new();
is $c.counter<BUILD>, 1, 'BUILD called once';
}

Expand Down
5 changes: 2 additions & 3 deletions S12-construction/construction.t
Expand Up @@ -2,7 +2,7 @@ use v6;

use Test;

plan 15;
plan 14;

# L<S12/"Construction and Initialization">

Expand Down Expand Up @@ -70,9 +70,8 @@ is Foo.new("a string").a, 'a string', "our own 'new' was called";
{
class RT64116 { has %.env is rw };

my $a;
my $a = RT64116.CREATE;

lives_ok { $a = RT64116.CREATE }, 'can .CREATE class';
lives_ok { $a.env = { foo => "bar" } }, 'assign to attr of .CREATEd class';
is $a.env<foo>, 'bar', 'assignment works';
}
Expand Down
16 changes: 5 additions & 11 deletions S12-methods/multi.t
Expand Up @@ -2,7 +2,7 @@ use v6;

use Test;

plan 20;
plan 16;

# L<S12/"Multisubs and Multimethods">
# L<S12/"Multi dispatch">
Expand Down Expand Up @@ -75,10 +75,8 @@ is Bar.new.a("not an Int"), 'Any-method in Foo';
# RT #67024
#?rakudo todo 'redefintion of non-multi method (RT #67024)'
{
my $bad_code = 'class A { method a(){0}; method a($x){1} }';

eval_dies_ok $bad_code, 'redefintion of non-multi method (RT 67024)';
eval $bad_code;
eval 'class A { method a(){0}; method a($x){1} }';
ok $! ~~ Exception, 'redefintion of non-multi method (RT 67024)';
ok "$!" ~~ /multi/, 'error message mentions multi-ness';
}

Expand All @@ -91,9 +89,7 @@ is Bar.new.a("not an Int"), 'Any-method in Foo';
multi method b() { @.order.push( 'class' ); nextsame }
}

my $c;
lives_ok { $c = C3.new }, 'can create class C3';
isa_ok $c, C3;
my $c = C3.new;
lives_ok { $c.b }, 'can call multi-method from class with role';

is $c.order, <class role>, 'call order is correct for class and role'
Expand All @@ -110,9 +106,7 @@ is Bar.new.a("not an Int"), 'Any-method in Foo';
class C4 is P4 does R4 {
multi method b() { @.order.push( 'class' ); nextsame }
}
my $c;
lives_ok { $c = C4.new }, 'can create class C4';
isa_ok $c, C4;
my $c = C4.new;
lives_ok { $c.b }, 'call multi-method from class with parent and role';

is $c.order, <class role parent>,
Expand Down
3 changes: 1 addition & 2 deletions S12-methods/what.t
Expand Up @@ -12,7 +12,7 @@ This test tests the C<WHAT> builtin.

# L<S12/Introspection/"WHAT">

plan 16;
plan 15;

# Basic subroutine/method form tests for C<WHAT>.
{
Expand Down Expand Up @@ -64,7 +64,6 @@ plan 16;

# RT #66928
{
lives_ok { &infix:<+>.WHAT }, 'Can .WHAT built-in infix op';
ok &infix:<+>.WHAT ~~ Multi, '.WHAT of built-in infix op is Multi';
}

Expand Down
9 changes: 4 additions & 5 deletions S29-context/eval.t
@@ -1,6 +1,6 @@
use v6;
use Test;
plan 17;
plan 16;

# L<S29/Context/"=item eval">

Expand Down Expand Up @@ -66,11 +66,10 @@ dies_ok({eval {42}}, 'block eval is gone');
is eval("'møp'".encode('UTF-8')), 'møp', 'eval(Buf)';

{
#?rakudo todo 'eval coerce to string'
lives_ok { eval 1 }, 'eval of non-string lives';
#?rakudo skip 'eval coerce to string'
is eval 88, 88, 'eval of non-string works';

my $number = 2;
#?rakudo todo 'eval coerce to string'
lives_ok { eval $number }, 'eval of non-string variable lives';
#?rakudo skip 'eval coerce to string'
is eval $number, $number, 'eval of non-string variable works';
}
Expand Down
4 changes: 1 addition & 3 deletions S29-conversions/ord_and_chr.t
Expand Up @@ -121,7 +121,7 @@ my @maps = (
"\o03", 3,
);

plan 38+@maps*2;
plan 37+@maps*2;

for @maps -> $char, $code {
my $descr = "\\{$code}{$code >= 32 ?? " == '{$char}'" !! ""}";
Expand Down Expand Up @@ -149,8 +149,6 @@ is 65.chr, 'A', "there's a .chr method";
is ord('hello'), [104, 101, 108, 108, 111], 'ord works with longer strings';
is chr(104, 101, 108, 108, 111), 'hello', 'chr works with a list of ints';

#?rakudo todo 'RT #62772'
lives_ok { ord("") }, 'ord("") lives';
#?rakudo skip 'RT #62772'
ok ord("") ~~ Failure, 'ord("") returns a Failure';

Expand Down
4 changes: 2 additions & 2 deletions S32-array/delete.t
Expand Up @@ -100,8 +100,8 @@ Basic C<delete> tests, see S32.
# RT #67446
{
my @array = 0..1;
lives_ok { @array.perl }, '@array.perl lives after init';
lives_ok { map { 1 }, @array }, 'map @array lives after init';
is ~(eval @array.perl ), '0 1', '@array.perl works after init';
is ~( map { 1 }, @array ), '1 1', 'map @array works after init';
@array.delete(0);
#?rakudo 2 todo 'RT #67446'
lives_ok { @array.perl }, '@array.perl lives after delete';
Expand Down

0 comments on commit ea4d235

Please sign in to comment.