Skip to content

Commit

Permalink
Merge pull request #762 from vrurg/disable-enum-instantiation
Browse files Browse the repository at this point in the history
Add tests for enums throwing on .new
  • Loading branch information
vrurg committed Oct 25, 2021
2 parents 97a5f77 + a54d2cb commit 749ce35
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 5 additions & 1 deletion S02-types/bool.t
@@ -1,6 +1,6 @@
use v6;
use Test;
plan 66;
plan 69;

#L<S12/Built-in Enumerations/"Two built-in enumerations are">

Expand Down Expand Up @@ -139,4 +139,8 @@ is-deeply $or, $r, 'infix `or` with one argument returns the argument';
$or = [or];
is-deeply $or, False, 'infix `or` with no argument is False';

for Bool, True, False -> \typish {
throws-like { typish.new }, X::Constructor::BadType, "invoking .new on {typish.raku} throws";
}

# vim: expandtab shiftwidth=4
9 changes: 7 additions & 2 deletions S12-enums/misc.t
Expand Up @@ -2,7 +2,7 @@ use v6;

use Test;

plan 24;
plan 25;

{
class EnumClass { enum C <a b c> }
Expand Down Expand Up @@ -48,7 +48,7 @@ plan 24;
}

# https://github.com/Raku/old-issue-tracker/issues/3481
# anonymous Enum in our context,
# anonymous Enum in our context,
{
enum :: <un>;
is +un, 0, 'is un the right value';
Expand Down Expand Up @@ -120,4 +120,9 @@ plan 24;
".invert on an Enum with Array values";
}

{
my enum Foo <A B>;
throws-like { Foo.new }, X::Constructor::BadType, "invoking .new on an enum throws";
}

# vim: expandtab shiftwidth=4

0 comments on commit 749ce35

Please sign in to comment.