Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 85 lines (60 sloc) 1.932 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;
7abe9d3 [t/spec]: Untyped variables now default to Any instead of Mu.
pmichaud authored
10 is($a.WHAT, Any, 'empty scalar is Any');
207f13f [t] and [t/spec]
moritz authored
11
12 my @a;
6b717bc [t/spec] One little test pays a visit to the Latest Spec doctor.
jnthn authored
13 ok(@a ~~ Array, 'it is an Array type');
207f13f [t] and [t/spec]
moritz authored
14 ok @a ~~ Positional, 'An Array does Positional';
15
16 my %a;
6b717bc [t/spec] One little test pays a visit to the Latest Spec doctor.
jnthn authored
17 ok(%a ~~ Hash, 'it is an Hash type');
207f13f [t] and [t/spec]
moritz authored
18 ok %a ~~ Associative, 'A Hash does Associative';
19
20 # WHAT() on reference types
21
22 my $b1 = [];
6b717bc [t/spec] One little test pays a visit to the Latest Spec doctor.
jnthn authored
23 ok($b1 ~~ Array, 'it is a Array type');
207f13f [t] and [t/spec]
moritz authored
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;
6b717bc [t/spec] One little test pays a visit to the Latest Spec doctor.
jnthn authored
27 ok($b2 ~~ Hash, 'it is a Hash type');
207f13f [t] and [t/spec]
moritz authored
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 = {};
6b717bc [t/spec] One little test pays a visit to the Latest Spec doctor.
jnthn authored
46 ok($s2 ~~ Hash, 'it is a Hash type (bare block)');
207f13f [t] and [t/spec]
moritz authored
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 = '';
c7c1e2f @coke nom fudging
coke authored
63 #?rakudo todo 'nom regression'
207f13f [t] and [t/spec]
moritz authored
64 ok(+$num ~~ Num, 'it is an Num type');
65
6b717bc [t/spec] One little test pays a visit to the Latest Spec doctor.
jnthn authored
66 my $float = 0.5e0;
207f13f [t] and [t/spec]
moritz authored
67 isa_ok($float, Num, 'it is an Num type');
a4ba5fd [t/spec] correct meaning of infix:<div> and infix:</>. Patch courtesy (m...
moritz authored
68 isa_ok(1 / 4, Rat, 'infix:</> of integers produces a Rat');
207f13f [t] and [t/spec]
moritz authored
69
70 my $string = "Hello World";
71 isa_ok($string, Str, 'it is a Str type');
72
73 my $bool = (0 == 0);
74 isa_ok($bool, Bool, 'it is a Bool type');
75
76 my $pair = ("foo" => "bar");
77 isa_ok($pair, Pair, 'it is a Pair type');
78
79 {
80 my $rule = rx/^hello\sworld$/;
81 isa_ok($rule, Regex, 'it is a Regex type');
82 }
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
83
84 # vim: ft=perl6
Something went wrong with that request. Please try again.