Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 171 lines (151 sloc) 3.33 kb
58135b3 [t/spec] changed 'use v6-alpha;' to 'use v6;'
moritz authored
1 use v6;
125e670 Test suite refactoring.
cosimo authored
2
3 use Test;
4
5f10837 [t] Converted pod markers to pod6
cosimo authored
5 =begin pod
125e670 Test suite refactoring.
cosimo authored
6
7 Basic tests for the ord() and chr() built-in.
8
5f10837 [t] Converted pod markers to pod6
cosimo authored
9 =end pod
125e670 Test suite refactoring.
cosimo authored
10
11 # L<S29/Conversions/ord>
19b6614 thundergnat Added tests for ords(), .ords, chrs() and .chrs
thundergnat authored
12 # L<S29/Conversions/ords>
125e670 Test suite refactoring.
cosimo authored
13 # L<S29/Conversions/chr>
19b6614 thundergnat Added tests for ords(), .ords, chrs() and .chrs
thundergnat authored
14 # L<S29/Conversions/chrs>
125e670 Test suite refactoring.
cosimo authored
15
16 # What is the best way to test 0 through 31??
17 my @maps = (
18 " ", 32,
19 "!", 33,
68ced3d [ord_and_chr.t] some malformed double-quoted strings
lwall authored
20 '"', 34,
125e670 Test suite refactoring.
cosimo authored
21 "#", 35,
68ced3d [ord_and_chr.t] some malformed double-quoted strings
lwall authored
22 '$', 36,
125e670 Test suite refactoring.
cosimo authored
23 "%", 37,
24 "&", 38,
68ced3d [ord_and_chr.t] some malformed double-quoted strings
lwall authored
25 "'", 39,
125e670 Test suite refactoring.
cosimo authored
26 "(", 40,
27 ")", 41,
28 "*", 42,
29 "+", 43,
30 ",", 44,
31 "-", 45,
32 ".", 46,
33 "/", 47,
34 "0", 48,
35 "1", 49,
36 "2", 50,
37 "3", 51,
38 "4", 52,
39 "5", 53,
40 "6", 54,
41 "7", 55,
42 "8", 56,
43 "9", 57,
44 ":", 58,
45 ";", 59,
46 "<", 60,
47 "=", 61,
48 ">", 62,
49 "?", 63,
50 "@", 64,
51 "A", 65,
52 "B", 66,
53 "C", 67,
54 "D", 68,
55 "E", 69,
56 "F", 70,
57 "G", 71,
58 "H", 72,
59 "I", 73,
60 "J", 74,
61 "K", 75,
62 "L", 76,
63 "M", 77,
64 "N", 78,
65 "O", 79,
66 "P", 80,
67 "Q", 81,
68 "R", 82,
69 "S", 83,
70 "T", 84,
71 "U", 85,
72 "V", 86,
73 "W", 87,
74 "X", 88,
75 "Y", 89,
76 "Z", 90,
77 "[", 91,
78 "\\", 92,
79 "]", 93,
80 "^", 94,
81 "_", 95,
82 "`", 96,
83 "a", 97,
84 "b", 98,
85 "c", 99,
86 "d", 100,
87 "e", 101,
88 "f", 102,
89 "g", 103,
90 "h", 104,
91 "i", 105,
92 "j", 106,
93 "k", 107,
94 "l", 108,
95 "m", 109,
96 "n", 110,
97 "o", 111,
98 "p", 112,
99 "q", 113,
100 "r", 114,
101 "s", 115,
102 "t", 116,
103 "u", 117,
104 "v", 118,
105 "w", 119,
106 "x", 120,
107 "y", 121,
108 "z", 122,
14a6ccf [ord_and_chr.t] typo - '{' is 123
rhr authored
109 '{', 123,
125e670 Test suite refactoring.
cosimo authored
110 "|", 124,
68ced3d [ord_and_chr.t] some malformed double-quoted strings
lwall authored
111 '}', 125,
125e670 Test suite refactoring.
cosimo authored
112 "~", 126,
113
114 # Unicode tests
115 "ä", 228,
116 "€", 8364,
117 "»", 187,
118 "«", 171,
119
120 # Special chars
121 "\o00", 0,
122 "\o01", 1,
123 "\o03", 3,
124 );
125
19b6614 thundergnat Added tests for ords(), .ords, chrs() and .chrs
thundergnat authored
126 plan 46 + @maps;
125e670 Test suite refactoring.
cosimo authored
127
128 for @maps -> $char, $code {
129 my $descr = "\\{$code}{$code >= 32 ?? " == '{$char}'" !! ""}";
130 is ord($char), $code, "ord() works for $descr";
131 is chr($code), $char, "chr() works for $descr";
132 }
133
f8f98e2 [t/spec] use series instead of range in ord_and_chr.t
moritz authored
134 for 0...31 -> $code {
125e670 Test suite refactoring.
cosimo authored
135 my $char = chr($code);
136 is ord($char), $code, "ord(chr($code)) is $code";
137 }
138
19b6614 thundergnat Added tests for ords(), .ords, chrs() and .chrs
thundergnat authored
139 is ords('ABCDEFGHIJK'), '65 66 67 68 69 70 71 72 73 74 75', "ords() works as expected";
140 is chrs(65..75), 'ABCDEFGHIJK', "chrs() method works as expected";
141 is chrs(ords('ABCDEFGHIJK')), 'ABCDEFGHIJK', "chrs(ords()) round-trips correctly";
142 is ords(chrs(65..75)), '65 66 67 68 69 70 71 72 73 74 75', "ords(chrs()) round-trips correctly";
143
d2ed6c4 [ord_and_chr.t] added tests for ord and chr methods
masak authored
144 is 'A'.ord, 65, "there's a .ord method";
145 is 65.chr, 'A', "there's a .chr method";
e6dc364 [ord_and_chr.t] added tests for multi-arg variants of ord and chr
masak authored
146
19b6614 thundergnat Added tests for ords(), .ords, chrs() and .chrs
thundergnat authored
147 is ('ABCDEFGHIJK').ords, '65 66 67 68 69 70 71 72 73 74 75', "there's a .ords method";
148 is (65..75).chrs, 'ABCDEFGHIJK', "there's a .chrs method";
149 is ('ABCDEFGHIJK').ords.chrs, 'ABCDEFGHIJK', "ords > chrs round-trips correctly";
150 is (65..75).chrs.ords, '65 66 67 68 69 70 71 72 73 74 75', "chrs > ords round-trips correctly";
151
86dcbc4 [t/spec] Unfudge the ord('hello') test.
colomon authored
152 #?rakudo skip 'multi-arg variants of chr not in place yet'
e6dc364 [ord_and_chr.t] added tests for multi-arg variants of ord and chr
masak authored
153 is chr(104, 101, 108, 108, 111), 'hello', 'chr works with a list of ints';
ea7311e [t/spec] Test for RT #62772
kyle authored
154
8bb65b5 Moritz Lenz correct ord_and_chr.t (precedence, calling positionals by name), and fud...
moritz authored
155 #?rakudo skip 'ord of empty string'
156 ok !defined(ord("")), 'ord("") returns an undefined value';
ea7311e [t/spec] Test for RT #62772
kyle authored
157
fe2a54c [t/spec] Test for RT #65172
kyle authored
158 # RT #65172
d87f4af Fitz Elliott [ord_and_chr.t] fix typo in RT number annotation
felliott authored
159 #?rakudo skip 'RT 65172'
fe2a54c [t/spec] Test for RT #65172
kyle authored
160 {
2f25552 [t/spec] be more explicit when testing for graphemenss
moritz authored
161 is "\c[LATIN CAPITAL LETTER A, COMBINING DOT ABOVE]".ord,
162 555,
163 '.ord defaults to graphemes (1)';
164
165 is "\c[LATIN CAPITAL LETTER A WITH DOT ABOVE]",
166 555,
167 '.ord defaults to graphemes (2)';
fe2a54c [t/spec] Test for RT #65172
kyle authored
168 }
169
1b6d1d0 [t] Added named arg tests for ord and chr
frew authored
170 #vim: ft=perl6
Something went wrong with that request. Please try again.