From e87f4bbe99e6b907050f6ab6d8c56d17309b9107 Mon Sep 17 00:00:00 2001 From: colomon Date: Fri, 26 Mar 2010 04:10:22 +0000 Subject: [PATCH] [t/spec] Redo split.t to use .join(',') for testing rather than is_deeply, as the latter does not really work with iterators. git-svn-id: http://svn.pugscode.org/pugs@30204 c213334d-75ef-0310-aa23-eaa082d1ae64 --- t/spec/S32-str/split.t | 307 +++++++++++++++++++++++++------------------------ 1 file changed, 154 insertions(+), 153 deletions(-) rewrite t/spec/S32-str/split.t (65%) diff --git a/t/spec/S32-str/split.t b/t/spec/S32-str/split.t dissimilarity index 65% index 0efb39120..bd5c95e39 100644 --- a/t/spec/S32-str/split.t +++ b/t/spec/S32-str/split.t @@ -1,153 +1,154 @@ -use v6; - -use Test; - -# L - -# XXX - this needs to be updated when Str.split(Str) works again -# this test really wants is_deeply() -# and got it, except for a couple of cases that fail because of Match objects -# being returned -- Aankhen -plan 25; - -# split on an empty string - -my %ords = ( - 1 => 'first', - 2 => 'second', - 3 => 'third', - 4 => 'fourth', - 5 => 'fifth', - 6 => 'sixth', - 7 => 'seventh', - 8 => 'eighth', - 9 => 'ninth', -); - -#?rakudo skip 'named arguments to split()' -is_deeply split(:input("fiSMBoC => fREW is Station's Most Bodacious Creation"), " "), - qw/fiSMBoC => fREW is Station's Most Bodacious Creation/, - q{split(:input(Str), " "}; - -#?rakudo skip 'named arguments to split()' -is_deeply split(:input("UNIFICATIONS => Unions Normally Identified From Initial Characters; Aesthetically Tailored to Infer Other Notions Subconsciously"), /\s+/), - qw/UNIFICATIONS => Unions Normally Identified From Initial Characters; Aesthetically Tailored to Infer Other Notions Subconsciously/, - q{split(:input(Str), /\s+/}; - -is_deeply split("", "forty-two"), - , - q{split "", Str}; - -# split on a space -is_deeply split(' ', 'split this string'), - , - q{split ' ', Str}; - -# split on a single character delimiter -is_deeply split('$', 'try$this$string'), - , - q{split '$', Str}; - -# split on a multi-character delimiter -is_deeply split(', ', "comma, separated, values"), - , - q{split ', ', Str}; - -# split on a variable delimiter - -my $delimiter = '::'; -is_deeply split($delimiter, "Perl6::Pugs::Test"), - , - q{split $delimiter, Str}; - -# split with a reg-exp -#?rakudo skip 'rx:Perl5' -is_deeply split(rx:Perl5 {,}, "split,me"), - qw/split me/, - q/split rx:Perl5 {,}, Str/; - -# split on multiple space characters -#?rakudo skip 'rx:Perl5' -is_deeply split(rx:Perl5 {\s+}, "Hello World Goodbye Mars"), - qw/Hello World Goodbye Mars/, - q/split rx:Perl5 {\s+}, Str/; - -#?rakudo skip 'FixedIntegerArray: index out of bounds!' -is_deeply split(rx:Perl5 {(\s+)}, "Hello test", :all), - ('Hello', ("Hello test" ~~ rx:Perl5 {(\s+)}), 'test'), - q/split rx:Perl5 {(\s+)}, Str/; - -is_deeply "to be || ! to be".split(' '), - , - q/Str.split(' ')/; - -#?rakudo skip 'rx:Perl5' -is_deeply "this will be split".split(rx:Perl5 { }), - , - q/Str.split(rx:Perl5 { })/; - -# split on multiple space characters -#?rakudo skip 'rx:Perl5' -is_deeply split(rx:Perl5 {\s+}, "Hello World Goodbye Mars", 3), - ( , "Goodbye Mars" ), - q/split rx:Perl5 {\s+}, Str, limit/; - -is_deeply split(" ", "Hello World Goodbye Mars", 3), - ( , " Goodbye Mars" ), - q/split " ", Str, limit/; - -#?rakudo skip 'rx:Perl5' -is_deeply "Hello World Goodbye Mars".split(rx:Perl5 {\s+}, 3), - ( , "Goodbye Mars" ), - q/Str.split(rx:Perl5 {\s+}, limit)/; - -is_deeply "Hello World Goodbye Mars".split(" ", 3), - ( , " Goodbye Mars" ), - q/Str.split(" ", limit)/; - -is_deeply "Word".split("", 3), , - q/Str.split("", limit)/; - - -#L -dies_ok {" abc def ".split()}, q/Str.split() disallowed/; - -# This one returns an empty list -is list("".split('')).elems, 0, q/"".split()/; - -# ... yet this one does not (different to p5). -# blessed by $Larry at Message-ID: <20060118191046.GB32562@wall.org> -is list("".split(':')).elems, 1, q/"".split(':')/; - -# using /.../ -is_deeply "a.b".split(/\./), , - q{"a.b".split(/\./)}; - -#?rakudo skip 'loops on zero-width match' -{ - is_deeply "abcd".split(//), , - q{"abcd".split(//)};() -} - -#?rakudo skip 'Null PMC access in invoke()' -{ - ' ' ~~ /(\s)/; - - if $0 eq ' ' { - is_deeply "foo bar baz".split(//), , - q{"foo bar baz".split(//)}; - } else { - skip q{' ' ~~ /\s/ did not result in ' '}; - } -} - -# RT #63066 -#?rakudo skip 'RT #63066 loops forever' -{ - is_deeply 'hello-world'.split(//), , - q{'hello-world'.split(//)}; - is_deeply 'hello-world'.split(//), , - q{'hello-world'.split(//)}; -} - -# vim: ft=perl6 +use v6; + +use Test; + +# L + +# XXX - this needs to be updated when Str.split(Str) works again +# this test really wants is_deeply() +# and got it, except for a couple of cases that fail because of Match objects +# being returned -- Aankhen +plan 25; + +# split on an empty string + +my %ords = ( + 1 => 'first', + 2 => 'second', + 3 => 'third', + 4 => 'fourth', + 5 => 'fifth', + 6 => 'sixth', + 7 => 'seventh', + 8 => 'eighth', + 9 => 'ninth', +); + +#?rakudo skip 'named arguments to split()' +is split(:input("fiSMBoC => fREW is Station's Most Bodacious Creation"), " ").join(','), + qw/fiSMBoC => fREW is Station's Most Bodacious Creation/.join(','), + q{split(:input(Str), " "}; + +#?rakudo skip 'named arguments to split()' +is split(:input("UNIFICATIONS => Unions Normally Identified From Initial Characters; Aesthetically Tailored to Infer Other Notions Subconsciously"), /\s+/).join(','), + qw/UNIFICATIONS => Unions Normally Identified From Initial Characters; Aesthetically Tailored to Infer Other Notions Subconsciously/.join(','), + q{split(:input(Str), /\s+/}; + +is split("", "forty-two").join(','), + .join(','), + q{split "", Str}; + +# split on a space +is split(' ', 'split this string').join(','), + .join(','), + q{split ' ', Str}; + +# split on a single character delimiter +is split('$', 'try$this$string').join(','), + .join(','), + q{split '$', Str}; + +# split on a multi-character delimiter +is split(', ', "comma, separated, values").join(','), + .join(','), + q{split ', ', Str}; + +# split on a variable delimiter + +my $delimiter = '::'; +is split($delimiter, "Perl6::Pugs::Test").join(','), + .join(','), + q{split $delimiter, Str}; + +# split with a reg-exp +#?rakudo skip 'rx:Perl5' +is split(rx:Perl5 {,}, "split,me").join(','), + qw/split me/.join(','), + q/split rx:Perl5 {,}, Str/; + +# split on multiple space characters +#?rakudo skip 'rx:Perl5' +is split(rx:Perl5 {\s+}, "Hello World Goodbye Mars").join(','), + qw/Hello World Goodbye Mars/.join(','), + q/split rx:Perl5 {\s+}, Str/; + +#?rakudo skip 'FixedIntegerArray: index out of bounds!' +is split(rx:Perl5 {(\s+)}, "Hello test", :all).join(','), + ('Hello', ("Hello test" ~~ rx:Perl5 {(\s+)}), 'test').join(','), + q/split rx:Perl5 {(\s+)}, Str/; + +is "to be || ! to be".split(' ').join(','), + .join(','), + q/Str.split(' ')/; + +#?rakudo skip 'rx:Perl5' +is "this will be split".split(rx:Perl5 { }).join(','), + .join(','), + q/Str.split(rx:Perl5 { })/; + +# split on multiple space characters +#?rakudo skip 'rx:Perl5' +is split(rx:Perl5 {\s+}, "Hello World Goodbye Mars", 3).join(','), + ( , "Goodbye Mars" ).join(','), + q/split rx:Perl5 {\s+}, Str, limit/; + +is split(" ", "Hello World Goodbye Mars", 3).join(','), + ( , " Goodbye Mars" ).join(','), + q/split " ", Str, limit/; + +#?rakudo skip 'rx:Perl5' +is "Hello World Goodbye Mars".split(rx:Perl5 {\s+}, 3).join(','), + ( , "Goodbye Mars" ).join(','), + q/Str.split(rx:Perl5 {\s+}, limit)/; + +is "Hello World Goodbye Mars".split(" ", 3).join(','), + ( , " Goodbye Mars" ).join(','), + q/Str.split(" ", limit)/; + +is "Word".split("", 3).join(','), .join(','), + q/Str.split("", limit)/; + + +#L +dies_ok {" abc def ".split()}, q/Str.split() disallowed/; + +# This one returns an empty list +#?rakudo todo "Empty split on empty yields a single result" +is "".split('').elems, 0, q/"".split()/; + +# ... yet this one does not (different to p5). +# blessed by $Larry at Message-ID: <20060118191046.GB32562@wall.org> +is "".split(':').elems, 1, q/"".split(':')/; + +# using /.../ +is "a.b".split(/\./).join(','), .join(','), + q{"a.b".split(/\./)}; + +#?rakudo skip 'loops on zero-width match' +{ + is "abcd".split(//).join(','), .join(','), + q{"abcd".split(//)};() +} + +#?rakudo skip 'Null PMC access in invoke()' +{ + ' ' ~~ /(\s)/; + + if $0 eq ' ' { + is "foo bar baz".split(//).join(','), .join(','), + q{"foo bar baz".split(//)}; + } else { + skip q{' ' ~~ /\s/ did not result in ' '}; + } +} + +# RT #63066 +#?rakudo skip 'RT #63066 loops forever' +{ + is 'hello-world'.split(//).join(','), .join(','), + q{'hello-world'.split(//)}; + is 'hello-world'.split(//).join(','), .join(','), + q{'hello-world'.split(//)}; +} + +# vim: ft=perl6 -- 2.11.4.GIT