Permalink
Browse files

s:g/CSV/Text::CSV/

  • Loading branch information...
1 parent d987425 commit 5e8e0ba3c399bef24879982dcb852e32acb1c202 @masak committed Aug 20, 2009
Showing with 15 additions and 13 deletions.
  1. +3 −3 lib/{ → Text}/CSV.pm
  2. +2 −2 t/01-lines.t
  3. +2 −2 t/02-commas.t
  4. +8 −6 t/03-quotes.t
@@ -1,4 +1,4 @@
-grammar CSV::Line {
+grammar Text::CSV::Line {
rule TOP { ^ <value> ** ',' $ }
rule value {
| <pure_text>
@@ -10,15 +10,15 @@ grammar CSV::Line {
regex pure_text { [<!before <['",]>> \S]+ }
}
-class CSV {
+class Text::CSV {
sub extract_text($m) {
return ($m<single_quote_contents>
// $m<double_quote_contents>
// $m).Str;
}
sub parse_line($line) {
- CSV::Line.parse($line)
+ Text::CSV::Line.parse($line)
or die "Sorry, cannot parse: ", $line;
}
View
@@ -1,10 +1,10 @@
use v6;
use Test;
-use CSV;
+use Text::CSV;
sub ok_becomes($input, $output, $description = '') {
- is_deeply CSV.read($input), $output, $description;
+ is_deeply Text::CSV.read($input), $output, $description;
}
ok_becomes q[[[foo
View
@@ -1,10 +1,10 @@
use v6;
use Test;
-use CSV;
+use Text::CSV;
sub ok_becomes($input, $output, $description = '') {
- is_deeply CSV.read($input), $output, $description;
+ is_deeply Text::CSV.read($input), $output, $description;
}
ok_becomes q[[[foo,bar,baz
View
@@ -1,10 +1,10 @@
use v6;
use Test;
-use CSV;
+use Text::CSV;
sub ok_becomes($input, $output, $description = '') {
- is_deeply CSV.read($input), $output, $description;
+ is_deeply Text::CSV.read($input), $output, $description;
}
ok_becomes q[[[foo,bar,baz
@@ -15,11 +15,13 @@ ok_becomes q[[[foo,bar,baz
"foo","bar","baz"
"foo","bar" , "baz"]]], [ [<foo bar baz>] xx 3 ], 'double quotes';
-dies_ok { CSV.read(q[[[foo,ba'r,ba'z]]]) }, 'mid-string single quotes illegal';
-dies_ok { CSV.read(q[[[foo,ba"r,ba"z]]]) }, 'mid-string double quotes illegal';
+dies_ok { Text::CSV.read(q[[[foo,ba'r,ba'z]]]) },
+ 'mid-string single quotes illegal';
+dies_ok { Text::CSV.read(q[[[foo,ba"r,ba"z]]]) },
+ 'mid-string double quotes illegal';
-is +CSV.read(q[[[foo,'bar,baz']]])[0], 2, 'can single-quote commas';
-is +CSV.read(q[[[foo,"bar,baz"]]])[0], 2, 'can double-quote commas';
+is +Text::CSV.read(q[[[foo,'bar,baz']]])[0], 2, 'can single-quote commas';
+is +Text::CSV.read(q[[[foo,"bar,baz"]]])[0], 2, 'can double-quote commas';
done_testing;

0 comments on commit 5e8e0ba

Please sign in to comment.