Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 84 lines (59 sloc) 1.904 kb
207f13f [t] and [t/spec]
moritz authored
1 use v6;
2
3 use Test;
4
5 plan 19;
6
7 # WHAT() on basic types
8
9 my $a;
10 isa_ok($a, Any, 'it is an Any type');
11
12 my @a;
13 isa_ok(@a, Array, 'it is an Array type');
14 ok @a ~~ Positional, 'An Array does Positional';
15
16 my %a;
17 isa_ok(%a, Hash, 'it is an Hash type');
18 ok %a ~~ Associative, 'A Hash does Associative';
19
20 # WHAT() on reference types
21
22 my $b1 = [];
23 isa_ok($b1, List, 'it is a List type');
24
25 # this seems to be the only way to make a hash - ref at the moment
26 my %b2 = ("one", 1); my $b2 = %b2;
27 isa_ok($b2, Hash, 'it is a Hash type');
28
29 # WHAT() on subroutines
30
31 my $s1 = sub {};
32 isa_ok($s1, Sub, 'it is a Sub type');
33
4e820b4 [t/spec] more smartlink fixes
moritz authored
34 # See L<S02/"Built-in Data Types">
207f13f [t] and [t/spec]
moritz authored
35 # Quoting A06:
36 # Code
37 # ____________|________________
38 # | |
39 # Routine Block
40 # ________________|_______________
41 # | | | | | |
42 # Sub Method Submethod Multi Rule Macro
43
44 # L<S06/Anonymous hashes vs blocks>
45 my $s2 = {};
46 isa_ok($s2, Hash, 'it is a Hash type (bare block)');
47
48 # L<S06/"Placeholder variables">
49 my $s2a = { $^a };
50 isa_ok($s2a, Block, 'it is a Parametric type (bare block with placeholder parameters)');
51
52 {
53 my $s3 = -> {};
54 isa_ok($s3, Block, 'it is a Block type (pointy block)');
55 }
56
57 # WHAT() on different types of scalars
58
59 my $int = 0;
60 isa_ok($int, Int, 'it is an Int type');
61
62 my $num = '';
63 ok(+$num ~~ Num, 'it is an Num type');
64
65 my $float = 0.5;
66 isa_ok($float, Num, 'it is an Num type');
a4ba5fd [t/spec] correct meaning of infix:<div> and infix:</>. Patch courtesy…
moritz authored
67 isa_ok(1 / 4, Rat, 'infix:</> of integers produces a Rat');
207f13f [t] and [t/spec]
moritz authored
68
69 my $string = "Hello World";
70 isa_ok($string, Str, 'it is a Str type');
71
72 my $bool = (0 == 0);
73 isa_ok($bool, Bool, 'it is a Bool type');
74
75 my $pair = ("foo" => "bar");
76 isa_ok($pair, Pair, 'it is a Pair type');
77
78 {
79 my $rule = rx/^hello\sworld$/;
80 isa_ok($rule, Regex, 'it is a Regex type');
81 }
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
82
83 # vim: ft=perl6
Something went wrong with that request. Please try again.