Skip to content

Commit

Permalink
Merge pull request #455 from perl6/post-release-2018.07
Browse files Browse the repository at this point in the history
Post release 2018.07
  • Loading branch information
zoffixznet committed Jul 27, 2018
2 parents 8afb8fb + a945d7a commit f5454af
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 44 deletions.
7 changes: 4 additions & 3 deletions S02-types/mu.t
Expand Up @@ -13,21 +13,22 @@ plan 8;

subtest 'Mu:U.self is identity' => {
plan 2;
is-deeply Mu.self.^name, 'Mu', 'got Mu';
cmp-ok Mu.self, '=:=', Mu, 'got self';
is-deeply Mu.self.defined, Bool::False, 'not .defined';
}

subtest 'Mu:D.self is identity' => {
plan 2;
is-deeply Mu.new.self.^name, 'Mu', 'got Mu';
my \v := Mu.new;
cmp-ok v.self, '=:=', v, 'got self';
is-deeply Mu.new.self.defined, Bool::True, 'is .defined';
}

subtest 'Mu.return-rw' => {
plan 3;

sub rrw { my Mu $x; $x.return-rw }();
is-deeply rrw.^name, 'Mu', 'got Mu';
cmp-ok rrw.WHAT, '=:=', Mu, 'got Mu';
is-deeply rrw.defined, Bool::False, 'not .defined';
lives-ok { rrw() = 42; }, 'can assign to returned value';
}
Expand Down
8 changes: 5 additions & 3 deletions S02-types/num.t
Expand Up @@ -402,25 +402,27 @@ ok Num === Num, 'Num === Num should be truthy, and not die';
}

subtest 'log(num)' => sub {
plan 8;
plan 9;
cmp-ok log(my num $ ), '===', NaN, 'uninitialized';
cmp-ok log(my num $ = NaN ), '===', NaN, 'NaN';
cmp-ok log(my num $ = -42e0), '===', NaN, 'negative';
cmp-ok log(my num $ = -∞), '===', NaN, '-∞';
is-deeply log(my num $ = ∞), my num $ = ∞, '+∞';
is-deeply log(my num $ = 0e0), my num $ = -∞, 'zero';
is-deeply log(my num $ = -0e0), my num $ = -∞, 'neg zero';
is-deeply log(my num $ = 1e0), my num $ = 0e0, 'one';
is-approx log(my num $ = 42e0), my num $ = 3.74e0, '42',
:abs-tol(.01);
}

