Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 66 lines (55 sloc) 1.432 kB
fabdf10 [spectest] Add some tests for generic subs.
jnthn authored
1 use v6;
2 use Test;
3
e26327b @usev6 Add test for RT #114724
usev6 authored
4 plan 10;
7ca904f [t/spec] remove Windows line endings from S06-signature/type-capture.t
hinrik authored
5
c2f8fec [t] and [t/spec] (two train travels worth of changes):
moritz authored
6 # TODO: move to S02?
7 # L<S02/Generic types/>
8
7ca904f [t/spec] remove Windows line endings from S06-signature/type-capture.t
hinrik authored
9 # Check it captures built-in types.
8dc7d4b [t/spec] mark various tests that intentionally declare things that ar…
lwall authored
10 sub basic_capture(::T $x) { T } #OK not used
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
11 isa-ok(basic_capture(42), Int, 'captured built-in type');
12 isa-ok(basic_capture(4.2), Rat, 'captured built-in type');
7ca904f [t/spec] remove Windows line endings from S06-signature/type-capture.t
hinrik authored
13
14 # User defined ones too.
15 class Foo { }
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
16 isa-ok(basic_capture(Foo.new), Foo, 'captured user defined type');
7ca904f [t/spec] remove Windows line endings from S06-signature/type-capture.t
hinrik authored
17
18 # Check you can use captured type later in the signature.
8dc7d4b [t/spec] mark various tests that intentionally declare things that ar…
lwall authored
19 sub two_the_same(::T $x, T $y) { 1 } #OK not used
7ca904f [t/spec] remove Windows line endings from S06-signature/type-capture.t
hinrik authored
20 ok(two_the_same(42, 42), 'used captured type later in the sig');
21 my $ok = 1;
22 try {
23 two_the_same(42, 4.2);
24 $ok = 0;
25 }
26 ok($ok, 'used captured type later in the sig');
27
28 # Check you can use them to declare variables.
8dc7d4b [t/spec] mark various tests that intentionally declare things that ar…
lwall authored
29 sub declare_cap_type(::T $x) { #OK not used
f341480 [t/spec] more warning suppressions; remaining STD warnings are mostly…
lwall authored
30 my T $y = 4.2; #OK not used
7ca904f [t/spec] remove Windows line endings from S06-signature/type-capture.t
hinrik authored
31 1
32 }
33 ok(declare_cap_type(3.3), 'can use captured type in declaration');
34 $ok = 1;
35 try {
36 declare_cap_type(42);
37 $ok = 0;
38 }
39 ok($ok, 'can use captured type in declaration');
8a34569 [t/spec] improve fudging of capture.t; vim modeline
moritz authored
40
0b90fb4 @svatsan Added test for RT #114216
svatsan authored
41 #RT #114216
e816632 @lizmat s/eval_lives_ok/eval-lives-ok/g
lizmat authored
42 eval-lives-ok q':(::T $x)', "No error on type capture";
201f031 @jnthn Test for RT #125537.
jnthn authored
43
44 # RT #125537
45 {
46 sub foo(::T) {
47 {
48 my T $b;
49 is $b, Int, 'Type capture works on variable in nested scope';
50 }
51 }
52 foo(1)
53 }
54
e26327b @usev6 Add test for RT #114724
usev6 authored
55 # RT #114724
56 {
57 sub f (::T $g) {
58 for ($g) -> T $h {
59 return $h ~ ":" ~ T.perl
60 }
61 };
62 is f("blah"), "blah:Str", 'Type variable matches in signature to "for" loop';
63 }
64
8a34569 [t/spec] improve fudging of capture.t; vim modeline
moritz authored
65 # vim: ft=perl6
Something went wrong with that request. Please try again.