Skip to content

Commit

Permalink
Synthetics rejected in constructor strings
Browse files Browse the repository at this point in the history
RT#128545
  • Loading branch information
zoffixznet committed Sep 8, 2016
1 parent ca2b03d commit 3ed2af4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 5 additions & 1 deletion S32-temporal/Date.t
Expand Up @@ -3,7 +3,7 @@ use Test;

# L<S32::Temporal/C<Date>>

plan 100;
plan 101;

# construction
{
Expand Down Expand Up @@ -184,3 +184,7 @@ is Date.new('2015-12-29',:formatter({sprintf "%2d/%2d/%4d",.day,.month,.year})),
is $fd.foo, 42, "is foo in FooDate ok";
}
}

# RT #128545
throws-like { Date.new: "2016-07\x[308]-05" }, X::Temporal::InvalidFormat,
'synthetics are rejected in constructor string';
11 changes: 10 additions & 1 deletion S32-temporal/DateTime.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 268;
plan 269;

my $orwell = DateTime.new(year => 1984);

Expand Down Expand Up @@ -689,3 +689,12 @@ is ds("2016-02-29T00:00:00").later(:1year), "2017-02-28T00:00:00Z",
is $fdt.foo, 42, "is foo in FooDateTime ok";
}
}

# RT #128545
subtest 'synthetics not allowed in date formats' => {
throws-like { DateTime.new: "20\x[308]16-07-05T00:00:00+01:00" },
X::Temporal::InvalidFormat, 'DateTime.new (+01:00 format)';

throws-like { DateTime.new: "2016-07-05T00:0\x[308]0:00Z" },
X::Temporal::InvalidFormat, 'DateTime.new (Z format)';
}

0 comments on commit 3ed2af4

Please sign in to comment.