Created
July 23, 2020 00:47
-
-
Save bjfish/36720052f4a9fbf08d95452cda0b69ac to your computer and use it in GitHub Desktop.
String#split work
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/CHANGELOG.md b/CHANGELOG.md | |
index 77a39c23ca..5da6d4b423 100644 | |
--- a/CHANGELOG.md | |
+++ b/CHANGELOG.md | |
@@ -1,20 +1,3 @@ | |
-# 20.3.0 | |
- | |
-New features: | |
- | |
- | |
-Bug fixes: | |
- | |
- | |
-Compatibility: | |
- | |
-* Run `at_exit` handlers even if parsing the main script fails (#2047). | |
-* Load required libraries (`-r`) before parsing the main script (#2047). | |
-* Fix `String#split` for 2.6 compatibility (#2052, @ssnickolay). | |
- | |
-Performance: | |
- | |
- | |
# 20.2.0 | |
New features: | |
diff --git a/src/main/ruby/truffleruby/core/splitter.rb b/src/main/ruby/truffleruby/core/splitter.rb | |
index bef4c98e94..1c4719bcb7 100644 | |
--- a/src/main/ruby/truffleruby/core/splitter.rb | |
+++ b/src/main/ruby/truffleruby/core/splitter.rb | |
@@ -63,7 +63,7 @@ module Truffle | |
awk_limit = limit < 0 ? -1 : limit | |
return Primitive.string_awk_split string, awk_limit, block | |
- elsif Primitive.object_kind_of?(pattern, Regexp) | |
+ elsif pattern.kind_of?(Regexp) | |
# Handle SPLIT_TYPE_REGEXP below | |
else | |
pattern = StringValue(pattern) | |
diff --git a/src/main/ruby/truffleruby/core/string.rb b/src/main/ruby/truffleruby/core/string.rb | |
index 66e56c1c0e..6ed600c7f4 100644 | |
--- a/src/main/ruby/truffleruby/core/string.rb | |
+++ b/src/main/ruby/truffleruby/core/string.rb | |
@@ -885,6 +885,9 @@ class String | |
maybe_chomp = ->(str) { chomp ? str.chomp(sep) : str } | |
sep = StringValue(sep) | |
+ if sep == DEFAULT_RECORD_SEPARATOR && !encoding.ascii_compatible? | |
+ sep = sep.encode(encoding) | |
+ end | |
pos = 0 | |
diff --git a/test/mri/excludes/TestString.rb b/test/mri/excludes/TestString.rb | |
index 2ca455e5d3..7b7a33de84 100644 | |
--- a/test/mri/excludes/TestString.rb | |
+++ b/test/mri/excludes/TestString.rb | |
@@ -18,6 +18,8 @@ exclude :test_rpartition, "needs investigation" | |
exclude :test_rstrip, "needs investigation" | |
exclude :test_rstrip_bang, "needs investigation" | |
exclude :test_setter, "needs investigation" | |
+exclude :test_split_invalid_argument, "needs investigation" | |
+exclude :test_split_with_block, "needs investigation" | |
exclude :test_to_i, "needs investigation" | |
exclude :test_to_str, "needs investigation" | |
exclude :test_uplus_minus, "needs investigation" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment