Created
August 27, 2015 11:03
-
-
Save anonymous/e3ab90806f82cd349493 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/Text/CSV.pm b/lib/Text/CSV.pm | |
index 3d76f8f..688b6e5 100644 | |
--- a/lib/Text/CSV.pm | |
+++ b/lib/Text/CSV.pm | |
@@ -293,8 +293,8 @@ class CSV::Row does Iterable does Positional { | |
method Str { $!csv ?? $!csv.string (@!fields) !! Str; } | |
method iterator { [ @.fields ].iterator; } | |
- method hash { hash $!csv.column_names Z @!fields».Str; } | |
- method AT-KEY (Str $k) { %($!csv.column_names Z @!fields){$k}; } | |
+ method hash { hash $!csv.column_names Z=> @!fields».Str; } | |
+ method AT-KEY (Str $k) { %($!csv.column_names Z=> @!fields){$k}; } | |
method list () { @!fields».Str; } | |
method AT-POS (int $i) { @!fields[$i]; } | |
@@ -660,7 +660,7 @@ $hook.perl.say; | |
multi method colrange (Str $range) returns Array[Int] { | |
@!crange = (); | |
- $range.defined and @!crange = self!rfc7111ranges ($range).to_list; | |
+ $range.defined and @!crange = self!rfc7111ranges ($range).to_list.flat; | |
@!crange; | |
} | |
@@ -762,7 +762,7 @@ $hook.perl.say; | |
} | |
method list () { | |
- self.fields».Str; | |
+ self.fields».Str.Array; | |
} | |
multi method string () returns Str { | |
@@ -1191,7 +1191,7 @@ $hook.perl.say; | |
method !row_hr (@row) { | |
my @cn = (@!crange ?? @!cnames[@!crange] !! @!cnames); | |
- hash @cn Z @row; | |
+ hash @cn Z=> @row; | |
} | |
multi method getline_hr (Str $str, Bool :$meta = $!keep_meta) { | |
@@ -1235,8 +1235,8 @@ $hook.perl.say; | |
$hr or return [ @row ]; | |
my @cn = (@!crange ?? @!cnames[@!crange] !! @!cnames); | |
- my %hash = @cn Z @row; | |
- { %hash }; | |
+ my %hash = @cn Z=> @row; | |
+ %hash; | |
} | |
# @a = $csv.getline_all ($io); | |
@@ -1265,7 +1265,7 @@ $hook.perl.say; | |
!%!callbacks<filter>.defined || | |
%!callbacks<filter>.($!csv-row) or next; | |
- @lines.push: self!row ($meta, $hr); | |
+ @lines.push: $[self!row ($meta, $hr)]; | |
} | |
} | |
else { | |
@@ -1275,7 +1275,7 @@ $hook.perl.say; | |
%!callbacks<filter>.($!csv-row) or next; | |
@lines.elems == $offset and @lines.shift; | |
- @lines.push: self!row ($meta, $hr); | |
+ @lines.push: $[self!row ($meta, $hr)]; | |
} | |
$length >= 0 && @lines.elems > $length and @lines.splice ($length); | |
} | |
@@ -1344,7 +1344,7 @@ $hook.perl.say; | |
my @row = $meta ?? @f !! @f.map (*.Str); | |
if (@!cnames.elems) { | |
- my %h = @!cnames Z @row; | |
+ my %h = @!cnames Z=> @row; | |
@lines.push: { %h }; | |
next; | |
} | |
diff --git a/t/50_utf8.t b/t/50_utf8.t | |
index 9a7aac8..9f15fb1 100644 | |
--- a/t/50_utf8.t | |
+++ b/t/50_utf8.t | |
@@ -53,7 +53,7 @@ SKIP: { | |
my $fh = open $file, :r; | |
my @row; | |
- ok (@row = $csv.getline ($fh), "read/parse"); | |
+ ok ((@row = $csv.getline ($fh)), "read/parse"); | |
is (@row[0].is_quoted, True, "First field is quoted"); | |
is (@row[1].is_quoted, False, "Second field is not quoted"); | |
@@ -96,15 +96,15 @@ $fh = open "_50test.csv", :r; | |
ok ($csv.auto_diag (1), "auto diag"); | |
ok ($csv.binary (1), "set binary"); | |
-ok (my @row = $csv.getline ($fh), "parse"); | |
+ok ((my @row = $csv.getline ($fh)), "parse"); | |
is ($csv.is_binary (0), False, "not binary"); | |
is (@row[0].text, "euro", "euro"); | |
is ($csv.is_utf8 (1), False, "not utf8"); | |
-ok (@row = $csv.getline ($fh), "parse"); | |
+ok ((@row = $csv.getline ($fh)), "parse"); | |
is ($csv.is_binary (0), True, "is binary"); | |
is (@row[0].text, "\x[20ac]", "euro"); | |
is (@row[0].is_utf8, True, "is utf8"); | |
-ok (@row = $csv.getline ($fh), "parse"); | |
+ok ((@row = $csv.getline ($fh)), "parse"); | |
is ($csv.is_binary (0), False, "not binary"); | |
is (@row[0].text, "euro", "euro"); | |
is (@row[0].is_utf8, False, "not utf8"); | |
diff --git a/t/77_getall.t b/t/77_getall.t | |
index e6f720e..0c4795c 100644 | |
--- a/t/77_getall.t | |
+++ b/t/77_getall.t | |
@@ -58,8 +58,7 @@ for ("\n", "\r") -> $eol { | |
my $s_args = @args.join (", "); | |
my $fh = open $tfn, :r or die "$tfn: $!"; | |
- # un-obj for is-deeply | |
- my @f = un-obj ($csv.getline_all ($fh, |@args)); | |
+ my @f = $csv.getline_all ($fh, |@args); | |
is-deeply (@f, @exp, "getline_all ($s_args)"); | |
$fh.close; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment