Skip to content
Newer
Older
100644 165 lines (118 sloc) 4.81 KB
d198f6b [t/spec] s/use v6-alpha;/use v6;/
moritz authored
1 use v6;
53330f8 Test suite refactoring.
cosimo authored
2 use Test;
c5fa27b @moritz [S32] remove more tests for now-gone calling-positionals-by-named tests
moritz authored
3 plan 34;
53330f8 Test suite refactoring.
cosimo authored
4
ccace72 [t/spec] fix smartlinks in S32-list
moritz authored
5 # L<S32::Containers/"List"/"=item join">
53330f8 Test suite refactoring.
cosimo authored
6
3992cea [t] added named arg tests for join
frew authored
7 # test all variants of join()
53330f8 Test suite refactoring.
cosimo authored
8
e33900b @coke pugs fudge
coke authored
9 #?pugs skip 'empty join NYI'
925c825 [t/spec] test join on empty list
moritz authored
10 is join(), '', 'empty join is empty string (sub)';
11 is ().join, '', 'empty join is empty string (method)';
12
53330f8 Test suite refactoring.
cosimo authored
13 is(["a", "b", "c"].join("|"), "a|b|c", '[].join("|") works');
14
15 my @list = ("a", "b", "c");
16
17 is(@list.join("|"), "a|b|c", '@list.join("|") works');
18
0f2c948 Skip tests that call positional params by name.
cspencer authored
19 my $joined2 = join("|", @list);
e33900b @coke pugs fudge
coke authored
20 #?pugs todo
53330f8 Test suite refactoring.
cosimo authored
21 is($joined2, "a|b|c", 'join("|", @list) works');
22
23 my $joined3 = join("|", "a", "b", "c");
e33900b @coke pugs fudge
coke authored
24 #?pugs todo
53330f8 Test suite refactoring.
cosimo authored
25 is($joined3, "a|b|c", 'join("|", 1, 2, 3) works');
26
27 my $joined4 = join("|", [ "a", "b", "c" ]);
e33900b @coke pugs fudge
coke authored
28 #?pugs todo
53330f8 Test suite refactoring.
cosimo authored
29 is($joined4, "a b c", 'join("|", []) should not join anything');
30
49d046f .join now defaults to ''
lwall authored
31 # join() without a separator (defaults to '', per S32)
32 is(<a b c>.join, 'abc', 'join() separator defaults to "".');
f4a0042 [gsoc_spectest] Changed tests for "foo".join() to make more sense. Al…
Auzon authored
33
53330f8 Test suite refactoring.
cosimo authored
34 # join() with $sep as a variable
35
36 my $sep = ", ";
37
38 is(["a", "b", "c"].join($sep), "a, b, c", '[].join($sep) works');
39
40 is(@list.join($sep), "a, b, c", '@list.join($sep) works');
41
42 my $joined2a = join($sep, @list);
e33900b @coke pugs fudge
coke authored
43 #?pugs todo
53330f8 Test suite refactoring.
cosimo authored
44 is($joined2a, "a, b, c", 'join($sep, @list) works');
45
46 my $joined3a = join($sep, "a", "b", "c");
e33900b @coke pugs fudge
coke authored
47 #?pugs todo
53330f8 Test suite refactoring.
cosimo authored
48 is($joined3a, "a, b, c", 'join($sep, "a", "b", "c") works');
49
50 my $joined4a = join($sep, [ "a", "b", "c" ]);
e33900b @coke pugs fudge
coke authored
51 #?pugs todo
53330f8 Test suite refactoring.
cosimo authored
52 is($joined4a, "a b c", 'join($sep, []) works');
53
54 # join ... without parens
55
56 my $joined2b = join $sep, @list;
e33900b @coke pugs fudge
coke authored
57 #?pugs todo
53330f8 Test suite refactoring.
cosimo authored
58 is($joined2b, "a, b, c", 'join $sep, @list works');
59
60 my $joined2c = join ":", @list;
e33900b @coke pugs fudge
coke authored
61 #?pugs todo
53330f8 Test suite refactoring.
cosimo authored
62 is($joined2c, "a:b:c", 'join ":", @list works');
63
64 my $joined3b = join $sep, "a", "b", "c";
e33900b @coke pugs fudge
coke authored
65 #?pugs todo
53330f8 Test suite refactoring.
cosimo authored
66 is($joined3b, "a, b, c", 'join $sep, "a", "b", "c" works');
67
68 my $joined3c = join ":", "a", "b", "c";
e33900b @coke pugs fudge
coke authored
69 #?pugs todo
53330f8 Test suite refactoring.
cosimo authored
70 is($joined3c, "a:b:c", 'join(":", "a", "b", "c") works');
71
72 my $joined4b = join $sep, [ "a", "b", "c" ];
e33900b @coke pugs fudge
coke authored
73 #?pugs todo
53330f8 Test suite refactoring.
cosimo authored
74 is($joined4b, "a b c", 'join $sep, [] should not join anything');
75
76 my $joined4c = join ":", [ "a", "b", "c" ];
e33900b @coke pugs fudge
coke authored
77 #?pugs todo
53330f8 Test suite refactoring.
cosimo authored
78 is($joined4c, "a b c", 'join ":", [] should not join anything');
79
13cc9c4 [t/spec] 71 typos in 32 files.
Util authored
80 # join() with empty string as separator
53330f8 Test suite refactoring.
cosimo authored
81
82 is(["a", "b", "c"].join(''), "abc", '[].join("") works');
83
1e0f570 [t/spec]: Eliminate some "Redeclared variable" warnings in tests
pmichaud authored
84 @list = ("a", "b", "c");
53330f8 Test suite refactoring.
cosimo authored
85
86 is(@list.join(''), "abc", '@list.join("") works');
87
88 my $joined2d = join('', @list);
e33900b @coke pugs fudge
coke authored
89 #?pugs todo
53330f8 Test suite refactoring.
cosimo authored
90 is($joined2d, "abc", 'join("", @list) works');
91
92 my $joined3d = join('', "a", "b", "c");
e33900b @coke pugs fudge
coke authored
93 #?pugs todo
53330f8 Test suite refactoring.
cosimo authored
94 is($joined3d, "abc", 'join("", 1, 2, 3) works');
95
96 my $joined4d = join("", [ "a", "b", "c" ]);
e33900b @coke pugs fudge
coke authored
97 #?pugs todo
53330f8 Test suite refactoring.
cosimo authored
98 is($joined4d, "a b c", 'join("", []) works');
99
100 # some odd edge cases
101
102 my $undefined;
103 my @odd_list1 = (1, $undefined, 2, $undefined, 3);
104
105 my $joined2e = join(':', @odd_list1);
e33900b @coke pugs fudge
coke authored
106 #?pugs todo
53330f8 Test suite refactoring.
cosimo authored
107 is($joined2e, "1::2::3", 'join(":", @odd_list1) works');
108
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
109 my @odd_list2 = (1, Mu, 2, Mu, 3);
53330f8 Test suite refactoring.
cosimo authored
110
111 my $joined2f = join(':', @odd_list2);
dc27da8 @coke pugs fudge - Mu
coke authored
112 #?pugs todo
53330f8 Test suite refactoring.
cosimo authored
113 is($joined2f, "1::2::3", 'join(":", @odd_list2) works');
114
115 # should these even be tests ???
116
117 my $joined1d = ("a", "b", "c").join('');
118 is($joined1d, "abc", '().join("") should dwim');
119
120 my $joined1 = ("a", "b", "c").join("|");
121 is($joined1, "a|b|c", '().join("|") should dwim');
122
123 my $joined1a = ("a", "b", "c").join($sep);
124 is($joined1a, "a, b, c", '().join($sep) should dwim');
125
e33900b @coke pugs fudge
coke authored
126 #?pugs todo
53330f8 Test suite refactoring.
cosimo authored
127 is(join("!", "hi"), "hi", "&join works with one-element lists (1)");
e33900b @coke pugs fudge
coke authored
128 #?pugs todo
53330f8 Test suite refactoring.
cosimo authored
129 is(join("!", <hi>), "hi", "&join works with one-element lists (2)");
130 is(("hi",).join("!"), "hi", "&join works with one-element lists (3)");
131
6859c82 S29-list/join.t
pmichaud authored
132
53330f8 Test suite refactoring.
cosimo authored
133 # Similar as with .kv: (42).kv should die, but (42,).kv should work.
6859c82 S29-list/join.t
pmichaud authored
134
135 ## <pmichaud>: I think the following two tests are likely incorrect.
ccace72 [t/spec] fix smartlinks in S32-list
moritz authored
136 ## Prior to r20722 S32::Containers gave the following definitions for C<join>:
6859c82 S29-list/join.t
pmichaud authored
137 ## our Str multi method join ( $separator: @values )
138 ## our Str multi join ( Str $separator = ' ', *@values )
139 ## Neither of these allows C< @list.join('sep') > to work.
ccace72 [t/spec] fix smartlinks in S32-list
moritz authored
140 ## In r20722 I changed S32::Containers to read
6859c82 S29-list/join.t
pmichaud authored
141 ## our Str multi method join ( @values: $separator = ' ' )
142 ## our Str multi join ( Str $separator = ' ', *@values )
143 ## This enables C< @list.join('sep') > to work, but now
144 ## C< 'foo'.join(':') > through method fallback is equivalent
145 ## to C< join('foo', ':') >, which results in ':' and not 'foo'.
146 ## Same is true for C< ('foo').join(':') >.
e90d4b6 [spec] S29-list/join.t: backed tests withe quotes from TimToady, since I
moritz authored
147 #
148 ## from http://www.nntp.perl.org/group/perl.perl6.language/2008/06/msg29283.html
149 #
150 # Larry Wall writes:
151 #
152 ## On Sat, Jun 14, 2008 at 01:46:10PM +0200, Moritz Lenz wrote:
153 ## : Fallback semantics in S12 suggest that since no matching multi method is
154 ## : found, subs are tried - that is, the expression is interpreted as
155 ## : join('str', 'other_str')
ccace72 [t/spec] fix smartlinks in S32-list
moritz authored
156 ## : yielding 'other_str'. t/spec/S32::Containers-list/join.t disagrees, and wants the
e90d4b6 [spec] S29-list/join.t: backed tests withe quotes from TimToady, since I
moritz authored
157 ## : result to be 'str'.
3992cea [t] added named arg tests for join
frew authored
158 ##
e90d4b6 [spec] S29-list/join.t: backed tests withe quotes from TimToady, since I
moritz authored
159 ## I want the result to be 'str'.
6859c82 S29-list/join.t
pmichaud authored
160
f4a0042 [gsoc_spectest] Changed tests for "foo".join() to make more sense. Al…
Auzon authored
161 is('hi'.join(':'), 'hi', '"foo".join(":") should be the same as join(":", "foo")');
162 is(('hi').join(':'), 'hi', '("foo").join(":") should be the same as join(":", "foo")');
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
163
164 # vim: ft=perl6
Something went wrong with that request. Please try again.