-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CSV::TSV class for tab-separated values #319
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6b22a09
Add TSV class
jsxs0 3414adb
Simplify CSV::TSV implementation to only override initialize
jsxs0 a5504e3
Add TSV tests and fix test runner
jsxs0 e1b962a
Revert run-test.rb changes - will address Ractor warnings separately
jsxs0 afea032
Update test/csv/test_tsv.rb
jsxs0 d08ebc6
Update TSV class references
jsxs0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,38 @@ | ||
#!/usr/bin/env ruby | ||
|
||
# Disable Ractor experimental warning | ||
Warning[:experimental] = false | ||
|
||
$VERBOSE = true | ||
|
||
$LOAD_PATH.unshift("test") | ||
$LOAD_PATH.unshift("test/lib") | ||
$LOAD_PATH.unshift("lib") | ||
|
||
require "test/unit" | ||
|
||
# Configure test-unit for better stability | ||
Test::Unit::AutoRunner.need_auto_run = false | ||
|
||
# Track test execution status | ||
failed_tests = [] | ||
|
||
Dir.glob("test/csv/**/*test_*.rb") do |test_rb| | ||
# Ensure we only load syntax that we can handle | ||
next if RUBY_VERSION < "2.7" && test_rb.end_with?("test_patterns.rb") | ||
|
||
require File.expand_path(test_rb) | ||
begin | ||
require File.expand_path(test_rb) | ||
rescue => e | ||
puts "Error loading #{test_rb}: #{e.message}" | ||
puts e.backtrace | ||
failed_tests << test_rb | ||
end | ||
end | ||
|
||
# Run tests with custom configuration | ||
runner = Test::Unit::AutoRunner.new(true) | ||
runner.process_args([]) | ||
|
||
# Exit with failure if any tests failed | ||
exit(failed_tests.empty? && runner.run ? 0 : 1) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require_relative "helper" | ||
|
||
class TestTSV < Test::Unit::TestCase | ||
def test_default_separator | ||
tsv = TSV.new(String.new) | ||
jsxs0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
assert_equal("\t", tsv.col_sep) | ||
end | ||
|
||
def test_override_separator | ||
tsv = TSV.new(String.new, col_sep: ",") | ||
assert_equal(",", tsv.col_sep) | ||
end | ||
|
||
def test_read_tsv_data | ||
data = "a\tb\tc\n1\t2\t3" | ||
result = TSV.parse(data) | ||
assert_equal([["a", "b", "c"], ["1", "2", "3"]], result.to_a) | ||
end | ||
|
||
def test_write_tsv_data | ||
output = String.new | ||
TSV.generate(output) do |tsv| | ||
tsv << ["a", "b", "c"] | ||
tsv << ["1", "2", "3"] | ||
end | ||
assert_equal("a\tb\tc\n1\t2\t3\n", output) | ||
end | ||
|
||
def test_inheritance | ||
assert_kind_of(CSV, TSV.new(String.new)) | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to change this file?
I think that we don't need to change this file but if you think that we need to change this file, could you open a separated PR?