Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
utilize does-ok test assertion
  • Loading branch information
dwarring committed Aug 25, 2015
1 parent 7e0c2b0 commit e960b57
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 34 deletions.
18 changes: 9 additions & 9 deletions S02-types/hash.t
Expand Up @@ -8,7 +8,7 @@ plan 95;
# L<S09/Hashes>

my %hash1;
ok(%hash1.does(Hash), '%hash1 does Hash');
does-ok %hash1, Hash, '%hash1 does Hash';
%hash1{"one"} = 5;
is(%hash1{"one"}, 5, 'lvalue hash assignment works (w/ double quoted keys)');

Expand All @@ -21,19 +21,19 @@ is(%hash1<three>, 3, 'lvalue hash assignment works (w/ unquoted style <key>)');
# basic hash creation w/ comma separated key/values

my %hash2 = ("one", 1);
ok(%hash2.does(Hash), '%hash2 does Hash');
does-ok %hash2, Hash, '%hash2 does Hash';
is(%hash2{"one"}, 1, 'comma separated key/value hash creation works');
is(%hash2<one>, 1, 'unquoted <key> fetching works');

my %hash3 = ("one", 1, "two", 2);
ok(%hash3.does(Hash), '%hash3 does Hash');
does-ok %hash3, Hash, '%hash3 does Hash';
is(%hash3{"one"}, 1, 'comma separated key/value hash creation works with more than one pair');
is(%hash3{"two"}, 2, 'comma separated key/value hash creation works with more than one pair');

# basic hash creation w/ => separated key/values (pairs?)

my %hash4;
ok(%hash4.does(Hash), '%hash4 does Hash');
does-ok %hash4, Hash, '%hash4 does Hash';
%hash4 = ("key" => "value");
is(%hash4{"key"}, 'value', '(key => value) separated key/value has creation works');

