ruby / stringio

Pseudo `IO` class from/to `String`.
BSD 2-Clause "Simplified" License
33 stars 26 forks source link

Update getline logic to match C version #61

Closed headius closed 1 year ago

headius commented 1 year ago

See commits:

headius commented 1 year ago

No rush on this. It fixes two new rubyspecs for altered paragraph behavior:

1)
StringIO#each_line when passed a separator yields each paragraph with all separation characters when passed an empty String as separator FAILED
Expected ["para1\n" + "\n", "para2\n" + "\n", "para3"] == ["para1\n" + "\n", "para2\n" + "\n" + "\n", "para3"]
to be truthy but was false
/Users/headius/work/jruby/spec/ruby/library/stringio/shared/each.rb:53:in `block in <main>'
org/jruby/RubyBasicObject.java:2613:in `instance_exec'
org/jruby/RubyArray.java:4920:in `all?'
org/jruby/RubyArray.java:1989:in `each'
/Users/headius/work/jruby/spec/ruby/library/stringio/each_line_spec.rb:5:in `<main>'
org/jruby/RubyKernel.java:1105:in `load'
org/jruby/RubyBasicObject.java:2613:in `instance_exec'
org/jruby/RubyArray.java:1989:in `each'

2)
StringIO#each when passed a separator yields each paragraph with all separation characters when passed an empty String as separator FAILED
Expected ["para1\n" + "\n", "para2\n" + "\n", "para3"] == ["para1\n" + "\n", "para2\n" + "\n" + "\n", "para3"]
to be truthy but was false
/Users/headius/work/jruby/spec/ruby/library/stringio/shared/each.rb:53:in `block in <main>'
org/jruby/RubyBasicObject.java:2613:in `instance_exec'
org/jruby/RubyArray.java:4920:in `all?'
org/jruby/RubyArray.java:1989:in `each'
/Users/headius/work/jruby/spec/ruby/library/stringio/each_spec.rb:5:in `<main>'
org/jruby/RubyKernel.java:1105:in `load'
org/jruby/RubyBasicObject.java:2613:in `instance_exec'
org/jruby/RubyArray.java:1989:in `each'
kou commented 1 year ago

It seems that this fixes test_each_string_sep but these referred commits update test_gets_chomp, test_gets_chomp_eol and test_each. They are still failing. Is it intentional? (They will be fixed later?)

headius commented 1 year ago

@kou Oh I will look into that!

headius commented 1 year ago

@kou Those tests were added with a separate "partial fix" I missed. I've applied the same fix for JRuby and those tests pass now.

See ruby/stringio@feaa2ec63176c2a9d77bda354ef68f3e7eb66e1a