Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 301 lines (251 sloc) 13.774 kB
3d3f9a2 @moritz initial tests for typed exceptions; very unstructured for now
moritz authored
1 use v6;
2 use Test;
8380ccf @moritz move throws_like to Test::Util
moritz authored
3 BEGIN { @*INC.push('t/spec/packages/') };
4 use Test::Util;
3d3f9a2 @moritz initial tests for typed exceptions; very unstructured for now
moritz authored
5
2002a2f @moritz more typed exceptions
moritz authored
6 #?DOES 1
88dbaa7 @moritz X::Buf::Pack
moritz authored
7 throws_like { Buf.new().Str }, X::Buf::AsStr, method => 'Str';;
8 throws_like 'pack("B", 1)', X::Buf::Pack, directive => 'B';
9 throws_like 'Buf.new.unpack("B")', X::Buf::Pack, directive => 'B';
7a26e13 @moritz test X::Buf::Pack::NonASCII
moritz authored
10 throws_like 'pack "A1", "mÄ"', X::Buf::Pack::NonASCII, char => 'Ä';
6763664 @moritz fix test for X::Attribute::Undeclared
moritz authored
11 throws_like 'my class Foo { method a() { $!bar } }', X::Attribute::Undeclared,
12f1b31 @moritz basic tests for sigilless params
moritz authored
12 symbol => '$!bar', package-name => 'Foo', package-kind => 'class',
13 what => 'attribute';
3d3f9a2 @moritz initial tests for typed exceptions; very unstructured for now
moritz authored
14 throws_like 'sub f() { $^x }', X::Signature::Placeholder,
bff406d @moritz update some exception tests
moritz authored
15 line => 1,
16 placeholder => '$^x',
17 ;
3d3f9a2 @moritz initial tests for typed exceptions; very unstructured for now
moritz authored
18
4c68d1a @moritz skipped tests for X::Obsolete
moritz authored
19 #?rakudo skip 'parsing of $& and other p5 variables'
9fb1b22 @moritz test for qr obsoletion message
moritz authored
20 throws_like '$&', X::Obsolete, old => '$@ variable', replacement => '$, rx/<<rx>>// or $()';
21 throws_like 'qr/a/', X::Obsolete, old => rx/<<qr>>/, replacement => rx/<<rx>>/;
ba74f5e test X::Obsolete
Moritz Lenz authored
22 throws_like '"a" . "b"', X::Obsolete, replacement => '~';
4c68d1a @moritz skipped tests for X::Obsolete
moritz authored
23
f52c2ed @moritz test presence of placeholder attribute of X::Placeholder::Block excep…
moritz authored
24 throws_like 'do { $^x }', X::Placeholder::Block, placeholder => '$^x';
25 throws_like 'do { @_ }', X::Placeholder::Block, placeholder => '@_';
26 throws_like 'class { $^x }', X::Placeholder::Block, placeholder => '$^x';
47eec67 @FROGGS RT #76956, linked ticket (placeholder in mainline)
FROGGS authored
27 # RT #76956
8d41f56 @moritz more typed exception tests, better diagnosis
moritz authored
28 throws_like '$^x', X::Placeholder::Mainline, placeholder => '$^x';
d5ac5a6 @moritz RT #73502, @_ in the mainline
moritz authored
29 # RT #73502
30 throws_like '@_', X::Placeholder::Mainline, placeholder => '@_';
bea87e2 @moritz RT #85942
moritz authored
31 # RT #85942
32 throws_like '"foo".{ say $^a }', X::Placeholder::Mainline;
33
34
12f1b31 @moritz basic tests for sigilless params
moritz authored
35 throws_like 'sub f(*@ = 2) { }', X::Parameter::Default, how => 'slurpy', parameter => *.not;
36 throws_like 'sub f($x! = 3) { }', X::Parameter::Default, how => 'required', parameter => '$x';
8d41f56 @moritz more typed exception tests, better diagnosis
moritz authored
37 throws_like 'sub f(:$x! = 3) { }', X::Parameter::Default, how => 'required';
38 throws_like 'sub f($:x) { }', X::Parameter::Placeholder,
39 parameter => '$:x',
40 right => ':$x';
41 throws_like 'sub f($?x) { }', X::Parameter::Twigil,
42 parameter => '$?x',
43 twigil => '?';
a97dc2a @moritz track change of error class names; add some more redeclaration tests
moritz authored
44 throws_like 'sub (Int Str $x) { }', X::Parameter::MultipleTypeConstraints;
8d41f56 @moritz more typed exception tests, better diagnosis
moritz authored
45
46
47
a97dc2a @moritz track change of error class names; add some more redeclaration tests
moritz authored
48 # some of these redeclaration errors take different code
49 # paths in rakudo, so we over-test a bit to catch them all,
50 # even if the tests look rather boring;
0b7d7d2 @moritz more typed exception tests
moritz authored
51 throws_like 'my @a; my @a', X::Redeclaration, symbol => '@a';
52 throws_like 'sub a { }; sub a { }',X::Redeclaration, symbol => 'a', what => 'routine';
dddf111 @moritz RT #78370, my &a; sub a { } redeclaration error
moritz authored
53 # RT #78370
cf0e342 @moritz oops, meant to test something else
moritz authored
54 #?rakudo skip 'RT 78370'
55 throws_like 'my &a; multi a { }', X::Redeclaration, symbol => 'a', what => 'routine';
63626c2 @moritz another redeclaration test
moritz authored
56 throws_like 'sub a { }; multi sub a { }',X::Redeclaration, symbol => 'a', what => 'routine';
a97dc2a @moritz track change of error class names; add some more redeclaration tests
moritz authored
57 throws_like 'my class A { }; my class A { }', X::Redeclaration, symbol => 'A';
c9e3611 @moritz more robust name clash tests
moritz authored
58 throws_like 'my class B { }; my subset B of Any;', X::Redeclaration, symbol => 'B';
a97dc2a @moritz track change of error class names; add some more redeclaration tests
moritz authored
59 throws_like 'CATCH { }; CATCH { }', X::Phaser::Multiple, block => 'CATCH';
75c081f @moritz tests for multiple return type exceptions
moritz authored
60 # multiple return types
61 throws_like 'sub f(--> List) returns Str { }', X::Redeclaration;
62 throws_like 'my Int sub f(--> Str) { }', X::Redeclaration;
b73c13b @moritz RT #115356, redeclaration of class as a role
moritz authored
63 # RT #115356
64 throws_like 'class F { }; role F { }', X::Redeclaration, symbol => 'F';
fbb78ed @moritz test for X::Placeholder::Block
moritz authored
65
6467df2 @moritz test X::Attribute::Package and X::Attribute::NoPackage
moritz authored
66 throws_like 'my class A { my @a; @a!List::foo() }',
c01e5d6 @moritz tests for typed private method call exceptions
moritz authored
67 X::Method::Private::Permission,
68 method => 'foo',
69 calling-package => 'A',
70 source-package => 'List';
71
72 throws_like '1!foo()',
a97dc2a @moritz track change of error class names; add some more redeclaration tests
moritz authored
73 X::Method::Private::Unqualified,
c01e5d6 @moritz tests for typed private method call exceptions
moritz authored
74 method => 'foo';
75
d9262ef @moritz [throws_ok] allow subtypes; Liskov applies
moritz authored
76 throws_like 'sub f() { }; f() := 2', X::Bind;
77 throws_like 'OUTER := 5', X::Bind, target => /OUTER/;
bff406d @moritz update some exception tests
moritz authored
78 throws_like 'my int $x := 2', X::Bind::NativeType, name => '$x';
c6df8c5 @moritz update and expand tests for binding to unbindable stuff
moritz authored
79 throws_like 'my @a; @a[] := <foo bar baz>', X::Bind::ZenSlice, type => Array;
80 throws_like 'my %a; %a{} := foo=>1, bar=>2, baz=>3', X::Bind::ZenSlice, type => Hash;
81 throws_like 'my @a; @a[0, 1] := (2, 3)', X::Bind::Slice, type => Array;
82 throws_like 'my %a; %a<a b> := (2, 3)', X::Bind::Slice, type => Hash;
709242e @timo tests for X::Bind::ZenSlice.
timo authored
83
a824698 @moritz typed binding excpetions
moritz authored
84
dc765eb @moritz tests for typed exceptions
moritz authored
85 throws_like 'for (1; 1; 1) { }', X::Obsolete,
86 old => rx/<<for>>/,
87 replacement => rx/<<loop>>/;
88 throws_like 'foreach (1..10) { }', X::Obsolete,
89 old => "'foreach'",
90 replacement => "'for'";
91 throws_like 'undef', X::Obsolete,
92 old => rx/<<undef>>/;
49868a5 @FROGGS RT #77118, test for obsolete use of diamond operator
FROGGS authored
93 # RT #77118
94 {
95 throws_like ':a<>', X::Obsolete, old => "<>";
96 }
dc765eb @moritz tests for typed exceptions
moritz authored
97
a97dc2a @moritz track change of error class names; add some more redeclaration tests
moritz authored
98 throws_like 'my $a::::b', X::Syntax::Name::Null;
d1f0fd8 @moritz tests for typed syntax errors
moritz authored
99 throws_like 'unless 1 { } else { }', X::Syntax::UnlessElse;
100 throws_like 'for my $x (1, 2, 3) { }', X::Syntax::P5;
425b786 @moritz test for extra information in X::Syntax::NegatedPair
moritz authored
101 throws_like ':!foo(3)', X::Syntax::NegatedPair, key => 'foo';
d1f0fd8 @moritz tests for typed syntax errors
moritz authored
102 throws_like 'my $0', X::Syntax::Variable::Numeric;
b291479 @moritz test parameter variant of X::Syntax::Variable::Numeric
moritz authored
103 throws_like 'my sub f($0) { }', X::Syntax::Variable::Numeric, what => 'parameter';
d1f0fd8 @moritz tests for typed syntax errors
moritz authored
104 throws_like 'my $<a>', X::Syntax::Variable::Match;
33e961e @moritz RT #69230, my $!foo
moritz authored
105 throws_like 'my class A { my $!foo }', X::Syntax::Variable::Twigil, twigil => '!', scope => 'my';
d9f7caa @moritz RT #112724, line numbers from warnings
moritz authored
106 throws_like 'my $?FILE', X::Syntax::Variable::Twigil, twigil => '?', scope => 'my';
277e13d @moritz more tests for typed syntax errors
moritz authored
107 throws_like 'my $::("foo")', X::Syntax::Variable::IndirectDeclaration;
171ad0a @moritz test X::Undeclared
moritz authored
108 throws_like '@a', X::Undeclared, symbol => '@a';
277e13d @moritz more tests for typed syntax errors
moritz authored
109 throws_like 'augment class Any { }', X::Syntax::Augment::WithoutMonkeyTyping;
110 throws_like 'use MONKEY_TYPING; augment role Positional { }', X::Syntax::Augment::Role;
fd201d9 @moritz RT #82984
moritz authored
111 throws_like 'sub postbla:sym<foo>() { }', X::Syntax::Extension::Category, category => 'postbla';
ab9c613 @moritz RT #83992, proper error message for infix in term position
moritz authored
112 # RT #83992
113 throws_like 'my @a = 1, => 2', X::Syntax::InfixInTermPosition, infix => '=>';
840bfda @moritz test for X::Signature::NameClash
moritz authored
114 throws_like 'sub f(:in(:$in)) { }', X::Signature::NameClash, name => 'in';
296a529 @timo test for X::Does::TypeObject raising for 'does' operator.
timo authored
115 throws_like 'my $foo does &Int', X::Does::TypeObject;
116 throws_like 'my $foo does &Int, &Bool', X::Does::TypeObject;
e87efa1 @FROGGS RT #76742, added test for 'does with type object'
FROGGS authored
117 # RT #76742
118 throws_like 'Bool does role { method Str() { $.perl } };', X::Does::TypeObject;
2267094 @jnthn Fix some package/eval related issues.
jnthn authored
119 throws_like 'my role R { }; 99 but R("wrong");', X::Role::Initialization;
120 throws_like 'my role R { has $.x; has $.y }; 99 but R("wrong");', X::Role::Initialization;
121 throws_like 'my role R { }; 99 does R("wrong");', X::Role::Initialization;
122 throws_like 'my role R { has $.x; has $.y }; 99 does R("wrong");', X::Role::Initialization;
277e13d @moritz more tests for typed syntax errors
moritz authored
123
124 throws_like 'sub f($a?, $b) { }', X::Parameter::WrongOrder,
125 misplaced => 'required',
126 after => 'optional';
127 throws_like 'sub f(*@a, $b) { }', X::Parameter::WrongOrder,
128 misplaced => 'required',
129 after => 'variadic';
130 throws_like 'sub f(*@a, $b?) { }', X::Parameter::WrongOrder,
131 misplaced => 'optional positional',
132 after => 'variadic';
03faea7 @moritz X::Syntax::Name::NotNull
moritz authored
133
2002a2f @moritz more typed exceptions
moritz authored
134 #?rakudo skip 'parsing regression'
135 throws_like '#`', X::Syntax::Comment::Embedded;
1af5f7a @moritz RT #71814, =begin without identifier
moritz authored
136 # RT #71814
137 throws_like "=begin\n", X::Syntax::Pod::BeginWithoutIdentifier, line => 1, filename => rx/eval/;
2002a2f @moritz more typed exceptions
moritz authored
138
139 throws_like '@', X::Syntax::SigilWithoutName;
140 throws_like '1∞', X::Syntax::Confused;
e4dee67 @moritz X::Syntax::Missing
moritz authored
141 throws_like 'for 1, 2', X::Syntax::Missing, what => 'block';
a78af8c @moritz X::Syntax::Reserved
moritz authored
142 throws_like 'my @a()', X::Syntax::Reserved, reserved => /shape/ & /array/;
143 throws_like 'my &a()', X::Syntax::Reserved, instead => /':()'/;
2002a2f @moritz more typed exceptions
moritz authored
144
98bd346 @FROGGS test for "\u" X::Backslash::UnrecognizedSequence
FROGGS authored
145 # RT #115922
146 throws_like '"\u"', X::Backslash::UnrecognizedSequence, sequence => 'u';
8d88d57 @FROGGS test for "$" X::Backslash::NonVariableDollar
FROGGS authored
147 throws_like '"$"', X::Backslash::NonVariableDollar;
148
59f3f35 @moritz test exception type for stuff that must be known at compile time
moritz authored
149 throws_like 'm:i(@*ARGS[0])/foo/', X::Value::Dynamic;
150
5c0802d @moritz more exception tests
moritz authored
151 throws_like 'self', X::Syntax::Self::WithoutObject;
478ed38 @moritz more tests for availabilty-of-self related errors
moritz authored
152 throws_like 'class { has $.x = $.y }', X::Syntax::VirtualCall, call => '$.y';
153 throws_like '$.a', X::Syntax::NoSelf, variable => '$.a';
b3c2006 @moritz RT #59118
moritz authored
154 # RT #59118
155 throws_like 'my class B0Rk { $.a }', X::Syntax::NoSelf, variable => '$.a';
5c0802d @moritz more exception tests
moritz authored
156
6467df2 @moritz test X::Attribute::Package and X::Attribute::NoPackage
moritz authored
157 throws_like 'has $.x', X::Attribute::NoPackage;
12f1b31 @moritz basic tests for sigilless params
moritz authored
158 throws_like 'my module A { has $.x }', X::Attribute::Package, package-kind => 'module';
6467df2 @moritz test X::Attribute::Package and X::Attribute::NoPackage
moritz authored
159
46f9b17 @moritz track exception name change, and add another test
moritz authored
160 throws_like 'has sub a() { }', X::Declaration::Scope, scope => 'has', declaration => 'sub';
161 throws_like 'has package a { }', X::Declaration::Scope, scope => 'has', declaration => 'package';
eb6edd6 @moritz test X::Declaration::Scope::Multi
moritz authored
162 throws_like 'our multi a() { }', X::Declaration::Scope::Multi, scope => 'our';
a2b6fc2 @moritz more typed exceptions
moritz authored
163 throws_like 'multi sub () { }', X::Anon::Multi, multiness => 'multi';
164 throws_like 'proto sub () { }', X::Anon::Multi, multiness => 'proto';
3b9a604 @moritz more typed exceptions
moritz authored
165 throws_like 'class { multi method () { }}', X::Anon::Multi, routine-type => 'method';
12f1b31 @moritz basic tests for sigilless params
moritz authored
166 throws_like 'use MONKEY_TYPING; augment class { }', X::Anon::Augment, package-kind => 'class';
3804629 @moritz test X::Augment::NoSuchType
moritz authored
167 throws_like 'use MONKEY_TYPING; augment class NoSuchClass { }', X::Augment::NoSuchType,
12f1b31 @moritz basic tests for sigilless params
moritz authored
168 package-kind => 'class',
3804629 @moritz test X::Augment::NoSuchType
moritz authored
169 package => 'NoSuchClass';
c9e3611 @moritz more robust name clash tests
moritz authored
170 throws_like 'use MONKEY_TYPING; augment class No::Such::Class { }', X::Augment::NoSuchType,
171 package => 'No::Such::Class';
3b9a604 @moritz more typed exceptions
moritz authored
172
173 throws_like ':45<abcd>', X::Syntax::Number::RadixOutOfRange, radix => 45;
3dab5c0 @moritz RT #112056
moritz authored
174 throws_like ':0<0>', X::Syntax::Number::RadixOutOfRange, message => rx/0/;
dc3de2d @moritz X::Syntax::Regex::Adverb
moritz authored
175 throws_like 'rx:g/a/', X::Syntax::Regex::Adverb, adverb => 'g', construct => 'rx';
26f6834 @moritz X::Syntax::Signature::InvocantMarker
moritz authored
176 throws_like 'my sub f($x, $y:) { }', X::Syntax::Signature::InvocantMarker;
a2b6fc2 @moritz more typed exceptions
moritz authored
177
1bf4f1d @moritz X::OutOfRange
moritz authored
178 throws_like 'Date.new("2012-02-30")', X::OutOfRange,
179 range => Range, message => rx/<<1\.\.29>>/;
c04814d @moritz test leap second exception
moritz authored
180 throws_like 'DateTime.new(year => 2012, month => 5, day => 22, hour => 18, minute => 3, second => 60)',
181 X::OutOfRange, comment => /'leap second'/;
58512ac @moritz test index out of range exception
moritz authored
182 throws_like 'use fatal; "foo"[2]', X::OutOfRange, what => rx:i/index/, range => 0..0, got => 2;
1bf4f1d @moritz X::OutOfRange
moritz authored
183
52f6db6 @moritz test for X::Routine::Unwrap
moritz authored
184 throws_like 'sub f() { }; &f.unwrap("foo")', X::Routine::Unwrap;
44d0aa3 @moritz test X::Constructor::Positional
moritz authored
185 throws_like 'Mu.new(1)', X::Constructor::Positional;
39b3eb7 @Siddhant add test for X::Hash::Store::Oddnumber
Siddhant authored
186 throws_like 'my %h = 1', X::Hash::Store::OddNumber;
52f6db6 @moritz test for X::Routine::Unwrap
moritz authored
187
fcd1668 @moritz Test for proper error of "sub foo;", RT #68710 and RT #111492
moritz authored
188 # TOOD: might be X::Syntax::Malformed too...
189 throws_like 'sub foo;', X::Syntax::Missing, what => 'block';
db2d40c @moritz RT #75776, correct syntax error for missing block
moritz authored
190 # RT #75776
191 throws_like 'my $d; my class A {method x { $d }}; for () { sub }', X::Syntax::Missing, what => 'block';
157d7b7 @moritz more tests for "constant" parse errors
moritz authored
192 throws_like 'constant foo;', X::Syntax::Missing, what => /initializer/;
193 throws_like 'constant * = 3;', X::Syntax::Missing, what => /constant/;
fcd1668 @moritz Test for proper error of "sub foo;", RT #68710 and RT #111492
moritz authored
194
ddc21bf @moritz test X::Package::Stubbed
moritz authored
195 throws_like 'class A {...}; grammar B { ... }', X::Package::Stubbed, packages => <A B>;
196
9831233 @moritz track phaser error changes in rakudo
moritz authored
197 throws_like 'my sub a { PRE 0 }; a()', X::Phaser::PrePost, phaser => 'PRE', condition => /0/;
198 throws_like 'my sub a { POST 0 }; a()', X::Phaser::PrePost, phaser => 'POST', condition => /0/;
efa9610 @moritz typed exceptions for PRE/POST failures
moritz authored
199
d720afa @moritz test that Str numification error message survives through infix:<+>
moritz authored
200 throws_like 'use fatal; my $x = "5 foo" + 8;', X::Str::Numeric, source => '5 foo', pos => 1,
201 reason => /trailing/;
7bac3ca @pmichaud Update a .match failure test.
pmichaud authored
202 throws_like '"a".match(:x([1, 2, 3]), /a/).Str', X::Str::Match::x, got => Array;
7d371b6 @moritz test X::Str::Trans::IllegalKey, sorear++
moritz authored
203 throws_like '"a".trans([Any.new] => [Any.new])', X::Str::Trans::IllegalKey, key => Any;
7b9ba33 @moritz test X::Str::Trans::InvalidArg
moritz authored
204 throws_like '"a".trans(rx/a/)', X::Str::Trans::InvalidArg, got => Regex;
d720afa @moritz test that Str numification error message survives through infix:<+>
moritz authored
205
d701cfa @moritz text X::Method::NotFound on normal and .+ dispatches
moritz authored
206 throws_like '1.foo', X::Method::NotFound, method => 'foo', typename => 'Int';
207 throws_like '1.+foo', X::Method::NotFound, method => 'foo', typename => 'Int';
16238cd @moritz test private method not found error
moritz authored
208 throws_like 'my class Priv { method x { self!foo } }; Priv.x',
209 X::Method::NotFound,
210 method => '!foo',
211 typename => 'Priv',
212 private => { $_ === True };
eff5942 @moritz more typed exception tests (X::ControlFlow, X::Method::InvalidQualifier)
moritz authored
213 throws_like '1.List::join', X::Method::InvalidQualifier,
214 method => 'join',
215 invocant => 1,
216 qualifier-type => List;
d701cfa @moritz text X::Method::NotFound on normal and .+ dispatches
moritz authored
217
903dffc @moritz test that stubby exception generators can take an argument
moritz authored
218 # RT #58558
219 throws_like '!!! 42', X::AdHoc, payload => 42;
220 throws_like 'use fatal; ... 42', X::AdHoc, payload => 42;
221 {
222 my $c = 0;
223 try {
224 ??? 42;
225 CONTROL { default { $c++ } }
226 }
227 is $c, 1, '??? with argument warns';
228 }
229
ca3a210 @moritz $!.backtrace generates a Backtrace
moritz authored
230 throws_like 'die "foo"', X::AdHoc, backtrace => Backtrace;
2365690 @moritz RT #98678, error message for failed sequence deduction
moritz authored
231 throws_like 'use fatal; ~(1, 2, 6 ... 10)', X::Sequence::Deduction;
903dffc @moritz test that stubby exception generators can take an argument
moritz authored
232
2267094 @jnthn Fix some package/eval related issues.
jnthn authored
233 throws_like 'my class B does Int { }', X::Composition::NotComposable, target-name => 'B', composer => Int;
cb7e988 @moritz test X::TypeCheck::Binding and X::TypeCheck::Return
moritz authored
234 throws_like 'my Str $x := 3', X::TypeCheck::Binding, got => Int, expected => Str;
235 throws_like 'sub f() returns Str { 5 }; f', X::TypeCheck::Return, got => Int, expected => Str;
6625f6f @moritz test X::TypeCheck::Assignment
moritz authored
236 throws_like 'my Int $x = "foo"', X::TypeCheck::Assignment, got => 'foo',
237 expected => Int, symbol => '$x';
cb7e988 @moritz test X::TypeCheck::Binding and X::TypeCheck::Return
moritz authored
238
61b24d9 @moritz test X::Assignment::RO, and add tests for RT #113534
moritz authored
239 throws_like 'sub f() { }; f() = 3', X::Assignment::RO;
240 throws_like '1.0 = 3', X::Assignment::RO;
241 # RT #113534
242 throws_like '120 = 3', X::Assignment::RO;
243 throws_like '1e0 = 3', X::Assignment::RO;
244 throws_like '"a" = 3', X::Assignment::RO;
245
b585e67 @moritz test for method not found exception
moritz authored
246 throws_like '1.foo', X::Method::NotFound, method => 'foo', typename => 'Int';
d4fa5e8 @moritz follow exception class rename
moritz authored
247 throws_like 'my class NC { }; NC.new does NC', X::Mixin::NotComposable,
5a8433b @moritz test X::Mixin::NonComposable
moritz authored
248 :target(*.defined), :rolish(*.^name eq 'NC');
d4fa5e8 @moritz follow exception class rename
moritz authored
249 throws_like 'my class NC { }; NC.new but NC', X::Mixin::NotComposable,
5a8433b @moritz test X::Mixin::NonComposable
moritz authored
250 :target(*.defined), :rolish(*.^name eq 'NC');
251
eff5942 @moritz more typed exception tests (X::ControlFlow, X::Method::InvalidQualifier)
moritz authored
252 throws_like 'last', X::ControlFlow,
253 illegal => 'last', enclosing => 'loop construct';
254 throws_like 'next', X::ControlFlow,
255 illegal => 'next', enclosing => 'loop construct';
256 throws_like 'redo', X::ControlFlow,
257 illegal => 'redo', enclosing => 'loop construct';
b585e67 @moritz test for method not found exception
moritz authored
258
c147454 @moritz test X::Inheritance::Unsupported
moritz authored
259 throws_like 'my package A { }; my class B is A { }', X::Inheritance::Unsupported;
d701cfa @moritz text X::Method::NotFound on normal and .+ dispatches
moritz authored
260
5eefbf8 @moritz test X::Export::NameClash
moritz authored
261 throws_like 'my module Expo { sub f is export { }; { sub f is export { } } }',
262 X::Export::NameClash, symbol => '&f';
263
385370f @moritz label and unfudge test for RT #113408, and remove nearly identical se…
moritz authored
264 # RT #113408
78d560a @moritz test for X::HyperOp::NonDWIM
moritz authored
265 throws_like '<a b> »+« <c>', X::HyperOp::NonDWIM,
266 left-elems => 2, right-elems => 1,
267 operator => { .name eq 'infix:<+>' };
268
e708a8c @moritz test X::ControlFlow::Return
moritz authored
269 throws_like 'my sub f() { gather { return } }; ~f()', X::ControlFlow::Return;
270
a1248db @moritz test X::Temporal::InvalidFormat
moritz authored
271 throws_like 'DateTime.new("2012/04")', X::Temporal::InvalidFormat,
272 invalid-str => '2012/04',
273 target => 'DateTime';
274
275 throws_like 'Date.new("2012/04")', X::Temporal::InvalidFormat,
276 invalid-str => '2012/04',
277 target => 'Date';
278
6aa9f56 @moritz test X::Eval::NoSuchLang
moritz authored
279 throws_like 'eval("foo", :lang<no-such-language>)',
280 X::Eval::NoSuchLang,
281 lang => 'no-such-language';
282
3ed2a34 @moritz test X::Temporal::Truncation
moritz authored
283 throws_like 'DateTime.now.truncated-to(:foo)', X::Temporal::Truncation;
284 throws_like 'Date.today.truncated-to(:foo)', X::Temporal::Truncation;
7a77b2a @moritz test X::DateTime::TimezoneClash
moritz authored
285 throws_like 'DateTime.new("1998-12-31T23:59:60+0200", :timezone<Z>)', X::DateTime::TimezoneClash;
7d371b6 @moritz test X::Str::Trans::IllegalKey, sorear++
moritz authored
286
85f737a @moritz test X::Set::Coerce
moritz authored
287 throws_like 'Set(Any.new)', X::Set::Coerce;
288
a47ed9f @moritz test X::Numeric::Real
moritz authored
289 throws_like 'use fatal; (1+2i).Num', X::Numeric::Real, target => Num;
290 throws_like 'use fatal; (1+2i).Real', X::Numeric::Real, target => Real;
291
edf27d4 @svatsan Added test for #114134
svatsan authored
292 #RT #114134
293 {
be54170 @moritz fudge test for RT #114134
moritz authored
294 #?rakudo skip 'RT 114134'
a6be9c5 @moritz avoid a redeclaration error that shadows the error we actually want t…
moritz authored
295 throws_like 'my class A {}; (-> &c, $m { A.new()(); CATCH { default { $m } } } )(A, "")', X::TypeCheck::Binding;
edf27d4 @svatsan Added test for #114134
svatsan authored
296
297 dies_ok {eval(class A{}; (-> &c, $m { A.new()(); CATCH { default { $m } } } )(A, "")) }, "Should fail type check with unbound variable";
298 }
299
3d3f9a2 @moritz initial tests for typed exceptions; very unstructured for now
moritz authored
300 done;
Something went wrong with that request. Please try again.