Expand All @@ -46,7 +46,7 @@ is( (map { .WHAT.gist } , %flattens).join(' ') , Pair.gist ~ ' ' ~ Pair.gist, 'F
# hash slicing

my %hash5 = ("one", 1, "two", 2, "three", 3);
ok(%hash5.does(Hash), '%hash5 does Hash');
does-ok %hash5, Hash, '%hash5 does Hash';

{
my @slice1 = %hash5{"one", "three"};
Expand Down Expand Up @@ -87,7 +87,7 @@ ok(%hash5.does(Hash), '%hash5 does Hash');
# keys

my %hash6 = ("one", 1, "two", 2, "three", 3);
ok(%hash6.does(Hash), '%hash6 does Hash');
does-ok %hash6, Hash, '%hash6 does Hash';

my @keys1 = (keys %hash6).sort;
is(+@keys1, 3, 'got the right number of keys');
Expand All @@ -104,7 +104,7 @@ is(@keys2[2], 'two', 'got the right key');
# values

my %hash7 = ("one", 1, "two", 2, "three", 3);
ok(%hash7.does(Hash), '%hash7 does Hash');
does-ok %hash7, Hash, '%hash7 does Hash';

my @values1 = (values %hash7).sort;
is(+@values1, 3, 'got the right number of values');
Expand All @@ -121,7 +121,7 @@ is(@values1[2], 3, 'got the right values');
# misc stuff ...

my %hash8;
ok(%hash8.does(Hash), '%hash8 does Hash');
does-ok %hash8, Hash, '%hash8 does Hash';
%hash8 = (:one, :key<value>, :three(3));
ok(%hash8{'one'} === True, 'colonpair :one');
is(%hash8{'key'}, 'value', 'colonpair :key<value>');
Expand All @@ -133,7 +133,7 @@ my $key;
my $val;

my %hash9;
ok(%hash9.does(Hash), '%hash9 does Hash');
does-ok %hash9, Hash, '%hash9 does Hash';
%hash9{1} = 2;

for (%hash9.kv) -> $k,$v {
Expand Down
46 changes: 23 additions & 23 deletions S02-types/sigils-and-types.t
Expand Up @@ -13,65 +13,65 @@ ok $scalar ~~ Any, 'value contained in a $var does Mu';

{
my @array;
ok @array.does(Positional), 'unitialized @var does Positional';
does-ok @array, Positional, 'unitialized @var does Positional';
}
{
my @array = [];
ok @array.does(Positional), 'value contained in a @var does Positional';
does-ok @array, Positional, 'value contained in a @var does Positional';
}
{
my @array = 1;
ok @array.does(Positional), 'generic val in a @var is converted to Positional';
does-ok @array, Positional, 'generic val in a @var is converted to Positional';
}

ok EVAL('List').does(Positional), "List does Positional";
ok EVAL('Array').does(Positional), "Array does Positional";
ok EVAL('Range').does(Positional), "Range does Positional";
ok EVAL('Parcel').does(Positional), "Parcel does Positional";
does-ok EVAL('List'), Positional, "List does Positional";
does-ok EVAL('Array'), Positional, "Array does Positional";
does-ok EVAL('Range'), Positional, "Range does Positional";
does-ok EVAL('Parcel'), Positional, "Parcel does Positional";
#?niecza skip 'Undeclared name Buf'
ok EVAL('Buf').does(Positional), "Buf does Positional";
does-ok EVAL('Buf'), Positional, "Buf does Positional";
#?rakudo todo "Capture does Positional RT #124484"
ok EVAL('Capture').does(Positional), "Capture does Positional";
does-ok EVAL('Capture'), Positional, "Capture does Positional";

my %hash;
ok %hash.does(Associative), 'uninitialized %var does Associative';
does-ok %hash, Associative, 'uninitialized %var does Associative';
%hash = a => 1;
ok %hash.does(Associative), 'value in %var does Associative';
does-ok %hash, Associative, 'value in %var does Associative';

#?niecza todo
ok EVAL('Pair').does(Associative), "Pair does Associative";
ok EVAL('Set').does(Associative), "Set does Associative";
ok EVAL('Bag').does(Associative), "Bag does Associative";
does-ok EVAL('Pair'), Associative, "Pair does Associative";
does-ok EVAL('Set'), Associative, "Set does Associative";
does-ok EVAL('Bag'), Associative, "Bag does Associative";
#?niecza skip 'Undeclared name QuantHash'
ok EVAL('QuantHash').does(Associative), "QuantHash does Associative";
does-ok EVAL('QuantHash'), Associative, "QuantHash does Associative";
#?rakudo todo "Capture does Associative RT #124485"
ok EVAL('Capture').does(Associative), "Capture does Associative";
does-ok EVAL('Capture'), Associative, "Capture does Associative";


sub foo {}
ok &foo.does(Callable), 'a Sub does Callable';
does-ok &foo, Callable, 'a Sub does Callable';

#?niecza skip 'Methods must be used in some kind of package'
{
my method meth {}
ok &meth.does(Callable), 'a Method does Callable';
does-ok &meth, Callable, 'a Method does Callable';
}
proto mul(|) {*}
multi mul {}
ok &mul.does(Callable), 'a multi does Callable';
does-ok &mul, Callable, 'a multi does Callable';
proto pro {}
ok &pro.does(Callable), 'a proto does Callable';
does-ok &pro, Callable, 'a proto does Callable';

# &token, &rule return a Method?
#?niecza skip 'Methods must be used in some kind of package'
{
my token bar {<?>}
ok &bar.does(Callable), 'a token does Callable';
does-ok &bar, Callable, 'a token does Callable';
my rule baz {<?>}
ok &baz.does(Callable), 'a rule does Callable';
does-ok &baz, Callable, 'a rule does Callable';
# &quux returns a Sub ?
macro quux {}
ok &quux.does(Callable), 'a macro does Callable';
does-ok &quux, Callable, 'a macro does Callable';
}

# RT 69318
Expand Down
4 changes: 2 additions & 2 deletions S12-enums/thorough.t
Expand Up @@ -22,7 +22,7 @@ ok day.perl, 'enum.perl returned a value';
#?DOES 12
sub test_stuff($x) {
#?niecza skip 'No candidates for dispatch to infix:<does>'
ok $x.does(day::Tue), "basic enum mixing worked ($x-2)";
does-ok $x, day::Tue, "basic enum mixing worked ($x-2)";
is $x.day, 2, "automatically created accessor worked ($x)";
is day::Tue, 2, "enum provided a correct mapping ($x)";
ok $x ~~ day, "smartmatch worked correctly ($x-1)";
Expand All @@ -32,7 +32,7 @@ sub test_stuff($x) {
#?niecza skip 'No candidates for dispatch to infix:<does>'
ok $x.does(Tue), ".does worked correctly ($x-1)";
#?niecza skip 'No candidates for dispatch to infix:<does>'
ok $x.does(day), ".does worked correctly ($x-2)";
does-ok $x, day, ".does worked correctly ($x-2)";
ok $x.Tue, ".Tue() worked correctly ($x)";
ok $x.Tue.WHAT === day, '$obj.Tue.WHAT returns the proper type object';
ok $x.Tue.perl, '$obj.Tue.perl returns a true valuee';
Expand Down
1 change: 1 addition & 0 deletions fudge
Expand Up @@ -125,6 +125,7 @@ my $IS = _register_functions( # regex with test functions used in roast
qw(
cmp_ok cmp-ok
dies_ok dies-ok
does-ok
eval_dies_ok eval-dies-ok
eval_lives_ok eval-lives-ok
flunk
Expand Down

0 comments on commit e960b57

Please sign in to comment.