subtest 'ceiling(num)' => sub {
plan 9;
plan 10;
cmp-ok ceiling(my num $ ), '===', NaN, 'uninitialized';
cmp-ok ceiling(my num $ = NaN), '===', NaN, 'NaN';
is-deeply ceiling(my num $ = -∞), my num $ = -∞, '-∞';
is-deeply ceiling(my num $ = ∞), my num $ = ∞, '+∞';
is-deeply ceiling(my num $ = 0e0), my num $ = 0e0, 'zero';
is-deeply ceiling(my num $ = -0e0), my num $ = -0e0, 'neg zero';
is-deeply ceiling(my num $ = 4.7e0), my num $ = 5e0, 'positive (1)';
is-deeply ceiling(my num $ = 4.2e0), my num $ = 5e0, 'positive (2)';
is-deeply ceiling(my num $ = -4.7e0), my num $ = -4e0, 'negative (1)';
Expand Down Expand Up @@ -634,7 +636,7 @@ ok Num === Num, 'Num === Num should be truthy, and not die';
cmp-ok acotan(my num $ ), '===', NaN, 'uninitialized';
cmp-ok acotan(my num $ = NaN), '===', NaN, 'NaN';

is acotan(my num $ = -∞).Str, '-0', '-∞ is -0';
is-deeply acotan(my num $ = -∞), -0e0, '-∞ is -0';

is-approx acotan(my num $ = ∞), my num $ = 0e0, '';
is-approx acotan(my num $ = -∞), my num $ = -0e0, '-∞';
Expand Down
12 changes: 8 additions & 4 deletions S03-junctions/misc.t
Expand Up @@ -505,10 +505,14 @@ throws-like 'sub foo($) { }; foo(Junction)', X::TypeCheck::Binding,
subtest 'Junction.new' => { # coverage; 2016-10-11
plan 4;

is-deeply Junction.new([^3], :type<all> ).perl, ^3 .all.perl, 'all';
is-deeply Junction.new([^3], :type<one> ).perl, ^3 .one.perl, 'one';
is-deeply Junction.new([^3], :type<any> ).perl, ^3 .any.perl, 'any';
is-deeply Junction.new([^3], :type<none>).perl, ^3 .none.perl, 'none';
is-deeply-junction Junction.new([^3], :type<all> ),
^3 .all, 'all';
is-deeply-junction Junction.new([^3], :type<one> ),
^3 .one, 'one';
is-deeply-junction Junction.new([^3], :type<any> ),
^3 .any, 'any';
is-deeply-junction Junction.new([^3], :type<none>),
^3 .none, 'none';
}

# https://github.com/rakudo/rakudo/commit/aa3684218b1f668b6a6e41da
Expand Down
20 changes: 10 additions & 10 deletions S03-metaops/reduce.t
Expand Up @@ -128,12 +128,12 @@ L<"http://groups.google.de/group/perl.perl6.language/msg/bd9eb275d5da2eda">
# my $hash = {a => {b => {c => {d => 42, e => 23}}}};
# is try { [.{}] $hash, <a b c d> }, 42, '[.{}] works';
# }
#
#
# {
# my $hash = {a => {b => 42}};
# is ([.{}] $hash, <a b>), 42, '[.{}] works two levels deep';
# }
#
#
# {
# my $arr = [[[1,2,3],[4,5,6]],[[7,8,9],[10,11,12]]];
# is ([.[]] $arr, 1, 0, 2), 9, '[.[]] works';
Expand Down Expand Up @@ -185,14 +185,14 @@ lives-ok({my @foo = [>>+<<] ([1..3],[1..3],[1..3])},'Parse [>>+<<]');
# {
# my $arr = [ 42, [ 23 ] ];
# $arr[1][1] = $arr;
#
#
# is try { [.[]] $arr, 1, 1, 1, 1, 1, 0 }, 23, '[.[]] works with infinite data structures';
# }
#
#
# {
# my $hash = {a => {b => 42}};
# $hash<a><c> = $hash;
#
#
# is try { [.{}] $hash, <a c a c a b> }, 42, '[.{}] works with infinite data structures';
# }

Expand All @@ -212,7 +212,7 @@ is( ([<] 42), Bool::True, "[<] 42 returns true");
is( ~([\<] 42), ~True, "[\<] 42 returns '1'");
ok( ([\<] 42) ~~ Iterable, "[\<] 42 returns something Iterable");

is( ([\*] 1..*).[^10].join(', '), '1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800',
is( ([\*] 1..*).[^10].join(', '), '1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800',
'triangle reduce is lazy');

ok ([\*] 1..*).is-lazy, "triangle reduce knows if it's lazy";
Expand Down Expand Up @@ -678,10 +678,10 @@ is prefix:<[**]>(2,3,4), 2417851639229258349412352, "Reduce ** can autogen witho

# RT #128757
{
throws-like {[+] 'hello'}, X::Str::Numeric, '[+] with single non-numeric argument errors';
throws-like {[-] 'hello'}, X::Str::Numeric, '[-] with single non-numeric argument errors';
throws-like {[*] 'hello'}, X::Str::Numeric, '[*] with single non-numeric argument errors';
throws-like {[/] 'hello'}, X::Str::Numeric, '[/] with single non-numeric argument errors';
throws-like [+] 'hello', X::Str::Numeric, '[+] with single non-numeric argument errors';
throws-like [-] 'hello', X::Str::Numeric, '[-] with single non-numeric argument errors';
throws-like [*] 'hello', X::Str::Numeric, '[*] with single non-numeric argument errors';
throws-like [/] 'hello', X::Str::Numeric, '[/] with single non-numeric argument errors';
}

# RT #128758
Expand Down
1 change: 0 additions & 1 deletion S06-signature/types.t
Expand Up @@ -29,7 +29,6 @@ is-deeply .perl.EVAL, $_, ".perl on an {.perl} roundtrips"
{
sub rt123789 (int $x) { say $x };
throws-like { rt123789(Int) }, Exception,
message => /'Cannot unbox a type object'/,
'no segfault when calling a routine having a native parameter with a type object argument';
}

Expand Down
14 changes: 8 additions & 6 deletions S09-typed-arrays/hashes.t
Expand Up @@ -83,12 +83,14 @@ plan 44;
{ # coverage; 2016-10-04
my class Foo {};
my $o = Foo.new;
my %h{Any} = :42a, :72b, Foo, $o;
is-deeply set(%h.antipairs), set(42 => "a", 72 => "b", Pair.new: $o, Foo),
'.antipairs on typed Hash';

is-deeply set(%h.invert), set(42 => "a", 72 => "b", Pair.new: $o, Foo),
'.invert on typed Hash';
my %h{Any} = :42a, :72b, :c{:200bers, :100bars}, Foo, $o;
is-deeply %h.antipairs.sort, (42 => "a", 72 => "b", (Foo.new) => Foo,
({:bars(100), :bers(200)}) => "c").Seq.sort,
'.antipairs on typed Hash';

is-deeply %h.invert.sort, (42 => "a", 72 => "b",
(:bers(200)) => "c", (:bars(100)) => "c", (Foo.new) => Foo).Seq.sort,
'.invert on typed Hash';
}

# RT#130870
Expand Down
11 changes: 7 additions & 4 deletions S12-enums/basic.t
Expand Up @@ -141,21 +141,24 @@ subtest 'dynamically created lists can be used to define an enum' => {
}

{ # coverage; 2016-10-03
my enum Cover20161003 <foo-cover bar-cover>;
my enum Cover20161003 (|<foo-cover bar-cover>, fo2-cover => 0);
subtest 'Enumeration:D.kv' => {
plan 2;
plan 3;
is-deeply foo-cover.kv, ('foo-cover', 0), 'first element';
is-deeply bar-cover.kv, ('bar-cover', 1), 'second element';
is-deeply fo2-cover.kv, ('fo2-cover', 0), 'element with duped value';
}
subtest 'Enumeration:D.pair' => {
plan 2;
plan 3;
is-deeply foo-cover.pair, (foo-cover => 0), 'first element';
is-deeply bar-cover.pair, (bar-cover => 1), 'second element';
is-deeply fo2-cover.pair, (fo2-cover => 0), 'element with duped value';
}
subtest 'Enumeration:D.Int' => {
plan 2;
plan 3;
is-deeply foo-cover.Int, 0, 'first element';
is-deeply bar-cover.Int, 1, 'second element';
is-deeply fo2-cover.Int, 0, 'element with duped value';
}
}

Expand Down
4 changes: 3 additions & 1 deletion S32-hash/delete.t
@@ -1,7 +1,7 @@
use v6;

use Test;
plan 9;
plan 10;

# L<S02/Names and Variables/:delete>

Expand Down Expand Up @@ -44,6 +44,8 @@ ok !defined(%hash{"a"}), "deleted hash elements are really deleted";

{ # coverage; 2016-10-04
is-deeply Hash<z>:delete, Nil, ':delete on Hash:U returns Nil';
is-deeply Hash<a b>:delete, (Nil, Nil),
':delete of slice on Hash:U returns a list of Nils';
}

# vim: ft=perl6
3 changes: 2 additions & 1 deletion S32-hash/map.t
Expand Up @@ -21,7 +21,8 @@ plan 15;
'Map:D.Hash gives right hash';

is-deeply $map.Int, 3, 'Map.Int gives number of pairs';
is-deeply $map{42e0}, 'foo', 'Map{} with non-Str key gives right results';
is-deeply $map{42.0}, 'foo',
'Map{} with non-Str value in lookup stringifies it';

is-deeply $map.clone, $map, 'Map.clone is identity';
}
Expand Down
18 changes: 9 additions & 9 deletions S32-num/int.t
Expand Up @@ -147,24 +147,24 @@ subtest 'smartmatching :U numeric against :D numeric does not throw' => {

{ # coverage; 2016-10-05
my UInt $u;
is $u.defined, Bool::False, 'undefined UInt is undefined';
is-deeply $u.defined, Bool::False, 'undefined UInt is undefined';
cmp-ok $u, '~~', UInt, 'UInt var smartmatches True against UInt';
is $u.HOW.^name, 'Perl6::Metamodel::SubsetHOW', 'UInt is a subset';
throws-like { UInt.new }, Exception,
'attempting to instantiate UInt throws';

is ($u = 42), 42, 'Can store a positive Int in UInt';
is ($u = 0), 0, 'Can store a zero in UInt';
throws-like { $u = -42 }, X::TypeCheck::Assignment,
is-deeply ($u = 42), 42, 'Can store a positive Int in UInt';
is-deeply ($u = 0), 0, 'Can store a zero in UInt';
throws-like my UInt $z = -42, X::TypeCheck::Assignment,
'UInt rejects negative numbers';
throws-like { $u = "foo" }, X::TypeCheck::Assignment,
throws-like my UInt $y = "foo", X::TypeCheck::Assignment,
'UInt rejects other types';

is ($u = Nil), UInt, 'Can assign Nil to UInt';
is-deeply ($u = Nil), UInt, 'Can assign Nil to UInt';
my $u2 is default(72);
is $u2, 72, 'is default() trait works on brand new UInt';
is ($u2 = 1337), 1337, 'is default()ed UInt can take values';
is ($u2 = Nil), 72,
is-deeply $u2, 72, 'is default() trait works on brand new UInt';
is-deeply ($u2 = 1337), 1337, 'is default()ed UInt can take values';
is-deeply ($u2 = Nil), 72,
'Nil assigned to is default()ed UInt gives default values';
}

Expand Down
2 changes: 1 addition & 1 deletion S32-temporal/DateTime-Instant-Duration.t
Expand Up @@ -148,7 +148,7 @@ for 1, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1449755609 {
is-deeply $d - 1e2, Duration.new(-95.5), '1e2';
is-deeply $d - (-1.5), Duration.new(6), '-1.5';
is-deeply $d - 1.5, Duration.new(3), '1.5';
is-deeply $d - 100.5, Duration.new(-96), '1.5';
is-deeply $d - 100.5, Duration.new(-96), '100.5';
}

is-deeply now.Date, DateTime.now(:timezone(0)).Date, 'Instant.Date';
Expand Down
3 changes: 2 additions & 1 deletion S32-temporal/DateTime.t
Expand Up @@ -430,7 +430,8 @@ is dt(timezone => 3661).offset, 3661, 'DateTime.offset (1 hour, 1 minute, 1 seco
isa-ok DateTime.now.hour, Int, 'DateTime.now.hour isa Int';
}

is DateTime.now.Date, Date.today, 'coercion to Date';
is DateTime.now.Date, Date.today,
'coercion to Date (this test can fail if run exactly at midnight)';

{
is ds('2013-12-23T12:34:36Z').later(second => 1),
Expand Down

0 comments on commit f5454af

Please sign in to comment.