Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 177 lines (149 sloc) 6.098 kb
58135b30 » moritz
2008-05-08 [t/spec] changed 'use v6-alpha;' to 'use v6;'
1 use v6;
f199a9db » cosimo
2008-01-12 Test suite refactoring (spec/S29)
2
3 use Test;
4
8b957839 » lizmat
2013-11-07 Remove ~6 year old cruft
5 # L<S32-setting-library/Str"=item split">
f199a9db » cosimo
2008-01-12 Test suite refactoring (spec/S29)
6
b1ac97a1 » TimToady
2013-12-27 remove tests for <prior>
7 plan 53;
f199a9db » cosimo
2008-01-12 Test suite refactoring (spec/S29)
8
390c3b79 » lizmat
2013-11-07 Some more thorough split testing
9 # split on empty string
ddfbc570 » coke
2012-01-04 niecza fudge
10 #?niecza todo "split on empty string has leading empty elements"
390c3b79 » lizmat
2013-11-07 Some more thorough split testing
11 {
12 is split("", "forty-two").join(','), 'f,o,r,t,y,-,t,w,o',
13 q{split "", Str};
14 is "forty-two".split("").join(','), 'f,o,r,t,y,-,t,w,o',
15 q{Str.split: ""};
16
17 is split("", "forty-two", 3).join(','), 'f,o,rty-two',
18 q{split "", Str};
19 is "forty-two".split("",3).join(','), 'f,o,rty-two',
20 q{Str.split: ""};
21 }
f199a9db » cosimo
2008-01-12 Test suite refactoring (spec/S29)
22
23 # split on a space
390c3b79 » lizmat
2013-11-07 Some more thorough split testing
24 {
25 is split(' ', 'split this string').join(','), 'split,this,string',
26 q{split ' ', Str};
27 is 'split this string'.split(' ').join(','), 'split,this,string',
28 q{Str.split: ' '};
29
30 is split(' ', 'split this string', 2).join(','), 'split,this string',
31 q{split ' ', Str, 2};
32 is 'split this string'.split(' ',2).join(','), 'split,this string',
33 q{Str.split: ' ', 2};
34 }
f199a9db » cosimo
2008-01-12 Test suite refactoring (spec/S29)
35
36 # split on a single character delimiter
390c3b79 » lizmat
2013-11-07 Some more thorough split testing
37 {
38 is split('$', 'try$this$string').join(','), 'try,this,string',
39 q{split '$', Str};
40 is 'try$this$string'.split('$').join(','), 'try,this,string',
41 q{Str.split: '$'};
42
43 is split('$', 'try$this$string',2).join(','), 'try,this$string',
44 q{split '$', Str, 2};
45 is 'try$this$string'.split('$',2).join(','), 'try,this$string',
46 q{Str.split: '$', 2};
47 }
f199a9db » cosimo
2008-01-12 Test suite refactoring (spec/S29)
48
49 # split on a multi-character delimiter
390c3b79 » lizmat
2013-11-07 Some more thorough split testing
50 {
51 is split(', ', "comma, separated, values").join('|'),
52 'comma|separated|values', q{split ', ', Str};
53 is "comma, separated, values".split(", ").join('|'),
54 'comma|separated|values', q{Str.split: ', '};
55
56 is split(', ', "comma, separated, values",2).join('|'),
57 'comma|separated, values', q{split ', ', Str,2};
58 is "comma, separated, values".split(", ",2).join('|'),
59 'comma|separated, values', q{Str.split: ', ',2};
60 }
f199a9db » cosimo
2008-01-12 Test suite refactoring (spec/S29)
61
62 # split on a variable delimiter
390c3b79 » lizmat
2013-11-07 Some more thorough split testing
63 {
64 my $del = '::';
65 is split($del, "Perl6::Camelia::Test").join(','), 'Perl6,Camelia,Test',
66 q{split $del, Str};
67 is 'Perl6::Camelia::Test'.split($del).join(','), 'Perl6,Camelia,Test',
68 q{Str.split: $del};
69
70 is split($del, "Perl6::Camelia::Test",2).join(','), 'Perl6,Camelia::Test',
71 q{split $del, Str,2};
72 is 'Perl6::Camelia::Test'.split($del,2).join(','), 'Perl6,Camelia::Test',
73 q{Str.split: $del,2};
74 }
f199a9db » cosimo
2008-01-12 Test suite refactoring (spec/S29)
75
390c3b79 » lizmat
2013-11-07 Some more thorough split testing
76 # split with a single char reg-exp
ddfbc570 » coke
2012-01-04 niecza fudge
77 #?niecza skip 'rx:Perl5'
390c3b79 » lizmat
2013-11-07 Some more thorough split testing
78 {
79 is split(rx:Perl5 {,},"split,me,please").join('|'), 'split|me|please',
80 'split rx:P5 {,},Str';
81 is 'split,me,please'.split(rx:Perl5 {,}).join('|'), 'split|me|please',
82 'Str.split: rx:P5 {,}';
83
84 is split(rx:Perl5 {,},"split,me,please",2).join('|'), 'split|me,please',
85 'split rx:P5 {,},Str,2';
86 is 'split,me,please'.split(rx:Perl5 {,},2).join('|'), 'split|me,please',
87 'Str.split: rx:P5 {,},2';
88 }
f199a9db » cosimo
2008-01-12 Test suite refactoring (spec/S29)
89
390c3b79 » lizmat
2013-11-07 Some more thorough split testing
90 # split on regex with any whitespace
ddfbc570 » coke
2012-01-04 niecza fudge
91 #?niecza skip 'rx:Perl5'
390c3b79 » lizmat
2013-11-07 Some more thorough split testing
92 {
93 is split(rx:Perl5 {\s+}, "Hello World Goodbye Mars").join(','),
94 'Hello,World,Goodbye,Mars', q/split rx:Perl5 {\s+}, Str/;
95 is 'Hello World Goodbye Mars'.split(rx:Perl5 {\s+}).join(','),
96 'Hello,World,Goodbye,Mars', q/Str.split: rx:Perl5 {\s+}/;
97
98 is split(rx:Perl5 {\s+}, "Hello World Goodbye Mars", 3).join(','),
99 'Hello,World,Goodbye Mars', q/split rx:Perl5 {\s+}, Str, 3/;
100 is 'Hello World Goodbye Mars'.split(rx:Perl5 {\s+}, 3).join(','),
101 'Hello,World,Goodbye Mars', q/Str.split: rx:Perl5 {\s+}, 3/;
102 }
f199a9db » cosimo
2008-01-12 Test suite refactoring (spec/S29)
103
ddfbc570 » coke
2012-01-04 niecza fudge
104 #?niecza skip 'rx:Perl5'
390c3b79 » lizmat
2013-11-07 Some more thorough split testing
105 {
106 is split(rx:Perl5 {(\s+)}, "Hello test", :all).join(','), 'Hello, ,test',
107 q/split rx:Perl5 {(\s+)}, Str/;
108 is "Hello test".split(rx:Perl5 {(\s+)}, :all).join(','), 'Hello, ,test',
109 q/Str.split rx:Perl5 {(\s+)}/;
110 }
f199a9db » cosimo
2008-01-12 Test suite refactoring (spec/S29)
111
ddfbc570 » coke
2012-01-04 niecza fudge
112 #?niecza skip 'rx:Perl5'
390c3b79 » lizmat
2013-11-07 Some more thorough split testing
113 {
114 is split(rx:Perl5 { },"this will be split").join(','), 'this,will,be,split',
115 q/split(rx:Perl5 { }, Str)/;
116 is "this will be split".split(rx:Perl5 { }).join(','), 'this,will,be,split',
117 q/Str.split(rx:Perl5 { })/;
118 is split(rx:Perl5 { },"this will be split",3).join(','),
119 'this,will,be split', q/split rx:Perl5 { }, Str,3)/;
120 is "this will be split".split(rx:Perl5 { },3).join(','),
121 'this,will,be split', q/Str.split: rx:Perl5 { },3/;
122 }
00b5ae99 » moritz
2009-07-12 [t/spec] simplified and corrected split.t
123
124 #L<S32::Str/Str/"no longer has a default delimiter">
125 dies_ok {" abc def ".split()}, q/Str.split() disallowed/;
f199a9db » cosimo
2008-01-12 Test suite refactoring (spec/S29)
126
127 # This one returns an empty list
ddfbc570 » coke
2012-01-04 niecza fudge
128 #?niecza todo '2 element list'
6dd356d3 » colomon
2010-03-26 [t/spec] Redo split.t to use .join(',') for testing rather than is_de…
129 is "".split('').elems, 0, q/"".split()/;
f199a9db » cosimo
2008-01-12 Test suite refactoring (spec/S29)
130
131 # ... yet this one does not (different to p5).
132 # blessed by $Larry at Message-ID: <20060118191046.GB32562@wall.org>
6dd356d3 » colomon
2010-03-26 [t/spec] Redo split.t to use .join(',') for testing rather than is_de…
133 is "".split(':').elems, 1, q/"".split(':')/;
f199a9db » cosimo
2008-01-12 Test suite refactoring (spec/S29)
134
135 # using /.../
6dd356d3 » colomon
2010-03-26 [t/spec] Redo split.t to use .join(',') for testing rather than is_de…
136 is "a.b".split(/\./).join(','), <a b>.join(','),
137 q{"a.b".split(/\./)};
f199a9db » cosimo
2008-01-12 Test suite refactoring (spec/S29)
138
9028e8c5 » lizmat
2013-09-03 Fudges for S32
139 #?rakudo skip 'No such method null for invocant of type Cursor'
ddfbc570 » coke
2012-01-04 niecza fudge
140 #?niecza skip 'Unable to resolve method null in class Cursor'
00b5ae99 » moritz
2009-07-12 [t/spec] simplified and corrected split.t
141 {
6dd356d3 » colomon
2010-03-26 [t/spec] Redo split.t to use .join(',') for testing rather than is_de…
142 is "abcd".split(/<null>/).join(','), <a b c d>.join(','),
143 q{"abcd".split(/<null>/)};()
00b5ae99 » moritz
2009-07-12 [t/spec] simplified and corrected split.t
144 }
f199a9db » cosimo
2008-01-12 Test suite refactoring (spec/S29)
145
01f489e4 » colomon
2010-04-28 [t/spec] Add some simple tests for :all.
146 {
147 my @a = "hello world".split(/<[aeiou]>/, :all);
148 is +@a, 7, "split:all resulted in seven pieces";
149 isa_ok @a[1], Match, "second is a Match object";
150 isa_ok @a[3], Match, "fourth is a Match object";
151 isa_ok @a[5], Match, "sixth is a Match object";
152 is ~@a, ~("h", "e", "ll", "o", " w", "o", "rld"), "The pieces are correct";
153 }
154
809562bc » colomon
2010-04-28 [t/spec] Simple test that split handles captures correctly.
155 {
156 my @a = "hello world".split(/(<[aeiou]>)(.)/, :all);
157 is +@a, 7, "split:all resulted in seven pieces";
158 is ~@a, ~("h", "el", "l", "o ", "w", "or", "ld"), "The pieces are correct";
159 is @a[1][0], "e", "First capture worked";
160 is @a[1][1], "l", "Second capture worked";
161 is @a[3][0], "o", "Third capture worked";
162 is @a[3][1], " ", "Fourth capture worked";
163 }
164
2be4bcef » moritz
2011-01-31 [split.t] tests for RT #63066
165 # RT #63066
166 {
167 is 'hello-world'.split(/<.ws>/).join('|'), '|hello|-|world|',
390c3b79 » lizmat
2013-11-07 Some more thorough split testing
168 'zero-width delimiter (<.ws>)';
ddfbc570 » coke
2012-01-04 niecza fudge
169 #?niecza skip 'Unable to resolve method wb in class Cursor'
f45e8fef » felliott
2011-01-31 [split.t] fix typo in test
170 is 'hello-world'.split(/<.wb>/).join('|'), '|hello|-|world|',
390c3b79 » lizmat
2013-11-07 Some more thorough split testing
171 'zero-width delimiter (<.wb>)';
ddfbc570 » coke
2012-01-04 niecza fudge
172 #?niecza skip 'Unable to resolve method wb in class Cursor'
390c3b79 » lizmat
2013-11-07 Some more thorough split testing
173 is '-a-b-c-'.split(/<.wb>/).join('|'), '-|a|-|b|-|c|-',
174 'zero-width delimiter (<.wb>) (2)';
2be4bcef » moritz
2011-01-31 [split.t] tests for RT #63066
175 }
176
00b5ae99 » moritz
2009-07-12 [t/spec] simplified and corrected split.t
177 # vim: ft=perl6
Something went wrong with that request. Please try again.