summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spec/ruby/core/array/pack/shared/basic.rb6
-rw-r--r--spec/ruby/core/dir/shared/glob.rb2
-rw-r--r--spec/ruby/core/encoding/compatible_spec.rb584
-rw-r--r--spec/ruby/core/exception/system_call_error_spec.rb34
-rw-r--r--spec/ruby/core/io/pread_spec.rb6
-rw-r--r--spec/ruby/core/io/set_encoding_by_bom_spec.rb8
-rw-r--r--spec/ruby/core/kernel/sleep_spec.rb19
-rw-r--r--spec/ruby/core/marshal/dump_spec.rb22
-rw-r--r--spec/ruby/core/marshal/fixtures/marshal_data.rb16
-rw-r--r--spec/ruby/core/marshal/shared/load.rb28
-rw-r--r--spec/ruby/core/process/status/bit_and_spec.rb32
-rw-r--r--spec/ruby/core/process/status/right_shift_spec.rb31
-rw-r--r--spec/ruby/core/range/reverse_each_spec.rb103
-rw-r--r--spec/ruby/core/refinement/refined_class_spec.rb27
-rw-r--r--spec/ruby/core/refinement/shared/target.rb13
-rw-r--r--spec/ruby/core/refinement/target_spec.rb8
-rw-r--r--spec/ruby/core/string/unpack/shared/basic.rb9
-rw-r--r--spec/ruby/core/time/comparison_spec.rb26
-rw-r--r--spec/ruby/core/time/new_spec.rb26
-rw-r--r--spec/ruby/core/time/shared/gmtime.rb9
-rw-r--r--spec/ruby/core/tracepoint/raised_exception_spec.rb18
-rw-r--r--spec/ruby/language/block_spec.rb30
-rw-r--r--spec/ruby/language/defined_spec.rb4
-rw-r--r--spec/ruby/language/delegation_spec.rb89
-rw-r--r--spec/ruby/language/fixtures/defined.rb6
-rw-r--r--spec/ruby/language/fixtures/delegation.rb4
-rw-r--r--spec/ruby/library/random/formatter/alphanumeric_spec.rb58
-rw-r--r--spec/ruby/library/securerandom/random_number_spec.rb34
-rw-r--r--spec/ruby/library/stringio/shared/write.rb2
-rw-r--r--spec/ruby/library/time/iso8601_spec.rb2
-rw-r--r--spec/ruby/optional/capi/ext/hash_spec.c15
-rw-r--r--spec/ruby/optional/capi/ext/io_spec.c29
-rw-r--r--spec/ruby/optional/capi/ext/kernel_spec.c26
-rw-r--r--spec/ruby/optional/capi/ext/string_spec.c6
-rw-r--r--spec/ruby/optional/capi/hash_spec.rb55
-rw-r--r--spec/ruby/optional/capi/io_spec.rb146
-rw-r--r--spec/ruby/optional/capi/kernel_spec.rb100
-rw-r--r--spec/ruby/optional/capi/string_spec.rb45
-rw-r--r--spec/ruby/shared/process/fork.rb10
-rw-r--r--spec/ruby/shared/string/end_with.rb4
40 files changed, 1319 insertions, 373 deletions
diff --git a/spec/ruby/core/array/pack/shared/basic.rb b/spec/ruby/core/array/pack/shared/basic.rb
index 5e3eea55f9..4b28de7ed0 100644
--- a/spec/ruby/core/array/pack/shared/basic.rb
+++ b/spec/ruby/core/array/pack/shared/basic.rb
@@ -57,9 +57,9 @@ describe :array_pack_basic_non_float, shared: true do
# NOTE: Added this case just to not forget about the decision in the ticket
it "raise ArgumentError when a directive is unknown" do
# additional directive ('a') is required for the X directive
- -> { [@obj, @obj].pack("a R" + pack_format) }.should raise_error(ArgumentError)
- -> { [@obj, @obj].pack("a 0" + pack_format) }.should raise_error(ArgumentError)
- -> { [@obj, @obj].pack("a :" + pack_format) }.should raise_error(ArgumentError)
+ -> { [@obj, @obj].pack("a R" + pack_format) }.should raise_error(ArgumentError, /unknown pack directive 'R'/)
+ -> { [@obj, @obj].pack("a 0" + pack_format) }.should raise_error(ArgumentError, /unknown pack directive '0'/)
+ -> { [@obj, @obj].pack("a :" + pack_format) }.should raise_error(ArgumentError, /unknown pack directive ':'/)
end
end
diff --git a/spec/ruby/core/dir/shared/glob.rb b/spec/ruby/core/dir/shared/glob.rb
index 745f02d46b..8db74881ba 100644
--- a/spec/ruby/core/dir/shared/glob.rb
+++ b/spec/ruby/core/dir/shared/glob.rb
@@ -12,7 +12,7 @@ describe :dir_glob, shared: true do
end
it "raises an Encoding::CompatibilityError if the argument encoding is not compatible with US-ASCII" do
- pattern = "file*".dup.force_encoding Encoding::UTF_16BE
+ pattern = "files*".dup.force_encoding Encoding::UTF_16BE
-> { Dir.send(@method, pattern) }.should raise_error(Encoding::CompatibilityError)
end
diff --git a/spec/ruby/core/encoding/compatible_spec.rb b/spec/ruby/core/encoding/compatible_spec.rb
index d5b958ea0b..61a651893b 100644
--- a/spec/ruby/core/encoding/compatible_spec.rb
+++ b/spec/ruby/core/encoding/compatible_spec.rb
@@ -114,11 +114,11 @@ describe "Encoding.compatible? String, String" do
end
it "returns nil when the second's Encoding is invalid and ASCII only" do
- Encoding.compatible?(@str, "\x7f".dup.force_encoding("utf-16be")).should be_nil
+ Encoding.compatible?(@str, "\x7f\x7f".dup.force_encoding("utf-16be")).should be_nil
end
it "returns nil when the second's Encoding is invalid and not ASCII only" do
- Encoding.compatible?(@str, "\xff".dup.force_encoding("utf-16be")).should be_nil
+ Encoding.compatible?(@str, "\xff\xff".dup.force_encoding("utf-16be")).should be_nil
end
it "returns the Encoding when the second's Encoding is invalid but the same as the first" do
@@ -186,8 +186,8 @@ describe "Encoding.compatible? String, String" do
#
# VALUES = {
# empty: "",
-# :"7bits" => "\x01",
-# non7bits: "\x81"
+# :"7bits" => "\x01\x01",
+# non7bits: "\x01\x81"
# }
#
# ENCODINGS.product(TYPES, ENCODINGS, TYPES).each do |encoding1, type1, encoding2, type2|
@@ -202,329 +202,329 @@ describe "Encoding.compatible? String, String" do
matrix = [
["US-ASCII", "", "US-ASCII", "", "US-ASCII"],
- ["US-ASCII", "", "US-ASCII", "\x01", "US-ASCII"],
- ["US-ASCII", "", "US-ASCII", "\x81", "US-ASCII"],
+ ["US-ASCII", "", "US-ASCII", "\x01\x01", "US-ASCII"],
+ ["US-ASCII", "", "US-ASCII", "\x01\x81", "US-ASCII"],
["US-ASCII", "", "UTF-8", "", "US-ASCII"],
- ["US-ASCII", "", "UTF-8", "\u0001", "US-ASCII"],
- ["US-ASCII", "", "UTF-8", "\x81", "UTF-8"],
+ ["US-ASCII", "", "UTF-8", "\u0001\u0001", "US-ASCII"],
+ ["US-ASCII", "", "UTF-8", "\u0001\x81", "UTF-8"],
["US-ASCII", "", "ASCII-8BIT", "", "US-ASCII"],
- ["US-ASCII", "", "ASCII-8BIT", "\x01", "US-ASCII"],
- ["US-ASCII", "", "ASCII-8BIT", "\x81", "ASCII-8BIT"],
+ ["US-ASCII", "", "ASCII-8BIT", "\x01\x01", "US-ASCII"],
+ ["US-ASCII", "", "ASCII-8BIT", "\x01\x81", "ASCII-8BIT"],
["US-ASCII", "", "ISO-8859-1", "", "US-ASCII"],
- ["US-ASCII", "", "ISO-8859-1", "\x01", "US-ASCII"],
- ["US-ASCII", "", "ISO-8859-1", "\x81", "ISO-8859-1"],
+ ["US-ASCII", "", "ISO-8859-1", "\x01\x01", "US-ASCII"],
+ ["US-ASCII", "", "ISO-8859-1", "\x01\x81", "ISO-8859-1"],
["US-ASCII", "", "UTF-16BE", "", "US-ASCII"],
- ["US-ASCII", "", "UTF-16BE", "\x01", "UTF-16BE"],
- ["US-ASCII", "", "UTF-16BE", "\x81", "UTF-16BE"],
+ ["US-ASCII", "", "UTF-16BE", "\u0101", "UTF-16BE"],
+ ["US-ASCII", "", "UTF-16BE", "\u0181", "UTF-16BE"],
["US-ASCII", "", "ISO-2022-JP", "", "US-ASCII"],
- ["US-ASCII", "", "ISO-2022-JP", "\x01", "ISO-2022-JP"],
- ["US-ASCII", "", "ISO-2022-JP", "\x81", "ISO-2022-JP"],
- ["US-ASCII", "\x01", "US-ASCII", "", "US-ASCII"],
- ["US-ASCII", "\x01", "US-ASCII", "\x01", "US-ASCII"],
- ["US-ASCII", "\x01", "US-ASCII", "\x81", "US-ASCII"],
- ["US-ASCII", "\x01", "UTF-8", "", "US-ASCII"],
- ["US-ASCII", "\x01", "UTF-8", "\u0001", "US-ASCII"],
- ["US-ASCII", "\x01", "UTF-8", "\x81", "UTF-8"],
- ["US-ASCII", "\x01", "ASCII-8BIT", "", "US-ASCII"],
- ["US-ASCII", "\x01", "ASCII-8BIT", "\x01", "US-ASCII"],
- ["US-ASCII", "\x01", "ASCII-8BIT", "\x81", "ASCII-8BIT"],
- ["US-ASCII", "\x01", "ISO-8859-1", "", "US-ASCII"],
- ["US-ASCII", "\x01", "ISO-8859-1", "\x01", "US-ASCII"],
- ["US-ASCII", "\x01", "ISO-8859-1", "\x81", "ISO-8859-1"],
- ["US-ASCII", "\x01", "UTF-16BE", "", "US-ASCII"],
- ["US-ASCII", "\x01", "UTF-16BE", "\x01", nil],
- ["US-ASCII", "\x01", "UTF-16BE", "\x81", nil],
- ["US-ASCII", "\x01", "ISO-2022-JP", "", "US-ASCII"],
- ["US-ASCII", "\x01", "ISO-2022-JP", "\x01", nil],
- ["US-ASCII", "\x01", "ISO-2022-JP", "\x81", nil],
- ["US-ASCII", "\x81", "US-ASCII", "", "US-ASCII"],
- ["US-ASCII", "\x81", "US-ASCII", "\x01", "US-ASCII"],
- ["US-ASCII", "\x81", "US-ASCII", "\x81", "US-ASCII"],
- ["US-ASCII", "\x81", "UTF-8", "", "US-ASCII"],
- ["US-ASCII", "\x81", "UTF-8", "\u0001", "US-ASCII"],
- ["US-ASCII", "\x81", "UTF-8", "\x81", nil],
- ["US-ASCII", "\x81", "ASCII-8BIT", "", "US-ASCII"],
- ["US-ASCII", "\x81", "ASCII-8BIT", "\x01", "US-ASCII"],
- ["US-ASCII", "\x81", "ASCII-8BIT", "\x81", nil],
- ["US-ASCII", "\x81", "ISO-8859-1", "", "US-ASCII"],
- ["US-ASCII", "\x81", "ISO-8859-1", "\x01", "US-ASCII"],
- ["US-ASCII", "\x81", "ISO-8859-1", "\x81", nil],
- ["US-ASCII", "\x81", "UTF-16BE", "", "US-ASCII"],
- ["US-ASCII", "\x81", "UTF-16BE", "\x01", nil],
- ["US-ASCII", "\x81", "UTF-16BE", "\x81", nil],
- ["US-ASCII", "\x81", "ISO-2022-JP", "", "US-ASCII"],
- ["US-ASCII", "\x81", "ISO-2022-JP", "\x01", nil],
- ["US-ASCII", "\x81", "ISO-2022-JP", "\x81", nil],
+ ["US-ASCII", "", "ISO-2022-JP", "\x01\x01", "ISO-2022-JP"],
+ ["US-ASCII", "", "ISO-2022-JP", "\x01\x81", "ISO-2022-JP"],
+ ["US-ASCII", "\x01\x01", "US-ASCII", "", "US-ASCII"],
+ ["US-ASCII", "\x01\x01", "US-ASCII", "\x01\x01", "US-ASCII"],
+ ["US-ASCII", "\x01\x01", "US-ASCII", "\x01\x81", "US-ASCII"],
+ ["US-ASCII", "\x01\x01", "UTF-8", "", "US-ASCII"],
+ ["US-ASCII", "\x01\x01", "UTF-8", "\u0001\u0001", "US-ASCII"],
+ ["US-ASCII", "\x01\x01", "UTF-8", "\u0001\x81", "UTF-8"],
+ ["US-ASCII", "\x01\x01", "ASCII-8BIT", "", "US-ASCII"],
+ ["US-ASCII", "\x01\x01", "ASCII-8BIT", "\x01\x01", "US-ASCII"],
+ ["US-ASCII", "\x01\x01", "ASCII-8BIT", "\x01\x81", "ASCII-8BIT"],
+ ["US-ASCII", "\x01\x01", "ISO-8859-1", "", "US-ASCII"],
+ ["US-ASCII", "\x01\x01", "ISO-8859-1", "\x01\x01", "US-ASCII"],
+ ["US-ASCII", "\x01\x01", "ISO-8859-1", "\x01\x81", "ISO-8859-1"],
+ ["US-ASCII", "\x01\x01", "UTF-16BE", "", "US-ASCII"],
+ ["US-ASCII", "\x01\x01", "UTF-16BE", "\u0101", nil],
+ ["US-ASCII", "\x01\x01", "UTF-16BE", "\u0181", nil],
+ ["US-ASCII", "\x01\x01", "ISO-2022-JP", "", "US-ASCII"],
+ ["US-ASCII", "\x01\x01", "ISO-2022-JP", "\x01\x01", nil],
+ ["US-ASCII", "\x01\x01", "ISO-2022-JP", "\x01\x81", nil],
+ ["US-ASCII", "\x01\x81", "US-ASCII", "", "US-ASCII"],
+ ["US-ASCII", "\x01\x81", "US-ASCII", "\x01\x01", "US-ASCII"],
+ ["US-ASCII", "\x01\x81", "US-ASCII", "\x01\x81", "US-ASCII"],
+ ["US-ASCII", "\x01\x81", "UTF-8", "", "US-ASCII"],
+ ["US-ASCII", "\x01\x81", "UTF-8", "\u0001\u0001", "US-ASCII"],
+ ["US-ASCII", "\x01\x81", "UTF-8", "\u0001\x81", nil],
+ ["US-ASCII", "\x01\x81", "ASCII-8BIT", "", "US-ASCII"],
+ ["US-ASCII", "\x01\x81", "ASCII-8BIT", "\x01\x01", "US-ASCII"],
+ ["US-ASCII", "\x01\x81", "ASCII-8BIT", "\x01\x81", nil],
+ ["US-ASCII", "\x01\x81", "ISO-8859-1", "", "US-ASCII"],
+ ["US-ASCII", "\x01\x81", "ISO-8859-1", "\x01\x01", "US-ASCII"],
+ ["US-ASCII", "\x01\x81", "ISO-8859-1", "\x01\x81", nil],
+ ["US-ASCII", "\x01\x81", "UTF-16BE", "", "US-ASCII"],
+ ["US-ASCII", "\x01\x81", "UTF-16BE", "\u0101", nil],
+ ["US-ASCII", "\x01\x81", "UTF-16BE", "\u0181", nil],
+ ["US-ASCII", "\x01\x81", "ISO-2022-JP", "", "US-ASCII"],
+ ["US-ASCII", "\x01\x81", "ISO-2022-JP", "\x01\x01", nil],
+ ["US-ASCII", "\x01\x81", "ISO-2022-JP", "\x01\x81", nil],
["UTF-8", "", "US-ASCII", "", "UTF-8"],
- ["UTF-8", "", "US-ASCII", "\x01", "UTF-8"],
- ["UTF-8", "", "US-ASCII", "\x81", "US-ASCII"],
+ ["UTF-8", "", "US-ASCII", "\x01\x01", "UTF-8"],
+ ["UTF-8", "", "US-ASCII", "\x01\x81", "US-ASCII"],
["UTF-8", "", "UTF-8", "", "UTF-8"],
- ["UTF-8", "", "UTF-8", "\u0001", "UTF-8"],
- ["UTF-8", "", "UTF-8", "\x81", "UTF-8"],
+ ["UTF-8", "", "UTF-8", "\u0001\u0001", "UTF-8"],
+ ["UTF-8", "", "UTF-8", "\u0001\x81", "UTF-8"],
["UTF-8", "", "ASCII-8BIT", "", "UTF-8"],
- ["UTF-8", "", "ASCII-8BIT", "\x01", "UTF-8"],
- ["UTF-8", "", "ASCII-8BIT", "\x81", "ASCII-8BIT"],
+ ["UTF-8", "", "ASCII-8BIT", "\x01\x01", "UTF-8"],
+ ["UTF-8", "", "ASCII-8BIT", "\x01\x81", "ASCII-8BIT"],
["UTF-8", "", "ISO-8859-1", "", "UTF-8"],
- ["UTF-8", "", "ISO-8859-1", "\x01", "UTF-8"],
- ["UTF-8", "", "ISO-8859-1", "\x81", "ISO-8859-1"],
+ ["UTF-8", "", "ISO-8859-1", "\x01\x01", "UTF-8"],
+ ["UTF-8", "", "ISO-8859-1", "\x01\x81", "ISO-8859-1"],
["UTF-8", "", "UTF-16BE", "", "UTF-8"],
- ["UTF-8", "", "UTF-16BE", "\x01", "UTF-16BE"],
- ["UTF-8", "", "UTF-16BE", "\x81", "UTF-16BE"],
+ ["UTF-8", "", "UTF-16BE", "\u0101", "UTF-16BE"],
+ ["UTF-8", "", "UTF-16BE", "\u0181", "UTF-16BE"],
["UTF-8", "", "ISO-2022-JP", "", "UTF-8"],
- ["UTF-8", "", "ISO-2022-JP", "\x01", "ISO-2022-JP"],
- ["UTF-8", "", "ISO-2022-JP", "\x81", "ISO-2022-JP"],
- ["UTF-8", "\u0001", "US-ASCII", "", "UTF-8"],
- ["UTF-8", "\u0001", "US-ASCII", "\x01", "UTF-8"],
- ["UTF-8", "\u0001", "US-ASCII", "\x81", "US-ASCII"],
- ["UTF-8", "\u0001", "UTF-8", "", "UTF-8"],
- ["UTF-8", "\u0001", "UTF-8", "\u0001", "UTF-8"],
- ["UTF-8", "\u0001", "UTF-8", "\x81", "UTF-8"],
- ["UTF-8", "\u0001", "ASCII-8BIT", "", "UTF-8"],
- ["UTF-8", "\u0001", "ASCII-8BIT", "\x01", "UTF-8"],
- ["UTF-8", "\u0001", "ASCII-8BIT", "\x81", "ASCII-8BIT"],
- ["UTF-8", "\u0001", "ISO-8859-1", "", "UTF-8"],
- ["UTF-8", "\u0001", "ISO-8859-1", "\x01", "UTF-8"],
- ["UTF-8", "\u0001", "ISO-8859-1", "\x81", "ISO-8859-1"],
- ["UTF-8", "\u0001", "UTF-16BE", "", "UTF-8"],
- ["UTF-8", "\u0001", "UTF-16BE", "\x01", nil],
- ["UTF-8", "\u0001", "UTF-16BE", "\x81", nil],
- ["UTF-8", "\u0001", "ISO-2022-JP", "", "UTF-8"],
- ["UTF-8", "\u0001", "ISO-2022-JP", "\x01", nil],
- ["UTF-8", "\u0001", "ISO-2022-JP", "\x81", nil],
- ["UTF-8", "\x81", "US-ASCII", "", "UTF-8"],
- ["UTF-8", "\x81", "US-ASCII", "\x01", "UTF-8"],
- ["UTF-8", "\x81", "US-ASCII", "\x81", nil],
- ["UTF-8", "\x81", "UTF-8", "", "UTF-8"],
- ["UTF-8", "\x81", "UTF-8", "\u0001", "UTF-8"],
- ["UTF-8", "\x81", "UTF-8", "\x81", "UTF-8"],
- ["UTF-8", "\x81", "ASCII-8BIT", "", "UTF-8"],
- ["UTF-8", "\x81", "ASCII-8BIT", "\x01", "UTF-8"],
- ["UTF-8", "\x81", "ASCII-8BIT", "\x81", nil],
- ["UTF-8", "\x81", "ISO-8859-1", "", "UTF-8"],
- ["UTF-8", "\x81", "ISO-8859-1", "\x01", "UTF-8"],
- ["UTF-8", "\x81", "ISO-8859-1", "\x81", nil],
- ["UTF-8", "\x81", "UTF-16BE", "", "UTF-8"],
- ["UTF-8", "\x81", "UTF-16BE", "\x01", nil],
- ["UTF-8", "\x81", "UTF-16BE", "\x81", nil],
- ["UTF-8", "\x81", "ISO-2022-JP", "", "UTF-8"],
- ["UTF-8", "\x81", "ISO-2022-JP", "\x01", nil],
- ["UTF-8", "\x81", "ISO-2022-JP", "\x81", nil],
+ ["UTF-8", "", "ISO-2022-JP", "\x01\x01", "ISO-2022-JP"],
+ ["UTF-8", "", "ISO-2022-JP", "\x01\x81", "ISO-2022-JP"],
+ ["UTF-8", "\u0001\u0001", "US-ASCII", "", "UTF-8"],
+ ["UTF-8", "\u0001\u0001", "US-ASCII", "\x01\x01", "UTF-8"],
+ ["UTF-8", "\u0001\u0001", "US-ASCII", "\x01\x81", "US-ASCII"],
+ ["UTF-8", "\u0001\u0001", "UTF-8", "", "UTF-8"],
+ ["UTF-8", "\u0001\u0001", "UTF-8", "\u0001\u0001", "UTF-8"],
+ ["UTF-8", "\u0001\u0001", "UTF-8", "\u0001\x81", "UTF-8"],
+ ["UTF-8", "\u0001\u0001", "ASCII-8BIT", "", "UTF-8"],
+ ["UTF-8", "\u0001\u0001", "ASCII-8BIT", "\x01\x01", "UTF-8"],
+ ["UTF-8", "\u0001\u0001", "ASCII-8BIT", "\x01\x81", "ASCII-8BIT"],
+ ["UTF-8", "\u0001\u0001", "ISO-8859-1", "", "UTF-8"],
+ ["UTF-8", "\u0001\u0001", "ISO-8859-1", "\x01\x01", "UTF-8"],
+ ["UTF-8", "\u0001\u0001", "ISO-8859-1", "\x01\x81", "ISO-8859-1"],
+ ["UTF-8", "\u0001\u0001", "UTF-16BE", "", "UTF-8"],
+ ["UTF-8", "\u0001\u0001", "UTF-16BE", "\u0101", nil],
+ ["UTF-8", "\u0001\u0001", "UTF-16BE", "\u0181", nil],
+ ["UTF-8", "\u0001\u0001", "ISO-2022-JP", "", "UTF-8"],
+ ["UTF-8", "\u0001\u0001", "ISO-2022-JP", "\x01\x01", nil],
+ ["UTF-8", "\u0001\u0001", "ISO-2022-JP", "\x01\x81", nil],
+ ["UTF-8", "\u0001\x81", "US-ASCII", "", "UTF-8"],
+ ["UTF-8", "\u0001\x81", "US-ASCII", "\x01\x01", "UTF-8"],
+ ["UTF-8", "\u0001\x81", "US-ASCII", "\x01\x81", nil],
+ ["UTF-8", "\u0001\x81", "UTF-8", "", "UTF-8"],
+ ["UTF-8", "\u0001\x81", "UTF-8", "\u0001\u0001", "UTF-8"],
+ ["UTF-8", "\u0001\x81", "UTF-8", "\u0001\x81", "UTF-8"],
+ ["UTF-8", "\u0001\x81", "ASCII-8BIT", "", "UTF-8"],
+ ["UTF-8", "\u0001\x81", "ASCII-8BIT", "\x01\x01", "UTF-8"],
+ ["UTF-8", "\u0001\x81", "ASCII-8BIT", "\x01\x81", nil],
+ ["UTF-8", "\u0001\x81", "ISO-8859-1", "", "UTF-8"],
+ ["UTF-8", "\u0001\x81", "ISO-8859-1", "\x01\x01", "UTF-8"],
+ ["UTF-8", "\u0001\x81", "ISO-8859-1", "\x01\x81", nil],
+ ["UTF-8", "\u0001\x81", "UTF-16BE", "", "UTF-8"],
+ ["UTF-8", "\u0001\x81", "UTF-16BE", "\u0101", nil],
+ ["UTF-8", "\u0001\x81", "UTF-16BE", "\u0181", nil],
+ ["UTF-8", "\u0001\x81", "ISO-2022-JP", "", "UTF-8"],
+ ["UTF-8", "\u0001\x81", "ISO-2022-JP", "\x01\x01", nil],
+ ["UTF-8", "\u0001\x81", "ISO-2022-JP", "\x01\x81", nil],
["ASCII-8BIT", "", "US-ASCII", "", "ASCII-8BIT"],
- ["ASCII-8BIT", "", "US-ASCII", "\x01", "ASCII-8BIT"],
- ["ASCII-8BIT", "", "US-ASCII", "\x81", "US-ASCII"],
+ ["ASCII-8BIT", "", "US-ASCII", "\x01\x01", "ASCII-8BIT"],
+ ["ASCII-8BIT", "", "US-ASCII", "\x01\x81", "US-ASCII"],
["ASCII-8BIT", "", "UTF-8", "", "ASCII-8BIT"],
- ["ASCII-8BIT", "", "UTF-8", "\u0001", "ASCII-8BIT"],
- ["ASCII-8BIT", "", "UTF-8", "\x81", "UTF-8"],
+ ["ASCII-8BIT", "", "UTF-8", "\u0001\u0001", "ASCII-8BIT"],
+ ["ASCII-8BIT", "", "UTF-8", "\u0001\x81", "UTF-8"],
["ASCII-8BIT", "", "ASCII-8BIT", "", "ASCII-8BIT"],
- ["ASCII-8BIT", "", "ASCII-8BIT", "\x01", "ASCII-8BIT"],
- ["ASCII-8BIT", "", "ASCII-8BIT", "\x81", "ASCII-8BIT"],
+ ["ASCII-8BIT", "", "ASCII-8BIT", "\x01\x01", "ASCII-8BIT"],
+ ["ASCII-8BIT", "", "ASCII-8BIT", "\x01\x81", "ASCII-8BIT"],
["ASCII-8BIT", "", "ISO-8859-1", "", "ASCII-8BIT"],
- ["ASCII-8BIT", "", "ISO-8859-1", "\x01", "ASCII-8BIT"],
- ["ASCII-8BIT", "", "ISO-8859-1", "\x81", "ISO-8859-1"],
+ ["ASCII-8BIT", "", "ISO-8859-1", "\x01\x01", "ASCII-8BIT"],
+ ["ASCII-8BIT", "", "ISO-8859-1", "\x01\x81", "ISO-8859-1"],
["ASCII-8BIT", "", "UTF-16BE", "", "ASCII-8BIT"],
- ["ASCII-8BIT", "", "UTF-16BE", "\x01", "UTF-16BE"],
- ["ASCII-8BIT", "", "UTF-16BE", "\x81", "UTF-16BE"],
+ ["ASCII-8BIT", "", "UTF-16BE", "\u0101", "UTF-16BE"],
+ ["ASCII-8BIT", "", "UTF-16BE", "\u0181", "UTF-16BE"],
["ASCII-8BIT", "", "ISO-2022-JP", "", "ASCII-8BIT"],
- ["ASCII-8BIT", "", "ISO-2022-JP", "\x01", "ISO-2022-JP"],
- ["ASCII-8BIT", "", "ISO-2022-JP", "\x81", "ISO-2022-JP"],
- ["ASCII-8BIT", "\x01", "US-ASCII", "", "ASCII-8BIT"],
- ["ASCII-8BIT", "\x01", "US-ASCII", "\x01", "ASCII-8BIT"],
- ["ASCII-8BIT", "\x01", "US-ASCII", "\x81", "US-ASCII"],
- ["ASCII-8BIT", "\x01", "UTF-8", "", "ASCII-8BIT"],
- ["ASCII-8BIT", "\x01", "UTF-8", "\u0001", "ASCII-8BIT"],
- ["ASCII-8BIT", "\x01", "UTF-8", "\x81", "UTF-8"],
- ["ASCII-8BIT", "\x01", "ASCII-8BIT", "", "ASCII-8BIT"],
- ["ASCII-8BIT", "\x01", "ASCII-8BIT", "\x01", "ASCII-8BIT"],
- ["ASCII-8BIT", "\x01", "ASCII-8BIT", "\x81", "ASCII-8BIT"],
- ["ASCII-8BIT", "\x01", "ISO-8859-1", "", "ASCII-8BIT"],
- ["ASCII-8BIT", "\x01", "ISO-8859-1", "\x01", "ASCII-8BIT"],
- ["ASCII-8BIT", "\x01", "ISO-8859-1", "\x81", "ISO-8859-1"],
- ["ASCII-8BIT", "\x01", "UTF-16BE", "", "ASCII-8BIT"],
- ["ASCII-8BIT", "\x01", "UTF-16BE", "\x01", nil],
- ["ASCII-8BIT", "\x01", "UTF-16BE", "\x81", nil],
- ["ASCII-8BIT", "\x01", "ISO-2022-JP", "", "ASCII-8BIT"],
- ["ASCII-8BIT", "\x01", "ISO-2022-JP", "\x01", nil],
- ["ASCII-8BIT", "\x01", "ISO-2022-JP", "\x81", nil],
- ["ASCII-8BIT", "\x81", "US-ASCII", "", "ASCII-8BIT"],
- ["ASCII-8BIT", "\x81", "US-ASCII", "\x01", "ASCII-8BIT"],
- ["ASCII-8BIT", "\x81", "US-ASCII", "\x81", nil],
- ["ASCII-8BIT", "\x81", "UTF-8", "", "ASCII-8BIT"],
- ["ASCII-8BIT", "\x81", "UTF-8", "\u0001", "ASCII-8BIT"],
- ["ASCII-8BIT", "\x81", "UTF-8", "\x81", nil],
- ["ASCII-8BIT", "\x81", "ASCII-8BIT", "", "ASCII-8BIT"],
- ["ASCII-8BIT", "\x81", "ASCII-8BIT", "\x01", "ASCII-8BIT"],
- ["ASCII-8BIT", "\x81", "ASCII-8BIT", "\x81", "ASCII-8BIT"],
- ["ASCII-8BIT", "\x81", "ISO-8859-1", "", "ASCII-8BIT"],
- ["ASCII-8BIT", "\x81", "ISO-8859-1", "\x01", "ASCII-8BIT"],
- ["ASCII-8BIT", "\x81", "ISO-8859-1", "\x81", nil],
- ["ASCII-8BIT", "\x81", "UTF-16BE", "", "ASCII-8BIT"],
- ["ASCII-8BIT", "\x81", "UTF-16BE", "\x01", nil],
- ["ASCII-8BIT", "\x81", "UTF-16BE", "\x81", nil],
- ["ASCII-8BIT", "\x81", "ISO-2022-JP", "", "ASCII-8BIT"],
- ["ASCII-8BIT", "\x81", "ISO-2022-JP", "\x01", nil],
- ["ASCII-8BIT", "\x81", "ISO-2022-JP", "\x81", nil],
+ ["ASCII-8BIT", "", "ISO-2022-JP", "\x01\x01", "ISO-2022-JP"],
+ ["ASCII-8BIT", "", "ISO-2022-JP", "\x01\x81", "ISO-2022-JP"],
+ ["ASCII-8BIT", "\x01\x01", "US-ASCII", "", "ASCII-8BIT"],
+ ["ASCII-8BIT", "\x01\x01", "US-ASCII", "\x01\x01", "ASCII-8BIT"],
+ ["ASCII-8BIT", "\x01\x01", "US-ASCII", "\x01\x81", "US-ASCII"],
+ ["ASCII-8BIT", "\x01\x01", "UTF-8", "", "ASCII-8BIT"],
+ ["ASCII-8BIT", "\x01\x01", "UTF-8", "\u0001\u0001", "ASCII-8BIT"],
+ ["ASCII-8BIT", "\x01\x01", "UTF-8", "\u0001\x81", "UTF-8"],
+ ["ASCII-8BIT", "\x01\x01", "ASCII-8BIT", "", "ASCII-8BIT"],
+ ["ASCII-8BIT", "\x01\x01", "ASCII-8BIT", "\x01\x01", "ASCII-8BIT"],
+ ["ASCII-8BIT", "\x01\x01", "ASCII-8BIT", "\x01\x81", "ASCII-8BIT"],
+ ["ASCII-8BIT", "\x01\x01", "ISO-8859-1", "", "ASCII-8BIT"],
+ ["ASCII-8BIT", "\x01\x01", "ISO-8859-1", "\x01\x01", "ASCII-8BIT"],
+ ["ASCII-8BIT", "\x01\x01", "ISO-8859-1", "\x01\x81", "ISO-8859-1"],
+ ["ASCII-8BIT", "\x01\x01", "UTF-16BE", "", "ASCII-8BIT"],
+ ["ASCII-8BIT", "\x01\x01", "UTF-16BE", "\u0101", nil],
+ ["ASCII-8BIT", "\x01\x01", "UTF-16BE", "\u0181", nil],
+ ["ASCII-8BIT", "\x01\x01", "ISO-2022-JP", "", "ASCII-8BIT"],
+ ["ASCII-8BIT", "\x01\x01", "ISO-2022-JP", "\x01\x01", nil],
+ ["ASCII-8BIT", "\x01\x01", "ISO-2022-JP", "\x01\x81", nil],
+ ["ASCII-8BIT", "\x01\x81", "US-ASCII", "", "ASCII-8BIT"],
+ ["ASCII-8BIT", "\x01\x81", "US-ASCII", "\x01\x01", "ASCII-8BIT"],
+ ["ASCII-8BIT", "\x01\x81", "US-ASCII", "\x01\x81", nil],
+ ["ASCII-8BIT", "\x01\x81", "UTF-8", "", "ASCII-8BIT"],
+ ["ASCII-8BIT", "\x01\x81", "UTF-8", "\u0001\u0001", "ASCII-8BIT"],
+ ["ASCII-8BIT", "\x01\x81", "UTF-8", "\u0001\x81", nil],
+ ["ASCII-8BIT", "\x01\x81", "ASCII-8BIT", "", "ASCII-8BIT"],
+ ["ASCII-8BIT", "\x01\x81", "ASCII-8BIT", "\x01\x01", "ASCII-8BIT"],
+ ["ASCII-8BIT", "\x01\x81", "ASCII-8BIT", "\x01\x81", "ASCII-8BIT"],
+ ["ASCII-8BIT", "\x01\x81", "ISO-8859-1", "", "ASCII-8BIT"],
+ ["ASCII-8BIT", "\x01\x81", "ISO-8859-1", "\x01\x01", "ASCII-8BIT"],
+ ["ASCII-8BIT", "\x01\x81", "ISO-8859-1", "\x01\x81", nil],
+ ["ASCII-8BIT", "\x01\x81", "UTF-16BE", "", "ASCII-8BIT"],
+ ["ASCII-8BIT", "\x01\x81", "UTF-16BE", "\u0101", nil],
+ ["ASCII-8BIT", "\x01\x81", "UTF-16BE", "\u0181", nil],
+ ["ASCII-8BIT", "\x01\x81", "ISO-2022-JP", "", "ASCII-8BIT"],
+ ["ASCII-8BIT", "\x01\x81", "ISO-2022-JP", "\x01\x01", nil],
+ ["ASCII-8BIT", "\x01\x81", "ISO-2022-JP", "\x01\x81", nil],
["ISO-8859-1", "", "US-ASCII", "", "ISO-8859-1"],
- ["ISO-8859-1", "", "US-ASCII", "\x01", "ISO-8859-1"],
- ["ISO-8859-1", "", "US-ASCII", "\x81", "US-ASCII"],
+ ["ISO-8859-1", "", "US-ASCII", "\x01\x01", "ISO-8859-1"],
+ ["ISO-8859-1", "", "US-ASCII", "\x01\x81", "US-ASCII"],
["ISO-8859-1", "", "UTF-8", "", "ISO-8859-1"],
- ["ISO-8859-1", "", "UTF-8", "\u0001", "ISO-8859-1"],
- ["ISO-8859-1", "", "UTF-8", "\x81", "UTF-8"],
+ ["ISO-8859-1", "", "UTF-8", "\u0001\u0001", "ISO-8859-1"],
+ ["ISO-8859-1", "", "UTF-8", "\u0001\x81", "UTF-8"],
["ISO-8859-1", "", "ASCII-8BIT", "", "ISO-8859-1"],
- ["ISO-8859-1", "", "ASCII-8BIT", "\x01", "ISO-8859-1"],
- ["ISO-8859-1", "", "ASCII-8BIT", "\x81", "ASCII-8BIT"],
+ ["ISO-8859-1", "", "ASCII-8BIT", "\x01\x01", "ISO-8859-1"],
+ ["ISO-8859-1", "", "ASCII-8BIT", "\x01\x81", "ASCII-8BIT"],
["ISO-8859-1", "", "ISO-8859-1", "", "ISO-8859-1"],
- ["ISO-8859-1", "", "ISO-8859-1", "\x01", "ISO-8859-1"],
- ["ISO-8859-1", "", "ISO-8859-1", "\x81", "ISO-8859-1"],
+ ["ISO-8859-1", "", "ISO-8859-1", "\x01\x01", "ISO-8859-1"],
+ ["ISO-8859-1", "", "ISO-8859-1", "\x01\x81", "ISO-8859-1"],
["ISO-8859-1", "", "UTF-16BE", "", "ISO-8859-1"],
- ["ISO-8859-1", "", "UTF-16BE", "\x01", "UTF-16BE"],
- ["ISO-8859-1", "", "UTF-16BE", "\x81", "UTF-16BE"],
+ ["ISO-8859-1", "", "UTF-16BE", "\u0101", "UTF-16BE"],
+ ["ISO-8859-1", "", "UTF-16BE", "\u0181", "UTF-16BE"],
["ISO-8859-1", "", "ISO-2022-JP", "", "ISO-8859-1"],
- ["ISO-8859-1", "", "ISO-2022-JP", "\x01", "ISO-2022-JP"],
- ["ISO-8859-1", "", "ISO-2022-JP", "\x81", "ISO-2022-JP"],
- ["ISO-8859-1", "\x01", "US-ASCII", "", "ISO-8859-1"],
- ["ISO-8859-1", "\x01", "US-ASCII", "\x01", "ISO-8859-1"],
- ["ISO-8859-1", "\x01", "US-ASCII", "\x81", "US-ASCII"],
- ["ISO-8859-1", "\x01", "UTF-8", "", "ISO-8859-1"],
- ["ISO-8859-1", "\x01", "UTF-8", "\u0001", "ISO-8859-1"],
- ["ISO-8859-1", "\x01", "UTF-8", "\x81", "UTF-8"],
- ["ISO-8859-1", "\x01", "ASCII-8BIT", "", "ISO-8859-1"],
- ["ISO-8859-1", "\x01", "ASCII-8BIT", "\x01", "ISO-8859-1"],
- ["ISO-8859-1", "\x01", "ASCII-8BIT", "\x81", "ASCII-8BIT"],
- ["ISO-8859-1", "\x01", "ISO-8859-1", "", "ISO-8859-1"],
- ["ISO-8859-1", "\x01", "ISO-8859-1", "\x01", "ISO-8859-1"],
- ["ISO-8859-1", "\x01", "ISO-8859-1", "\x81", "ISO-8859-1"],
- ["ISO-8859-1", "\x01", "UTF-16BE", "", "ISO-8859-1"],
- ["ISO-8859-1", "\x01", "UTF-16BE", "\x01", nil],
- ["ISO-8859-1", "\x01", "UTF-16BE", "\x81", nil],
- ["ISO-8859-1", "\x01", "ISO-2022-JP", "", "ISO-8859-1"],
- ["ISO-8859-1", "\x01", "ISO-2022-JP", "\x01", nil],
- ["ISO-8859-1", "\x01", "ISO-2022-JP", "\x81", nil],
- ["ISO-8859-1", "\x81", "US-ASCII", "", "ISO-8859-1"],
- ["ISO-8859-1", "\x81", "US-ASCII", "\x01", "ISO-8859-1"],
- ["ISO-8859-1", "\x81", "US-ASCII", "\x81", nil],
- ["ISO-8859-1", "\x81", "UTF-8", "", "ISO-8859-1"],
- ["ISO-8859-1", "\x81", "UTF-8", "\u0001", "ISO-8859-1"],
- ["ISO-8859-1", "\x81", "UTF-8", "\x81", nil],
- ["ISO-8859-1", "\x81", "ASCII-8BIT", "", "ISO-8859-1"],
- ["ISO-8859-1", "\x81", "ASCII-8BIT", "\x01", "ISO-8859-1"],
- ["ISO-8859-1", "\x81", "ASCII-8BIT", "\x81", nil],
- ["ISO-8859-1", "\x81", "ISO-8859-1", "", "ISO-8859-1"],
- ["ISO-8859-1", "\x81", "ISO-8859-1", "\x01", "ISO-8859-1"],
- ["ISO-8859-1", "\x81", "ISO-8859-1", "\x81", "ISO-8859-1"],
- ["ISO-8859-1", "\x81", "UTF-16BE", "", "ISO-8859-1"],
- ["ISO-8859-1", "\x81", "UTF-16BE", "\x01", nil],
- ["ISO-8859-1", "\x81", "UTF-16BE", "\x81", nil],
- ["ISO-8859-1", "\x81", "ISO-2022-JP", "", "ISO-8859-1"],
- ["ISO-8859-1", "\x81", "ISO-2022-JP", "\x01", nil],
- ["ISO-8859-1", "\x81", "ISO-2022-JP", "\x81", nil],
+ ["ISO-8859-1", "", "ISO-2022-JP", "\x01\x01", "ISO-2022-JP"],
+ ["ISO-8859-1", "", "ISO-2022-JP", "\x01\x81", "ISO-2022-JP"],
+ ["ISO-8859-1", "\x01\x01", "US-ASCII", "", "ISO-8859-1"],
+ ["ISO-8859-1", "\x01\x01", "US-ASCII", "\x01\x01", "ISO-8859-1"],
+ ["ISO-8859-1", "\x01\x01", "US-ASCII", "\x01\x81", "US-ASCII"],
+ ["ISO-8859-1", "\x01\x01", "UTF-8", "", "ISO-8859-1"],
+ ["ISO-8859-1", "\x01\x01", "UTF-8", "\u0001\u0001", "ISO-8859-1"],
+ ["ISO-8859-1", "\x01\x01", "UTF-8", "\u0001\x81", "UTF-8"],
+ ["ISO-8859-1", "\x01\x01", "ASCII-8BIT", "", "ISO-8859-1"],
+ ["ISO-8859-1", "\x01\x01", "ASCII-8BIT", "\x01\x01", "ISO-8859-1"],
+ ["ISO-8859-1", "\x01\x01", "ASCII-8BIT", "\x01\x81", "ASCII-8BIT"],
+ ["ISO-8859-1", "\x01\x01", "ISO-8859-1", "", "ISO-8859-1"],
+ ["ISO-8859-1", "\x01\x01", "ISO-8859-1", "\x01\x01", "ISO-8859-1"],
+ ["ISO-8859-1", "\x01\x01", "ISO-8859-1", "\x01\x81", "ISO-8859-1"],
+ ["ISO-8859-1", "\x01\x01", "UTF-16BE", "", "ISO-8859-1"],
+ ["ISO-8859-1", "\x01\x01", "UTF-16BE", "\u0101", nil],
+ ["ISO-8859-1", "\x01\x01", "UTF-16BE", "\u0181", nil],
+ ["ISO-8859-1", "\x01\x01", "ISO-2022-JP", "", "ISO-8859-1"],
+ ["ISO-8859-1", "\x01\x01", "ISO-2022-JP", "\x01\x01", nil],
+ ["ISO-8859-1", "\x01\x01", "ISO-2022-JP", "\x01\x81", nil],
+ ["ISO-8859-1", "\x01\x81", "US-ASCII", "", "ISO-8859-1"],
+ ["ISO-8859-1", "\x01\x81", "US-ASCII", "\x01\x01", "ISO-8859-1"],
+ ["ISO-8859-1", "\x01\x81", "US-ASCII", "\x01\x81", nil],
+ ["ISO-8859-1", "\x01\x81", "UTF-8", "", "ISO-8859-1"],
+ ["ISO-8859-1", "\x01\x81", "UTF-8", "\u0001\u0001", "ISO-8859-1"],
+ ["ISO-8859-1", "\x01\x81", "UTF-8", "\u0001\x81", nil],
+ ["ISO-8859-1", "\x01\x81", "ASCII-8BIT", "", "ISO-8859-1"],
+ ["ISO-8859-1", "\x01\x81", "ASCII-8BIT", "\x01\x01", "ISO-8859-1"],
+ ["ISO-8859-1", "\x01\x81", "ASCII-8BIT", "\x01\x81", nil],
+ ["ISO-8859-1", "\x01\x81", "ISO-8859-1", "", "ISO-8859-1"],
+ ["ISO-8859-1", "\x01\x81", "ISO-8859-1", "\x01\x01", "ISO-8859-1"],
+ ["ISO-8859-1", "\x01\x81", "ISO-8859-1", "\x01\x81", "ISO-8859-1"],
+ ["ISO-8859-1", "\x01\x81", "UTF-16BE", "", "ISO-8859-1"],
+ ["ISO-8859-1", "\x01\x81", "UTF-16BE", "\u0101", nil],
+ ["ISO-8859-1", "\x01\x81", "UTF-16BE", "\u0181", nil],
+ ["ISO-8859-1", "\x01\x81", "ISO-2022-JP", "", "ISO-8859-1"],
+ ["ISO-8859-1", "\x01\x81", "ISO-2022-JP", "\x01\x01", nil],
+ ["ISO-8859-1", "\x01\x81", "ISO-2022-JP", "\x01\x81", nil],
["UTF-16BE", "", "US-ASCII", "", "UTF-16BE"],
- ["UTF-16BE", "", "US-ASCII", "\x01", "US-ASCII"],
- ["UTF-16BE", "", "US-ASCII", "\x81", "US-ASCII"],
+ ["UTF-16BE", "", "US-ASCII", "\x01\x01", "US-ASCII"],
+ ["UTF-16BE", "", "US-ASCII", "\x01\x81", "US-ASCII"],
["UTF-16BE", "", "UTF-8", "", "UTF-16BE"],
- ["UTF-16BE", "", "UTF-8", "\u0001", "UTF-8"],
- ["UTF-16BE", "", "UTF-8", "\x81", "UTF-8"],
+ ["UTF-16BE", "", "UTF-8", "\u0001\u0001", "UTF-8"],
+ ["UTF-16BE", "", "UTF-8", "\u0001\x81", "UTF-8"],
["UTF-16BE", "", "ASCII-8BIT", "", "UTF-16BE"],
- ["UTF-16BE", "", "ASCII-8BIT", "\x01", "ASCII-8BIT"],
- ["UTF-16BE", "", "ASCII-8BIT", "\x81", "ASCII-8BIT"],
+ ["UTF-16BE", "", "ASCII-8BIT", "\x01\x01", "ASCII-8BIT"],
+ ["UTF-16BE", "", "ASCII-8BIT", "\x01\x81", "ASCII-8BIT"],
["UTF-16BE", "", "ISO-8859-1", "", "UTF-16BE"],
- ["UTF-16BE", "", "ISO-8859-1", "\x01", "ISO-8859-1"],
- ["UTF-16BE", "", "ISO-8859-1", "\x81", "ISO-8859-1"],
+ ["UTF-16BE", "", "ISO-8859-1", "\x01\x01", "ISO-8859-1"],
+ ["UTF-16BE", "", "ISO-8859-1", "\x01\x81", "ISO-8859-1"],
["UTF-16BE", "", "UTF-16BE", "", "UTF-16BE"],
- ["UTF-16BE", "", "UTF-16BE", "\x01", "UTF-16BE"],
- ["UTF-16BE", "", "UTF-16BE", "\x81", "UTF-16BE"],
+ ["UTF-16BE", "", "UTF-16BE", "\u0101", "UTF-16BE"],
+ ["UTF-16BE", "", "UTF-16BE", "\u0181", "UTF-16BE"],
["UTF-16BE", "", "ISO-2022-JP", "", "UTF-16BE"],
- ["UTF-16BE", "", "ISO-2022-JP", "\x01", "ISO-2022-JP"],
- ["UTF-16BE", "", "ISO-2022-JP", "\x81", "ISO-2022-JP"],
- ["UTF-16BE", "\x01", "US-ASCII", "", "UTF-16BE"],
- ["UTF-16BE", "\x01", "US-ASCII", "\x01", nil],
- ["UTF-16BE", "\x01", "US-ASCII", "\x81", nil],
- ["UTF-16BE", "\x01", "UTF-8", "", "UTF-16BE"],
- ["UTF-16BE", "\x01", "UTF-8", "\u0001", nil],
- ["UTF-16BE", "\x01", "UTF-8", "\x81", nil],
- ["UTF-16BE", "\x01", "ASCII-8BIT", "", "UTF-16BE"],
- ["UTF-16BE", "\x01", "ASCII-8BIT", "\x01", nil],
- ["UTF-16BE", "\x01", "ASCII-8BIT", "\x81", nil],
- ["UTF-16BE", "\x01", "ISO-8859-1", "", "UTF-16BE"],
- ["UTF-16BE", "\x01", "ISO-8859-1", "\x01", nil],
- ["UTF-16BE", "\x01", "ISO-8859-1", "\x81", nil],
- ["UTF-16BE", "\x01", "UTF-16BE", "", "UTF-16BE"],
- ["UTF-16BE", "\x01", "UTF-16BE", "\x01", "UTF-16BE"],
- ["UTF-16BE", "\x01", "UTF-16BE", "\x81", "UTF-16BE"],
- ["UTF-16BE", "\x01", "ISO-2022-JP", "", "UTF-16BE"],
- ["UTF-16BE", "\x01", "ISO-2022-JP", "\x01", nil],
- ["UTF-16BE", "\x01", "ISO-2022-JP", "\x81", nil],
- ["UTF-16BE", "\x81", "US-ASCII", "", "UTF-16BE"],
- ["UTF-16BE", "\x81", "US-ASCII", "\x01", nil],
- ["UTF-16BE", "\x81", "US-ASCII", "\x81", nil],
- ["UTF-16BE", "\x81", "UTF-8", "", "UTF-16BE"],
- ["UTF-16BE", "\x81", "UTF-8", "\u0001", nil],
- ["UTF-16BE", "\x81", "UTF-8", "\x81", nil],
- ["UTF-16BE", "\x81", "ASCII-8BIT", "", "UTF-16BE"],
- ["UTF-16BE", "\x81", "ASCII-8BIT", "\x01", nil],
- ["UTF-16BE", "\x81", "ASCII-8BIT", "\x81", nil],
- ["UTF-16BE", "\x81", "ISO-8859-1", "", "UTF-16BE"],
- ["UTF-16BE", "\x81", "ISO-8859-1", "\x01", nil],
- ["UTF-16BE", "\x81", "ISO-8859-1", "\x81", nil],
- ["UTF-16BE", "\x81", "UTF-16BE", "", "UTF-16BE"],
- ["UTF-16BE", "\x81", "UTF-16BE", "\x01", "UTF-16BE"],
- ["UTF-16BE", "\x81", "UTF-16BE", "\x81", "UTF-16BE"],
- ["UTF-16BE", "\x81", "ISO-2022-JP", "", "UTF-16BE"],
- ["UTF-16BE", "\x81", "ISO-2022-JP", "\x01", nil],
- ["UTF-16BE", "\x81", "ISO-2022-JP", "\x81", nil],
+ ["UTF-16BE", "", "ISO-2022-JP", "\x01\x01", "ISO-2022-JP"],
+ ["UTF-16BE", "", "ISO-2022-JP", "\x01\x81", "ISO-2022-JP"],
+ ["UTF-16BE", "\u0101", "US-ASCII", "", "UTF-16BE"],
+ ["UTF-16BE", "\u0101", "US-ASCII", "\x01\x01", nil],
+ ["UTF-16BE", "\u0101", "US-ASCII", "\x01\x81", nil],
+ ["UTF-16BE", "\u0101", "UTF-8", "", "UTF-16BE"],
+ ["UTF-16BE", "\u0101", "UTF-8", "\u0001\u0001", nil],
+ ["UTF-16BE", "\u0101", "UTF-8", "\u0001\x81", nil],
+ ["UTF-16BE", "\u0101", "ASCII-8BIT", "", "UTF-16BE"],
+ ["UTF-16BE", "\u0101", "ASCII-8BIT", "\x01\x01", nil],
+ ["UTF-16BE", "\u0101", "ASCII-8BIT", "\x01\x81", nil],
+ ["UTF-16BE", "\u0101", "ISO-8859-1", "", "UTF-16BE"],
+ ["UTF-16BE", "\u0101", "ISO-8859-1", "\x01\x01", nil],
+ ["UTF-16BE", "\u0101", "ISO-8859-1", "\x01\x81", nil],
+ ["UTF-16BE", "\u0101", "UTF-16BE", "", "UTF-16BE"],
+ ["UTF-16BE", "\u0101", "UTF-16BE", "\u0101", "UTF-16BE"],
+ ["UTF-16BE", "\u0101", "UTF-16BE", "\u0181", "UTF-16BE"],
+ ["UTF-16BE", "\u0101", "ISO-2022-JP", "", "UTF-16BE"],
+ ["UTF-16BE", "\u0101", "ISO-2022-JP", "\x01\x01", nil],
+ ["UTF-16BE", "\u0101", "ISO-2022-JP", "\x01\x81", nil],
+ ["UTF-16BE", "\u0181", "US-ASCII", "", "UTF-16BE"],
+ ["UTF-16BE", "\u0181", "US-ASCII", "\x01\x01", nil],
+ ["UTF-16BE", "\u0181", "US-ASCII", "\x01\x81", nil],
+ ["UTF-16BE", "\u0181", "UTF-8", "", "UTF-16BE"],
+ ["UTF-16BE", "\u0181", "UTF-8", "\u0001\u0001", nil],
+ ["UTF-16BE", "\u0181", "UTF-8", "\u0001\x81", nil],
+ ["UTF-16BE", "\u0181", "ASCII-8BIT", "", "UTF-16BE"],
+ ["UTF-16BE", "\u0181", "ASCII-8BIT", "\x01\x01", nil],
+ ["UTF-16BE", "\u0181", "ASCII-8BIT", "\x01\x81", nil],
+ ["UTF-16BE", "\u0181", "ISO-8859-1", "", "UTF-16BE"],
+ ["UTF-16BE", "\u0181", "ISO-8859-1", "\x01\x01", nil],
+ ["UTF-16BE", "\u0181", "ISO-8859-1", "\x01\x81", nil],
+ ["UTF-16BE", "\u0181", "UTF-16BE", "", "UTF-16BE"],
+ ["UTF-16BE", "\u0181", "UTF-16BE", "\u0101", "UTF-16BE"],
+ ["UTF-16BE", "\u0181", "UTF-16BE", "\u0181", "UTF-16BE"],
+ ["UTF-16BE", "\u0181", "ISO-2022-JP", "", "UTF-16BE"],
+ ["UTF-16BE", "\u0181", "ISO-2022-JP", "\x01\x01", nil],
+ ["UTF-16BE", "\u0181", "ISO-2022-JP", "\x01\x81", nil],
["ISO-2022-JP", "", "US-ASCII", "", "ISO-2022-JP"],
- ["ISO-2022-JP", "", "US-ASCII", "\x01", "US-ASCII"],
- ["ISO-2022-JP", "", "US-ASCII", "\x81", "US-ASCII"],
+ ["ISO-2022-JP", "", "US-ASCII", "\x01\x01", "US-ASCII"],
+ ["ISO-2022-JP", "", "US-ASCII", "\x01\x81", "US-ASCII"],
["ISO-2022-JP", "", "UTF-8", "", "ISO-2022-JP"],
- ["ISO-2022-JP", "", "UTF-8", "\u0001", "UTF-8"],
- ["ISO-2022-JP", "", "UTF-8", "\x81", "UTF-8"],
+ ["ISO-2022-JP", "", "UTF-8", "\u0001\u0001", "UTF-8"],
+ ["ISO-2022-JP", "", "UTF-8", "\u0001\x81", "UTF-8"],
["ISO-2022-JP", "", "ASCII-8BIT", "", "ISO-2022-JP"],
- ["ISO-2022-JP", "", "ASCII-8BIT", "\x01", "ASCII-8BIT"],
- ["ISO-2022-JP", "", "ASCII-8BIT", "\x81", "ASCII-8BIT"],
+ ["ISO-2022-JP", "", "ASCII-8BIT", "\x01\x01", "ASCII-8BIT"],
+ ["ISO-2022-JP", "", "ASCII-8BIT", "\x01\x81", "ASCII-8BIT"],
["ISO-2022-JP", "", "ISO-8859-1", "", "ISO-2022-JP"],
- ["ISO-2022-JP", "", "ISO-8859-1", "\x01", "ISO-8859-1"],
- ["ISO-2022-JP", "", "ISO-8859-1", "\x81", "ISO-8859-1"],
+ ["ISO-2022-JP", "", "ISO-8859-1", "\x01\x01", "ISO-8859-1"],
+ ["ISO-2022-JP", "", "ISO-8859-1", "\x01\x81", "ISO-8859-1"],
["ISO-2022-JP", "", "UTF-16BE", "", "ISO-2022-JP"],
- ["ISO-2022-JP", "", "UTF-16BE", "\x01", "UTF-16BE"],
- ["ISO-2022-JP", "", "UTF-16BE", "\x81", "UTF-16BE"],
+ ["ISO-2022-JP", "", "UTF-16BE", "\u0101", "UTF-16BE"],
+ ["ISO-2022-JP", "", "UTF-16BE", "\u0181", "UTF-16BE"],
["ISO-2022-JP", "", "ISO-2022-JP", "", "ISO-2022-JP"],
- ["ISO-2022-JP", "", "ISO-2022-JP", "\x01", "ISO-2022-JP"],
- ["ISO-2022-JP", "", "ISO-2022-JP", "\x81", "ISO-2022-JP"],
- ["ISO-2022-JP", "\x01", "US-ASCII", "", "ISO-2022-JP"],
- ["ISO-2022-JP", "\x01", "US-ASCII", "\x01", nil],
- ["ISO-2022-JP", "\x01", "US-ASCII", "\x81", nil],
- ["ISO-2022-JP", "\x01", "UTF-8", "", "ISO-2022-JP"],
- ["ISO-2022-JP", "\x01", "UTF-8", "\u0001", nil],
- ["ISO-2022-JP", "\x01", "UTF-8", "\x81", nil],
- ["ISO-2022-JP", "\x01", "ASCII-8BIT", "", "ISO-2022-JP"],
- ["ISO-2022-JP", "\x01", "ASCII-8BIT", "\x01", nil],
- ["ISO-2022-JP", "\x01", "ASCII-8BIT", "\x81", nil],
- ["ISO-2022-JP", "\x01", "ISO-8859-1", "", "ISO-2022-JP"],
- ["ISO-2022-JP", "\x01", "ISO-8859-1", "\x01", nil],
- ["ISO-2022-JP", "\x01", "ISO-8859-1", "\x81", nil],
- ["ISO-2022-JP", "\x01", "UTF-16BE", "", "ISO-2022-JP"],
- ["ISO-2022-JP", "\x01", "UTF-16BE", "\x01", nil],
- ["ISO-2022-JP", "\x01", "UTF-16BE", "\x81", nil],
- ["ISO-2022-JP", "\x01", "ISO-2022-JP", "", "ISO-2022-JP"],
- ["ISO-2022-JP", "\x01", "ISO-2022-JP", "\x01", "ISO-2022-JP"],
- ["ISO-2022-JP", "\x01", "ISO-2022-JP", "\x81", "ISO-2022-JP"],
- ["ISO-2022-JP", "\x81", "US-ASCII", "", "ISO-2022-JP"],
- ["ISO-2022-JP", "\x81", "US-ASCII", "\x01", nil],
- ["ISO-2022-JP", "\x81", "US-ASCII", "\x81", nil],
- ["ISO-2022-JP", "\x81", "UTF-8", "", "ISO-2022-JP"],
- ["ISO-2022-JP", "\x81", "UTF-8", "\u0001", nil],
- ["ISO-2022-JP", "\x81", "UTF-8", "\x81", nil],
- ["ISO-2022-JP", "\x81", "ASCII-8BIT", "", "ISO-2022-JP"],
- ["ISO-2022-JP", "\x81", "ASCII-8BIT", "\x01", nil],
- ["ISO-2022-JP", "\x81", "ASCII-8BIT", "\x81", nil],
- ["ISO-2022-JP", "\x81", "ISO-8859-1", "", "ISO-2022-JP"],
- ["ISO-2022-JP", "\x81", "ISO-8859-1", "\x01", nil],
- ["ISO-2022-JP", "\x81", "ISO-8859-1", "\x81", nil],
- ["ISO-2022-JP", "\x81", "UTF-16BE", "", "ISO-2022-JP"],
- ["ISO-2022-JP", "\x81", "UTF-16BE", "\x01", nil],
- ["ISO-2022-JP", "\x81", "UTF-16BE", "\x81", nil],
- ["ISO-2022-JP", "\x81", "ISO-2022-JP", "", "ISO-2022-JP"],
- ["ISO-2022-JP", "\x81", "ISO-2022-JP", "\x01", "ISO-2022-JP"],
- ["ISO-2022-JP", "\x81", "ISO-2022-JP", "\x81", "ISO-2022-JP"],
+ ["ISO-2022-JP", "", "ISO-2022-JP", "\x01\x01", "ISO-2022-JP"],
+ ["ISO-2022-JP", "", "ISO-2022-JP", "\x01\x81", "ISO-2022-JP"],
+ ["ISO-2022-JP", "\x01\x01", "US-ASCII", "", "ISO-2022-JP"],
+ ["ISO-2022-JP", "\x01\x01", "US-ASCII", "\x01\x01", nil],
+ ["ISO-2022-JP", "\x01\x01", "US-ASCII", "\x01\x81", nil],
+ ["ISO-2022-JP", "\x01\x01", "UTF-8", "", "ISO-2022-JP"],
+ ["ISO-2022-JP", "\x01\x01", "UTF-8", "\u0001\u0001", nil],
+ ["ISO-2022-JP", "\x01\x01", "UTF-8", "\u0001\x81", nil],
+ ["ISO-2022-JP", "\x01\x01", "ASCII-8BIT", "", "ISO-2022-JP"],
+ ["ISO-2022-JP", "\x01\x01", "ASCII-8BIT", "\x01\x01", nil],
+ ["ISO-2022-JP", "\x01\x01", "ASCII-8BIT", "\x01\x81", nil],
+ ["ISO-2022-JP", "\x01\x01", "ISO-8859-1", "", "ISO-2022-JP"],
+ ["ISO-2022-JP", "\x01\x01", "ISO-8859-1", "\x01\x01", nil],
+ ["ISO-2022-JP", "\x01\x01", "ISO-8859-1", "\x01\x81", nil],
+ ["ISO-2022-JP", "\x01\x01", "UTF-16BE", "", "ISO-2022-JP"],
+ ["ISO-2022-JP", "\x01\x01", "UTF-16BE", "\u0101", nil],
+ ["ISO-2022-JP", "\x01\x01", "UTF-16BE", "\u0181", nil],
+ ["ISO-2022-JP", "\x01\x01", "ISO-2022-JP", "", "ISO-2022-JP"],
+ ["ISO-2022-JP", "\x01\x01", "ISO-2022-JP", "\x01\x01", "ISO-2022-JP"],
+ ["ISO-2022-JP", "\x01\x01", "ISO-2022-JP", "\x01\x81", "ISO-2022-JP"],
+ ["ISO-2022-JP", "\x01\x81", "US-ASCII", "", "ISO-2022-JP"],
+ ["ISO-2022-JP", "\x01\x81", "US-ASCII", "\x01\x01", nil],
+ ["ISO-2022-JP", "\x01\x81", "US-ASCII", "\x01\x81", nil],
+ ["ISO-2022-JP", "\x01\x81", "UTF-8", "", "ISO-2022-JP"],
+ ["ISO-2022-JP", "\x01\x81", "UTF-8", "\u0001\u0001", nil],
+ ["ISO-2022-JP", "\x01\x81", "UTF-8", "\u0001\x81", nil],
+ ["ISO-2022-JP", "\x01\x81", "ASCII-8BIT", "", "ISO-2022-JP"],
+ ["ISO-2022-JP", "\x01\x81", "ASCII-8BIT", "\x01\x01", nil],
+ ["ISO-2022-JP", "\x01\x81", "ASCII-8BIT", "\x01\x81", nil],
+ ["ISO-2022-JP", "\x01\x81", "ISO-8859-1", "", "ISO-2022-JP"],
+ ["ISO-2022-JP", "\x01\x81", "ISO-8859-1", "\x01\x01", nil],
+ ["ISO-2022-JP", "\x01\x81", "ISO-8859-1", "\x01\x81", nil],
+ ["ISO-2022-JP", "\x01\x81", "UTF-16BE", "", "ISO-2022-JP"],
+ ["ISO-2022-JP", "\x01\x81", "UTF-16BE", "\u0101", nil],
+ ["ISO-2022-JP", "\x01\x81", "UTF-16BE", "\u0181", nil],
+ ["ISO-2022-JP", "\x01\x81", "ISO-2022-JP", "", "ISO-2022-JP"],
+ ["ISO-2022-JP", "\x01\x81", "ISO-2022-JP", "\x01\x01", "ISO-2022-JP"],
+ ["ISO-2022-JP", "\x01\x81", "ISO-2022-JP", "\x01\x81", "ISO-2022-JP"],
]
matrix.each do |encoding1, value1, encoding2, value2, compatible_encoding|
diff --git a/spec/ruby/core/exception/system_call_error_spec.rb b/spec/ruby/core/exception/system_call_error_spec.rb
index 73167bc288..f6995d3c5e 100644
--- a/spec/ruby/core/exception/system_call_error_spec.rb
+++ b/spec/ruby/core/exception/system_call_error_spec.rb
@@ -53,6 +53,11 @@ describe "SystemCallError.new" do
e.should be_an_instance_of(@example_errno_class)
end
+ it "sets an error message corresponding to an appropriate Errno class" do
+ e = SystemCallError.new(@example_errno)
+ e.message.should == 'Invalid argument'
+ end
+
it "accepts an optional custom message preceding the errno" do
exc = SystemCallError.new("custom message", @example_errno)
exc.should be_an_instance_of(@example_errno_class)
@@ -81,6 +86,35 @@ describe "SystemCallError.new" do
SystemCallError.new('foo', 2.9).should == SystemCallError.new('foo', 2)
end
+ it "treats nil errno as unknown error value" do
+ SystemCallError.new(nil).should be_an_instance_of(SystemCallError)
+ end
+
+ it "treats nil custom message as if it is not passed at all" do
+ exc = SystemCallError.new(nil, @example_errno)
+ exc.message.should == 'Invalid argument'
+ end
+
+ it "sets an 'unknown error' message when an unknown error number" do
+ platform_is_not :windows do
+ SystemCallError.new(-1).message.should =~ /Unknown error(:)? -1/
+ end
+
+ platform_is :windows do
+ SystemCallError.new(-1).message.should == "The operation completed successfully."
+ end
+ end
+
+ it "adds a custom error message to an 'unknown error' message when an unknown error number and a custom message specified" do
+ platform_is_not :windows do
+ SystemCallError.new("custom message", -1).message.should =~ /Unknown error(:)? -1 - custom message/
+ end
+
+ platform_is :windows do
+ SystemCallError.new("custom message", -1).message.should == "The operation completed successfully. - custom message"
+ end
+ end
+
it "converts to Integer if errno is a Complex convertible to Integer" do
SystemCallError.new('foo', Complex(2.9, 0)).should == SystemCallError.new('foo', 2)
end
diff --git a/spec/ruby/core/io/pread_spec.rb b/spec/ruby/core/io/pread_spec.rb
index 6d93b432c2..dc7bcedf3e 100644
--- a/spec/ruby/core/io/pread_spec.rb
+++ b/spec/ruby/core/io/pread_spec.rb
@@ -59,6 +59,12 @@ guard -> { platform_is_not :windows or ruby_version_is "3.3" } do
@file.pread(0, 4).should == ""
end
+ it "returns a buffer for maxlen = 0 when buffer specified" do
+ buffer = +"foo"
+ @file.pread(0, 4, buffer).should.equal?(buffer)
+ buffer.should == "foo"
+ end
+
it "ignores the offset for maxlen = 0, even if it is out of file bounds" do
@file.pread(0, 400).should == ""
end
diff --git a/spec/ruby/core/io/set_encoding_by_bom_spec.rb b/spec/ruby/core/io/set_encoding_by_bom_spec.rb
index 92433d6640..30d5ce5a5a 100644
--- a/spec/ruby/core/io/set_encoding_by_bom_spec.rb
+++ b/spec/ruby/core/io/set_encoding_by_bom_spec.rb
@@ -62,11 +62,11 @@ describe "IO#set_encoding_by_bom" do
@io.rewind
@io.set_encoding(Encoding::ASCII_8BIT)
- File.binwrite(@name, "\xFE\xFFabc")
+ File.binwrite(@name, "\xFE\xFFabcd")
@io.set_encoding_by_bom.should == Encoding::UTF_16BE
@io.external_encoding.should == Encoding::UTF_16BE
- @io.read.b.should == "abc".b
+ @io.read.b.should == "abcd".b
end
it "returns the result encoding if found BOM UTF_32LE sequence" do
@@ -94,11 +94,11 @@ describe "IO#set_encoding_by_bom" do
@io.rewind
@io.set_encoding(Encoding::ASCII_8BIT)
- File.binwrite(@name, "\x00\x00\xFE\xFFabc")
+ File.binwrite(@name, "\x00\x00\xFE\xFFabcd")
@io.set_encoding_by_bom.should == Encoding::UTF_32BE
@io.external_encoding.should == Encoding::UTF_32BE
- @io.read.b.should == "abc".b
+ @io.read.b.should == "abcd".b
end
it "returns nil if io is empty" do
diff --git a/spec/ruby/core/kernel/sleep_spec.rb b/spec/ruby/core/kernel/sleep_spec.rb
index 607764464f..4401e54256 100644
--- a/spec/ruby/core/kernel/sleep_spec.rb
+++ b/spec/ruby/core/kernel/sleep_spec.rb
@@ -51,18 +51,15 @@ describe "Kernel#sleep" do
t.value.should == 5
end
- quarantine! do # fails transiently on at least linux & darwin
- it "sleeps with nanosecond precision" do
- start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
- 100.times do
- sleep(0.0001)
- end
- end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
-
- actual_duration = end_time - start_time
- (actual_duration > 0.01).should == true # 100 * 0.0001 => 0.01
- (actual_duration < 0.03).should == true
+ it "sleeps with nanosecond precision" do
+ start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
+ 100.times do
+ sleep(0.0001)
end
+ end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
+
+ actual_duration = end_time - start_time
+ actual_duration.should > 0.01 # 100 * 0.0001 => 0.01
end
ruby_version_is ""..."3.3" do
diff --git a/spec/ruby/core/marshal/dump_spec.rb b/spec/ruby/core/marshal/dump_spec.rb
index adabfdf025..05e473c64e 100644
--- a/spec/ruby/core/marshal/dump_spec.rb
+++ b/spec/ruby/core/marshal/dump_spec.rb
@@ -283,6 +283,28 @@ describe "Marshal.dump" do
end
end
+ ruby_version_is "3.2" do
+ describe "with a Data" do
+ it "dumps a Data" do
+ Marshal.dump(MarshalSpec::DataSpec::Measure.new(100, 'km')).should == "\x04\bS:#MarshalSpec::DataSpec::Measure\a:\vamountii:\tunit\"\akm"
+ end
+
+ it "dumps an extended Data" do
+ obj = MarshalSpec::DataSpec::MeasureExtended.new(100, "km")
+ Marshal.dump(obj).should == "\x04\bS:+MarshalSpec::DataSpec::MeasureExtended\a:\vamountii:\tunit\"\akm"
+ end
+
+ it "ignores overridden name method" do
+ obj = MarshalSpec::DataSpec::MeasureWithOverriddenName.new(100, "km")
+ Marshal.dump(obj).should == "\x04\bS:5MarshalSpec::DataSpec::MeasureWithOverriddenName\a:\vamountii:\tunit\"\akm"
+ end
+
+ it "raises TypeError with an anonymous Struct" do
+ -> { Marshal.dump(Data.define(:a).new(1)) }.should raise_error(TypeError, /can't dump anonymous class/)
+ end
+ end
+ end
+
describe "with a String" do
it "dumps a blank String" do
Marshal.dump("".dup.force_encoding("binary")).should == "\004\b\"\000"
diff --git a/spec/ruby/core/marshal/fixtures/marshal_data.rb b/spec/ruby/core/marshal/fixtures/marshal_data.rb
index aae3fce0aa..97fd78b2d7 100644
--- a/spec/ruby/core/marshal/fixtures/marshal_data.rb
+++ b/spec/ruby/core/marshal/fixtures/marshal_data.rb
@@ -486,6 +486,22 @@ module MarshalSpec
"\004\bS:\024Struct::Pyramid\000"],
"Random" => random_data,
}
+
+ if defined? Data # TODO: remove the condition when minimal supported version is 3.2
+ module DataSpec
+ Measure = Data.define(:amount, :unit)
+ Empty = Data.define
+
+ MeasureExtended = Class.new(Measure)
+ MeasureExtended.extend(Enumerable)
+
+ class MeasureWithOverriddenName < Measure
+ def self.name
+ "Foo"
+ end
+ end
+ end
+ end
end
class ArraySub < Array
diff --git a/spec/ruby/core/marshal/shared/load.rb b/spec/ruby/core/marshal/shared/load.rb
index 4eac21a952..fd6490153c 100644
--- a/spec/ruby/core/marshal/shared/load.rb
+++ b/spec/ruby/core/marshal/shared/load.rb
@@ -749,6 +749,34 @@ describe :marshal_load, shared: true do
end
end
+ ruby_version_is "3.2" do
+ describe "for a Data" do
+ it "loads a Data" do
+ obj = MarshalSpec::DataSpec::Measure.new(100, 'km')
+ dumped = "\x04\bS:#MarshalSpec::DataSpec::Measure\a:\vamountii:\tunit\"\akm"
+ Marshal.dump(obj).should == dumped
+
+ Marshal.send(@method, dumped).should == obj
+ end
+
+ it "loads an extended Data" do
+ obj = MarshalSpec::DataSpec::MeasureExtended.new(100, "km")
+ dumped = "\x04\bS:+MarshalSpec::DataSpec::MeasureExtended\a:\vamountii:\tunit\"\akm"
+ Marshal.dump(obj).should == dumped
+
+ Marshal.send(@method, dumped).should == obj
+ end
+
+ it "returns a frozen object" do
+ obj = MarshalSpec::DataSpec::Measure.new(100, 'km')
+ dumped = "\x04\bS:#MarshalSpec::DataSpec::Measure\a:\vamountii:\tunit\"\akm"
+ Marshal.dump(obj).should == dumped
+
+ Marshal.send(@method, dumped).should.frozen?
+ end
+ end
+ end
+
describe "for an Exception" do
it "loads a marshalled exception with no message" do
obj = Exception.new
diff --git a/spec/ruby/core/process/status/bit_and_spec.rb b/spec/ruby/core/process/status/bit_and_spec.rb
index 97f768fdc1..f4a4328907 100644
--- a/spec/ruby/core/process/status/bit_and_spec.rb
+++ b/spec/ruby/core/process/status/bit_and_spec.rb
@@ -1,5 +1,35 @@
require_relative '../../../spec_helper'
describe "Process::Status#&" do
- it "needs to be reviewed for spec completeness"
+ it "returns a bitwise and of the integer status of an exited child" do
+ suppress_warning do
+ ruby_exe("exit(29)", exit_status: 29)
+ ($? & 0).should == 0
+ ($? & $?.to_i).should == $?.to_i
+
+ # Actual value is implementation specific
+ platform_is :linux do
+ # 29 == 0b11101
+ ($? & 0b1011100000000).should == 0b1010100000000
+ end
+ end
+ end
+
+ ruby_version_is "3.3" do
+ it "raises an ArgumentError if mask is negative" do
+ suppress_warning do
+ ruby_exe("exit(0)")
+ -> {
+ $? & -1
+ }.should raise_error(ArgumentError, 'negative mask value: -1')
+ end
+ end
+
+ it "shows a deprecation warning" do
+ ruby_exe("exit(0)")
+ -> {
+ $? & 0
+ }.should complain(/warning: Process::Status#& is deprecated and will be removed .*use other Process::Status predicates instead/)
+ end
+ end
end
diff --git a/spec/ruby/core/process/status/right_shift_spec.rb b/spec/ruby/core/process/status/right_shift_spec.rb
index e9dda437e8..034ce348cb 100644
--- a/spec/ruby/core/process/status/right_shift_spec.rb
+++ b/spec/ruby/core/process/status/right_shift_spec.rb
@@ -1,5 +1,34 @@
require_relative '../../../spec_helper'
describe "Process::Status#>>" do
- it "needs to be reviewed for spec completeness"
+ it "returns a right shift of the integer status of an exited child" do
+ suppress_warning do
+ ruby_exe("exit(29)", exit_status: 29)
+ ($? >> 0).should == $?.to_i
+ ($? >> 1).should == $?.to_i >> 1
+
+ # Actual value is implementation specific
+ platform_is :linux do
+ ($? >> 8).should == 29
+ end
+ end
+ end
+
+ ruby_version_is "3.3" do
+ it "raises an ArgumentError if shift value is negative" do
+ suppress_warning do
+ ruby_exe("exit(0)")
+ -> {
+ $? >> -1
+ }.should raise_error(ArgumentError, 'negative shift value: -1')
+ end
+ end
+
+ it "shows a deprecation warning" do
+ ruby_exe("exit(0)")
+ -> {
+ $? >> 0
+ }.should complain(/warning: Process::Status#>> is deprecated and will be removed .*use other Process::Status attributes instead/)
+ end
+ end
end
diff --git a/spec/ruby/core/range/reverse_each_spec.rb b/spec/ruby/core/range/reverse_each_spec.rb
new file mode 100644
index 0000000000..b51e04c3ff
--- /dev/null
+++ b/spec/ruby/core/range/reverse_each_spec.rb
@@ -0,0 +1,103 @@
+require_relative '../../spec_helper'
+
+ruby_version_is "3.3" do
+ describe "Range#reverse_each" do
+ it "traverses the Range in reverse order and passes each element to block" do
+ a = []
+ (1..3).reverse_each { |i| a << i }
+ a.should == [3, 2, 1]
+
+ a = []
+ (1...3).reverse_each { |i| a << i }
+ a.should == [2, 1]
+ end
+
+ it "returns self" do
+ r = (1..3)
+ r.reverse_each { |x| }.should equal(r)
+ end
+
+ it "returns an Enumerator if no block given" do
+ enum = (1..3).reverse_each
+ enum.should be_an_instance_of(Enumerator)
+ enum.to_a.should == [3, 2, 1]
+ end
+
+ it "raises a TypeError for endless Ranges of Integers" do
+ -> {
+ (1..).reverse_each.take(3)
+ }.should raise_error(TypeError, "can't iterate from NilClass")
+ end
+
+ it "raises a TypeError for endless Ranges of non-Integers" do
+ -> {
+ ("a"..).reverse_each.take(3)
+ }.should raise_error(TypeError, "can't iterate from NilClass")
+ end
+
+ context "Integer boundaries" do
+ it "supports beginningless Ranges" do
+ (..5).reverse_each.take(3).should == [5, 4, 3]
+ end
+ end
+
+ context "non-Integer boundaries" do
+ it "uses #succ to iterate a Range of non-Integer elements" do
+ y = mock('y')
+ x = mock('x')
+
+ x.should_receive(:succ).any_number_of_times.and_return(y)
+ x.should_receive(:<=>).with(y).any_number_of_times.and_return(-1)
+ x.should_receive(:<=>).with(x).any_number_of_times.and_return(0)
+ y.should_receive(:<=>).with(x).any_number_of_times.and_return(1)
+ y.should_receive(:<=>).with(y).any_number_of_times.and_return(0)
+
+ a = []
+ (x..y).each { |i| a << i }
+ a.should == [x, y]
+ end
+
+ it "uses #succ to iterate a Range of Strings" do
+ a = []
+ ('A'..'D').reverse_each { |i| a << i }
+ a.should == ['D','C','B','A']
+ end
+
+ it "uses #succ to iterate a Range of Symbols" do
+ a = []
+ (:A..:D).reverse_each { |i| a << i }
+ a.should == [:D, :C, :B, :A]
+ end
+
+ it "raises a TypeError when `begin` value does not respond to #succ" do
+ -> { (Time.now..Time.now).reverse_each { |x| x } }.should raise_error(TypeError, /can't iterate from Time/)
+ -> { (//..//).reverse_each { |x| x } }.should raise_error(TypeError, /can't iterate from Regexp/)
+ -> { ([]..[]).reverse_each { |x| x } }.should raise_error(TypeError, /can't iterate from Array/)
+ end
+
+ it "does not support beginningless Ranges" do
+ -> {
+ (..'a').reverse_each { |x| x }
+ }.should raise_error(TypeError, /can't iterate from NilClass/)
+ end
+ end
+
+ context "when no block is given" do
+ describe "returned Enumerator size" do
+ it "returns the Range size when Range size is finite" do
+ (1..3).reverse_each.size.should == 3
+ end
+
+ ruby_bug "#20936", "3.4"..."3.5" do
+ it "returns Infinity when Range size is infinite" do
+ (..3).reverse_each.size.should == Float::INFINITY
+ end
+ end
+
+ it "returns nil when Range size is unknown" do
+ ('a'..'z').reverse_each.size.should == nil
+ end
+ end
+ end
+ end
+end
diff --git a/spec/ruby/core/refinement/refined_class_spec.rb b/spec/ruby/core/refinement/refined_class_spec.rb
index 00b65d0895..acc6e2cb2b 100644
--- a/spec/ruby/core/refinement/refined_class_spec.rb
+++ b/spec/ruby/core/refinement/refined_class_spec.rb
@@ -1,8 +1,29 @@
-require_relative '../../spec_helper'
+require_relative "../../spec_helper"
+require_relative 'shared/target'
describe "Refinement#refined_class" do
ruby_version_is "3.2"..."3.3" do
- it "returns the class refined by the receiver" do
+ it_behaves_like :refinement_target, :refined_class
+ end
+
+ ruby_version_is "3.3"..."3.4" do
+ it "has been deprecated in favour of Refinement#target" do
+ refinement_int = nil
+
+ Module.new do
+ refine Integer do
+ refinement_int = self
+ end
+ end
+
+ -> {
+ refinement_int.refined_class
+ }.should complain(/warning: Refinement#refined_class is deprecated and will be removed in Ruby 3.4; use Refinement#target instead/)
+ end
+ end
+
+ ruby_version_is "3.4" do
+ it "has been removed" do
refinement_int = nil
Module.new do
@@ -11,7 +32,7 @@ describe "Refinement#refined_class" do
end
end
- refinement_int.refined_class.should == Integer
+ refinement_int.should_not.respond_to?(:refined_class)
end
end
end
diff --git a/spec/ruby/core/refinement/shared/target.rb b/spec/ruby/core/refinement/shared/target.rb
new file mode 100644
index 0000000000..79557bea0b
--- /dev/null
+++ b/spec/ruby/core/refinement/shared/target.rb
@@ -0,0 +1,13 @@
+describe :refinement_target, shared: true do
+ it "returns the class refined by the receiver" do
+ refinement_int = nil
+
+ Module.new do
+ refine Integer do
+ refinement_int = self
+ end
+ end
+
+ refinement_int.send(@method).should == Integer
+ end
+end
diff --git a/spec/ruby/core/refinement/target_spec.rb b/spec/ruby/core/refinement/target_spec.rb
new file mode 100644
index 0000000000..fee9588a96
--- /dev/null
+++ b/spec/ruby/core/refinement/target_spec.rb
@@ -0,0 +1,8 @@
+require_relative "../../spec_helper"
+require_relative 'shared/target'
+
+describe "Refinement#target" do
+ ruby_version_is "3.3" do
+ it_behaves_like :refinement_target, :target
+ end
+end
diff --git a/spec/ruby/core/string/unpack/shared/basic.rb b/spec/ruby/core/string/unpack/shared/basic.rb
index bb5302edc5..b37a447683 100644
--- a/spec/ruby/core/string/unpack/shared/basic.rb
+++ b/spec/ruby/core/string/unpack/shared/basic.rb
@@ -8,6 +8,15 @@ describe :string_unpack_basic, shared: true do
d.should_receive(:to_str).and_return("a"+unpack_format)
"abc".unpack(d).should be_an_instance_of(Array)
end
+
+ ruby_version_is "3.3" do
+ # https://bugs.ruby-lang.org/issues/19150
+ it 'raise ArgumentError when a directive is unknown' do
+ -> { "abcdefgh".unpack("a R" + unpack_format) }.should raise_error(ArgumentError, /unknown unpack directive 'R'/)
+ -> { "abcdefgh".unpack("a 0" + unpack_format) }.should raise_error(ArgumentError, /unknown unpack directive '0'/)
+ -> { "abcdefgh".unpack("a :" + unpack_format) }.should raise_error(ArgumentError, /unknown unpack directive ':'/)
+ end
+ end
end
describe :string_unpack_no_platform, shared: true do
diff --git a/spec/ruby/core/time/comparison_spec.rb b/spec/ruby/core/time/comparison_spec.rb
index 5b53c9fb50..866fbea72e 100644
--- a/spec/ruby/core/time/comparison_spec.rb
+++ b/spec/ruby/core/time/comparison_spec.rb
@@ -55,6 +55,32 @@ describe "Time#<=>" do
}.should_not complain
end
+ context "given different timezones" do
+ it "returns 0 if time is the same as other" do
+ # three timezones, all at the same timestamp
+ time_utc = Time.new(2000, 1, 1, 0, 0, 0, 0)
+ time_cet = Time.new(2000, 1, 1, 1, 0, 0, '+01:00')
+ time_brt = Time.new(1999, 12, 31, 21, 0, 0, '-03:00')
+ (time_utc <=> time_cet).should == 0
+ (time_utc <=> time_brt).should == 0
+ (time_cet <=> time_brt).should == 0
+ end
+
+ it "returns -1 if the first argument is before the second argument" do
+ # time_brt is later, even though the date is earlier
+ time_utc = Time.new(2000, 1, 1, 0, 0, 0, 0)
+ time_brt = Time.new(1999, 12, 31, 23, 0, 0, '-03:00')
+ (time_utc <=> time_brt).should == -1
+ end
+
+ it "returns 1 if the first argument is before the second argument" do
+ # time_brt is later, even though the date is earlier
+ time_utc = Time.new(2000, 1, 1, 0, 0, 0, 0)
+ time_brt = Time.new(1999, 12, 31, 23, 0, 0, '-03:00')
+ (time_brt <=> time_utc).should == 1
+ end
+ end
+
describe "given a non-Time argument" do
it "returns nil if argument <=> self returns nil" do
t = Time.now
diff --git a/spec/ruby/core/time/new_spec.rb b/spec/ruby/core/time/new_spec.rb
index c310a8631e..24bb9fde0c 100644
--- a/spec/ruby/core/time/new_spec.rb
+++ b/spec/ruby/core/time/new_spec.rb
@@ -564,6 +564,12 @@ describe "Time.new with a timezone argument" do
Time.new("2020-12-25")
}.should raise_error(ArgumentError, /no time information|can't parse:/)
end
+
+ it "raises ArgumentError if day is missing" do
+ -> {
+ Time.new("2020-12")
+ }.should raise_error(ArgumentError, /no time information|can't parse:/)
+ end
end
it "raises ArgumentError if subsecond is missing after dot" do
@@ -679,6 +685,26 @@ describe "Time.new with a timezone argument" do
Time.new("2021-11-31 00:00:59 +09:00 abc")
}.should raise_error(ArgumentError, /can't parse.+ abc/)
end
+
+ ruby_version_is "3.2.3" do
+ it "raises ArgumentError when there are leading space characters" do
+ -> { Time.new(" 2020-12-02 00:00:00") }.should raise_error(ArgumentError, /can't parse/)
+ -> { Time.new("\t2020-12-02 00:00:00") }.should raise_error(ArgumentError, /can't parse/)
+ -> { Time.new("\n2020-12-02 00:00:00") }.should raise_error(ArgumentError, /can't parse/)
+ -> { Time.new("\v2020-12-02 00:00:00") }.should raise_error(ArgumentError, /can't parse/)
+ -> { Time.new("\f2020-12-02 00:00:00") }.should raise_error(ArgumentError, /can't parse/)
+ -> { Time.new("\r2020-12-02 00:00:00") }.should raise_error(ArgumentError, /can't parse/)
+ end
+
+ it "raises ArgumentError when there are trailing whitespaces" do
+ -> { Time.new("2020-12-02 00:00:00 ") }.should raise_error(ArgumentError, /can't parse/)
+ -> { Time.new("2020-12-02 00:00:00\t") }.should raise_error(ArgumentError, /can't parse/)
+ -> { Time.new("2020-12-02 00:00:00\n") }.should raise_error(ArgumentError, /can't parse/)
+ -> { Time.new("2020-12-02 00:00:00\v") }.should raise_error(ArgumentError, /can't parse/)
+ -> { Time.new("2020-12-02 00:00:00\f") }.should raise_error(ArgumentError, /can't parse/)
+ -> { Time.new("2020-12-02 00:00:00\r") }.should raise_error(ArgumentError, /can't parse/)
+ end
+ end
end
end
end
diff --git a/spec/ruby/core/time/shared/gmtime.rb b/spec/ruby/core/time/shared/gmtime.rb
index bae19da462..7b4f65f0b7 100644
--- a/spec/ruby/core/time/shared/gmtime.rb
+++ b/spec/ruby/core/time/shared/gmtime.rb
@@ -4,7 +4,14 @@ describe :time_gmtime, shared: true do
with_timezone("CST", -6) do
t = Time.local(2007, 1, 9, 6, 0, 0)
t.send(@method)
- t.should == Time.gm(2007, 1, 9, 12, 0, 0)
+ # Time#== compensates for time zones, so check all parts separately
+ t.year.should == 2007
+ t.month.should == 1
+ t.mday.should == 9
+ t.hour.should == 12
+ t.min.should == 0
+ t.sec.should == 0
+ t.zone.should == "UTC"
end
end
diff --git a/spec/ruby/core/tracepoint/raised_exception_spec.rb b/spec/ruby/core/tracepoint/raised_exception_spec.rb
index ca2f50abb3..5ac8531840 100644
--- a/spec/ruby/core/tracepoint/raised_exception_spec.rb
+++ b/spec/ruby/core/tracepoint/raised_exception_spec.rb
@@ -17,4 +17,22 @@ describe 'TracePoint#raised_exception' do
raised_exception.should equal(error_result)
end
end
+
+ ruby_version_is "3.3" do
+ it 'returns value from exception rescued on the :rescue event' do
+ raised_exception, error_result = nil
+ trace = TracePoint.new(:rescue) { |tp|
+ next unless TracePointSpec.target_thread?
+ raised_exception = tp.raised_exception
+ }
+ trace.enable do
+ begin
+ raise StandardError
+ rescue => e
+ error_result = e
+ end
+ raised_exception.should equal(error_result)
+ end
+ end
+ end
end
diff --git a/spec/ruby/language/block_spec.rb b/spec/ruby/language/block_spec.rb
index cf0931b688..75c1e71bc2 100644
--- a/spec/ruby/language/block_spec.rb
+++ b/spec/ruby/language/block_spec.rb
@@ -999,6 +999,7 @@ describe "Post-args" do
end
end
+# tested more thoroughly in language/delegation_spec.rb
describe "Anonymous block forwarding" do
ruby_version_is "3.1" do
it "forwards blocks to other method that formally declares anonymous block" do
@@ -1072,3 +1073,32 @@ describe "Anonymous block forwarding" do
end
end
end
+
+describe "`it` calls without arguments in a block with no ordinary parameters" do
+ ruby_version_is "3.3"..."3.4" do
+ it "emits a deprecation warning" do
+ -> {
+ eval "proc { it }"
+ }.should complain(/warning: `it` calls without arguments will refer to the first block param in Ruby 3.4; use it\(\) or self.it/)
+ end
+
+ it "does not emit a deprecation warning when a block has parameters" do
+ -> { eval "proc { |a, b| it }" }.should_not complain
+ -> { eval "proc { |*rest| it }" }.should_not complain
+ -> { eval "proc { |*| it }" }.should_not complain
+ -> { eval "proc { |a:, b:| it }" }.should_not complain
+ -> { eval "proc { |**kw| it }" }.should_not complain
+ -> { eval "proc { |**| it }" }.should_not complain
+ -> { eval "proc { |&block| it }" }.should_not complain
+ -> { eval "proc { |&| it }" }.should_not complain
+ end
+
+ it "does not emit a deprecation warning when `it` calls with arguments" do
+ -> { eval "proc { it(42) }" }.should_not complain
+ end
+
+ it "does not emit a deprecation warning when `it` calls with explicit empty arguments list" do
+ -> { eval "proc { it() }" }.should_not complain
+ end
+ end
+end
diff --git a/spec/ruby/language/defined_spec.rb b/spec/ruby/language/defined_spec.rb
index 34408c0190..80ad1818b1 100644
--- a/spec/ruby/language/defined_spec.rb
+++ b/spec/ruby/language/defined_spec.rb
@@ -900,6 +900,10 @@ describe "The defined? keyword for a scoped constant" do
defined?(DefinedSpecs::Undefined).should be_nil
end
+ it "returns nil when the constant is not defined and the outer module implements .const_missing" do
+ defined?(DefinedSpecs::ModuleWithConstMissing::Undefined).should be_nil
+ end
+
it "does not call .const_missing if the constant is not defined" do
DefinedSpecs.should_not_receive(:const_missing)
defined?(DefinedSpecs::UnknownChild).should be_nil
diff --git a/spec/ruby/language/delegation_spec.rb b/spec/ruby/language/delegation_spec.rb
index d780506421..b75f3f5f7c 100644
--- a/spec/ruby/language/delegation_spec.rb
+++ b/spec/ruby/language/delegation_spec.rb
@@ -1,6 +1,7 @@
require_relative '../spec_helper'
require_relative 'fixtures/delegation'
+# Forwarding anonymous parameters
describe "delegation with def(...)" do
it "delegates rest and kwargs" do
a = Class.new(DelegationSpecs::Target)
@@ -10,10 +11,10 @@ describe "delegation with def(...)" do
end
RUBY
- a.new.delegate(1, b: 2).should == [[1], {b: 2}]
+ a.new.delegate(1, b: 2).should == [[1], {b: 2}, nil]
end
- it "delegates block" do
+ it "delegates a block literal" do
a = Class.new(DelegationSpecs::Target)
a.class_eval(<<-RUBY)
def delegate_block(...)
@@ -24,6 +25,18 @@ describe "delegation with def(...)" do
a.new.delegate_block(1, b: 2) { |x| x }.should == [{b: 2}, [1]]
end
+ it "delegates a block argument" do
+ a = Class.new(DelegationSpecs::Target)
+ a.class_eval(<<-RUBY)
+ def delegate(...)
+ target(...)
+ end
+ RUBY
+
+ block = proc {}
+ a.new.delegate(1, b: 2, &block).should == [[1], {b: 2}, block]
+ end
+
it "parses as open endless Range when brackets are omitted" do
a = Class.new(DelegationSpecs::Target)
suppress_warning do
@@ -34,7 +47,7 @@ describe "delegation with def(...)" do
RUBY
end
- a.new.delegate(1, b: 2).should == Range.new([[], {}], nil, true)
+ a.new.delegate(1, b: 2).should == Range.new([[], {}, nil], nil, true)
end
end
@@ -47,10 +60,10 @@ describe "delegation with def(x, ...)" do
end
RUBY
- a.new.delegate(0, 1, b: 2).should == [[1], {b: 2}]
+ a.new.delegate(0, 1, b: 2).should == [[1], {b: 2}, nil]
end
- it "delegates block" do
+ it "delegates a block literal" do
a = Class.new(DelegationSpecs::Target)
a.class_eval(<<-RUBY)
def delegate_block(x, ...)
@@ -60,6 +73,18 @@ describe "delegation with def(x, ...)" do
a.new.delegate_block(0, 1, b: 2) { |x| x }.should == [{b: 2}, [1]]
end
+
+ it "delegates a block argument" do
+ a = Class.new(DelegationSpecs::Target)
+ a.class_eval(<<-RUBY)
+ def delegate(...)
+ target(...)
+ end
+ RUBY
+
+ block = proc {}
+ a.new.delegate(1, b: 2, &block).should == [[1], {b: 2}, block]
+ end
end
ruby_version_is "3.2" do
@@ -70,9 +95,19 @@ ruby_version_is "3.2" do
def delegate(*)
target(*)
end
- RUBY
+ RUBY
- a.new.delegate(0, 1).should == [[0, 1], {}]
+ a.new.delegate(0, 1).should == [[0, 1], {}, nil]
+ end
+
+ ruby_version_is "3.3" do
+ context "within a block that accepts anonymous rest within a method that accepts anonymous rest" do
+ it "does not allow delegating rest" do
+ -> {
+ eval "def m(*); proc { |*| n(*) } end"
+ }.should raise_error(SyntaxError, /anonymous rest parameter is also used within block/)
+ end
+ end
end
end
end
@@ -85,9 +120,45 @@ ruby_version_is "3.2" do
def delegate(**)
target(**)
end
- RUBY
+ RUBY
+
+ a.new.delegate(a: 1) { |x| x }.should == [[], {a: 1}, nil]
+ end
- a.new.delegate(a: 1) { |x| x }.should == [[], {a: 1}]
+ ruby_version_is "3.3" do
+ context "within a block that accepts anonymous kwargs within a method that accepts anonymous kwargs" do
+ it "does not allow delegating kwargs" do
+ -> {
+ eval "def m(**); proc { |**| n(**) } end"
+ }.should raise_error(SyntaxError, /anonymous keyword rest parameter is also used within block/)
+ end
+ end
+ end
+ end
+end
+
+ruby_version_is "3.1" do
+ describe "delegation with def(&)" do
+ it "delegates an anonymous block parameter" do
+ a = Class.new(DelegationSpecs::Target)
+ a.class_eval(<<-RUBY)
+ def delegate(&)
+ target(&)
+ end
+ RUBY
+
+ block = proc {}
+ a.new.delegate(&block).should == [[], {}, block]
+ end
+
+ ruby_version_is "3.3" do
+ context "within a block that accepts anonymous block within a method that accepts anonymous block" do
+ it "does not allow delegating a block" do
+ -> {
+ eval "def m(&); proc { |&| n(&) } end"
+ }.should raise_error(SyntaxError, /anonymous block parameter is also used within block/)
+ end
+ end
end
end
end
diff --git a/spec/ruby/language/fixtures/defined.rb b/spec/ruby/language/fixtures/defined.rb
index a9552619bf..3761cfa5bd 100644
--- a/spec/ruby/language/fixtures/defined.rb
+++ b/spec/ruby/language/fixtures/defined.rb
@@ -285,6 +285,12 @@ module DefinedSpecs
end
end
+ module ModuleWithConstMissing
+ def self.const_missing(const)
+ const
+ end
+ end
+
class SuperWithIntermediateModules
include IntermediateModule1
include IntermediateModule2
diff --git a/spec/ruby/language/fixtures/delegation.rb b/spec/ruby/language/fixtures/delegation.rb
index 527d928390..da2b024791 100644
--- a/spec/ruby/language/fixtures/delegation.rb
+++ b/spec/ruby/language/fixtures/delegation.rb
@@ -1,7 +1,7 @@
module DelegationSpecs
class Target
- def target(*args, **kwargs)
- [args, kwargs]
+ def target(*args, **kwargs, &block)
+ [args, kwargs, block]
end
def target_block(*args, **kwargs)
diff --git a/spec/ruby/library/random/formatter/alphanumeric_spec.rb b/spec/ruby/library/random/formatter/alphanumeric_spec.rb
new file mode 100644
index 0000000000..df14c29e24
--- /dev/null
+++ b/spec/ruby/library/random/formatter/alphanumeric_spec.rb
@@ -0,0 +1,58 @@
+require_relative '../../../spec_helper'
+
+ruby_version_is "3.1" do
+ require 'random/formatter'
+
+ describe "Random::Formatter#alphanumeric" do
+ before :each do
+ @object = Object.new
+ @object.extend(Random::Formatter)
+ @object.define_singleton_method(:bytes) do |n|
+ "\x00".b * n
+ end
+ end
+
+ it "generates a random alphanumeric string" do
+ @object.alphanumeric.should =~ /\A[A-Za-z0-9]+\z/
+ end
+
+ it "has a default size of 16 characters" do
+ @object.alphanumeric.size.should == 16
+ end
+
+ it "accepts a 'size' argument" do
+ @object.alphanumeric(10).size.should == 10
+ end
+
+ it "uses the default size if 'nil' is given as size argument" do
+ @object.alphanumeric(nil).size.should == 16
+ end
+
+ it "raises an ArgumentError if the size is not numeric" do
+ -> {
+ @object.alphanumeric("10")
+ }.should raise_error(ArgumentError)
+ end
+
+ it "does not coerce the size argument with #to_int" do
+ size = mock("size")
+ size.should_not_receive(:to_int)
+ -> {
+ @object.alphanumeric(size)
+ }.should raise_error(ArgumentError)
+ end
+
+ ruby_version_is "3.3" do
+ it "accepts a 'chars' argument with the output alphabet" do
+ @object.alphanumeric(chars: ['a', 'b']).should =~ /\A[ab]+\z/
+ end
+
+ it "converts the elements of chars using #to_s" do
+ to_s = mock("to_s")
+ to_s.should_receive(:to_s).and_return("[mock to_s]")
+ # Using 1 value in chars results in an infinite loop
+ @object.alphanumeric(1, chars: [to_s, to_s]).should == "[mock to_s]"
+ end
+ end
+ end
+end
diff --git a/spec/ruby/library/securerandom/random_number_spec.rb b/spec/ruby/library/securerandom/random_number_spec.rb
index 03781f4901..bb25bc496e 100644
--- a/spec/ruby/library/securerandom/random_number_spec.rb
+++ b/spec/ruby/library/securerandom/random_number_spec.rb
@@ -11,8 +11,8 @@ describe "SecureRandom.random_number" do
(1..64).each do |idx|
num = SecureRandom.random_number(idx)
num.should be_kind_of(Integer)
- (0 <= num).should == true
- (num < idx).should == true
+ 0.should <= num
+ num.should < idx
end
end
@@ -21,8 +21,8 @@ describe "SecureRandom.random_number" do
11.times do
num = SecureRandom.random_number max
num.should be_kind_of(Integer)
- (0 <= num).should == true
- (num < max).should == true
+ 0.should <= num
+ num.should < max
end
end
@@ -30,8 +30,8 @@ describe "SecureRandom.random_number" do
64.times do
num = SecureRandom.random_number
num.should be_kind_of(Float)
- (0.0 <= num).should == true
- (num < 1.0).should == true
+ 0.0.should <= num
+ num.should < 1.0
end
end
@@ -39,8 +39,8 @@ describe "SecureRandom.random_number" do
64.times do
num = SecureRandom.random_number 11...13
num.should be_kind_of(Integer)
- (11 <= num).should == true
- (num < 13).should == true
+ 11.should <= num
+ num.should < 13
end
end
@@ -50,8 +50,8 @@ describe "SecureRandom.random_number" do
32.times do
num = SecureRandom.random_number lower..upper
num.should be_kind_of(Integer)
- (lower <= num).should == true
- (num <= upper).should == true
+ lower.should <= num
+ num.should <= upper
end
end
@@ -59,23 +59,23 @@ describe "SecureRandom.random_number" do
64.times do
num = SecureRandom.random_number 0.6..0.9
num.should be_kind_of(Float)
- (0.6 <= num).should == true
- (num <= 0.9).should == true
+ 0.6.should <= num
+ num.should <= 0.9
end
end
it "generates a random float number between 0.0 and 1.0 if argument is negative" do
num = SecureRandom.random_number(-10)
num.should be_kind_of(Float)
- (0.0 <= num).should == true
- (num < 1.0).should == true
+ 0.0.should <= num
+ num.should < 1.0
end
it "generates a random float number between 0.0 and 1.0 if argument is negative float" do
num = SecureRandom.random_number(-11.1)
num.should be_kind_of(Float)
- (0.0 <= num).should == true
- (num < 1.0).should == true
+ 0.0.should <= num
+ num.should < 1.0
end
it "generates different float numbers with subsequent invocations" do
@@ -84,7 +84,7 @@ describe "SecureRandom.random_number" do
256.times do
val = SecureRandom.random_number
# make sure the random values are not repeating
- values.include?(val).should == false
+ values.should_not include(val)
values << val
end
end
diff --git a/spec/ruby/library/stringio/shared/write.rb b/spec/ruby/library/stringio/shared/write.rb
index 404e08b93d..4661658baf 100644
--- a/spec/ruby/library/stringio/shared/write.rb
+++ b/spec/ruby/library/stringio/shared/write.rb
@@ -94,7 +94,7 @@ describe :stringio_write_string, shared: true do
end
it "does not transcode the given string when the external encoding is set and the string encoding is BINARY" do
- str = "été".b
+ str = "été_".b
io = StringIO.new.set_encoding(Encoding::UTF_16BE)
io.external_encoding.should == Encoding::UTF_16BE
diff --git a/spec/ruby/library/time/iso8601_spec.rb b/spec/ruby/library/time/iso8601_spec.rb
index 9e2607fbd0..ab35ab25d6 100644
--- a/spec/ruby/library/time/iso8601_spec.rb
+++ b/spec/ruby/library/time/iso8601_spec.rb
@@ -2,6 +2,6 @@ require_relative '../../spec_helper'
require_relative 'shared/xmlschema'
require 'time'
-describe "Time.xmlschema" do
+describe "Time.iso8601" do
it_behaves_like :time_library_xmlschema, :iso8601
end
diff --git a/spec/ruby/optional/capi/ext/hash_spec.c b/spec/ruby/optional/capi/ext/hash_spec.c
index 69ef02d5da..e7fdbb10f4 100644
--- a/spec/ruby/optional/capi/ext/hash_spec.c
+++ b/spec/ruby/optional/capi/ext/hash_spec.c
@@ -134,6 +134,20 @@ VALUE hash_spec_compute_a_hash_code(VALUE self, VALUE seed) {
return ULONG2NUM(h);
}
+VALUE hash_spec_rb_hash_bulk_insert(VALUE self, VALUE array_len, VALUE array, VALUE hash) {
+ VALUE* ptr;
+
+ if (array == Qnil) {
+ ptr = NULL;
+ } else {
+ ptr = RARRAY_PTR(array);
+ }
+
+ long len = FIX2LONG(array_len);
+ rb_hash_bulk_insert(len, ptr, hash);
+ return Qnil;
+}
+
void Init_hash_spec(void) {
VALUE cls = rb_define_class("CApiHashSpecs", rb_cObject);
rb_define_method(cls, "rb_hash", hash_spec_rb_hash, 1);
@@ -162,6 +176,7 @@ void Init_hash_spec(void) {
rb_define_method(cls, "rb_hash_size", hash_spec_rb_hash_size, 1);
rb_define_method(cls, "rb_hash_set_ifnone", hash_spec_rb_hash_set_ifnone, 2);
rb_define_method(cls, "compute_a_hash_code", hash_spec_compute_a_hash_code, 1);
+ rb_define_method(cls, "rb_hash_bulk_insert", hash_spec_rb_hash_bulk_insert, 3);
}
#ifdef __cplusplus
diff --git a/spec/ruby/optional/capi/ext/io_spec.c b/spec/ruby/optional/capi/ext/io_spec.c
index e0b1df0de7..d1cc861e21 100644
--- a/spec/ruby/optional/capi/ext/io_spec.c
+++ b/spec/ruby/optional/capi/ext/io_spec.c
@@ -371,6 +371,27 @@ static VALUE io_spec_rb_io_mode(VALUE self, VALUE io) {
static VALUE io_spec_rb_io_path(VALUE self, VALUE io) {
return rb_io_path(io);
}
+
+static VALUE io_spec_rb_io_closed_p(VALUE self, VALUE io) {
+ return rb_io_closed_p(io);
+}
+
+static VALUE io_spec_rb_io_open_descriptor(VALUE self, VALUE klass, VALUE descriptor, VALUE mode, VALUE path, VALUE timeout, VALUE internal_encoding, VALUE external_encoding, VALUE ecflags, VALUE ecopts) {
+ struct rb_io_encoding *io_encoding;
+
+ io_encoding = (struct rb_io_encoding *) malloc(sizeof(struct rb_io_encoding));
+
+ io_encoding->enc = rb_to_encoding(internal_encoding);
+ io_encoding->enc2 = rb_to_encoding(external_encoding);
+ io_encoding->ecflags = FIX2INT(ecflags);
+ io_encoding->ecopts = ecopts;
+
+ return rb_io_open_descriptor(klass, FIX2INT(descriptor), FIX2INT(mode), path, timeout, io_encoding);
+}
+
+static VALUE io_spec_rb_io_open_descriptor_without_encoding(VALUE self, VALUE klass, VALUE descriptor, VALUE mode, VALUE path, VALUE timeout) {
+ return rb_io_open_descriptor(klass, FIX2INT(descriptor), FIX2INT(mode), path, timeout, NULL);
+}
#endif
void Init_io_spec(void) {
@@ -409,6 +430,14 @@ void Init_io_spec(void) {
#if defined(RUBY_VERSION_IS_3_3) || defined(TRUFFLERUBY)
rb_define_method(cls, "rb_io_mode", io_spec_rb_io_mode, 1);
rb_define_method(cls, "rb_io_path", io_spec_rb_io_path, 1);
+ rb_define_method(cls, "rb_io_closed_p", io_spec_rb_io_closed_p, 1);
+ rb_define_method(cls, "rb_io_open_descriptor", io_spec_rb_io_open_descriptor, 9);
+ rb_define_method(cls, "rb_io_open_descriptor_without_encoding", io_spec_rb_io_open_descriptor_without_encoding, 5);
+ rb_define_const(cls, "FMODE_READABLE", INT2FIX(FMODE_READABLE));
+ rb_define_const(cls, "FMODE_WRITABLE", INT2FIX(FMODE_WRITABLE));
+ rb_define_const(cls, "FMODE_BINMODE", INT2FIX(FMODE_BINMODE));
+ rb_define_const(cls, "FMODE_TEXTMODE", INT2FIX(FMODE_TEXTMODE));
+ rb_define_const(cls, "ECONV_UNIVERSAL_NEWLINE_DECORATOR", INT2FIX(ECONV_UNIVERSAL_NEWLINE_DECORATOR));
#endif
}
diff --git a/spec/ruby/optional/capi/ext/kernel_spec.c b/spec/ruby/optional/capi/ext/kernel_spec.c
index e6bf4870ec..abd8d20ff4 100644
--- a/spec/ruby/optional/capi/ext/kernel_spec.c
+++ b/spec/ruby/optional/capi/ext/kernel_spec.c
@@ -67,11 +67,20 @@ VALUE kernel_spec_rb_block_call_no_func(VALUE self, VALUE ary) {
return rb_block_call(ary, rb_intern("map"), 0, NULL, (rb_block_call_func_t)NULL, Qnil);
}
-
VALUE kernel_spec_rb_frame_this_func(VALUE self) {
return ID2SYM(rb_frame_this_func());
}
+VALUE kernel_spec_rb_category_warn_deprecated(VALUE self) {
+ rb_category_warn(RB_WARN_CATEGORY_DEPRECATED, "foo");
+ return Qnil;
+}
+
+VALUE kernel_spec_rb_category_warn_deprecated_with_integer_extra_value(VALUE self, VALUE value) {
+ rb_category_warn(RB_WARN_CATEGORY_DEPRECATED, "foo %d", FIX2INT(value));
+ return Qnil;
+}
+
VALUE kernel_spec_rb_ensure(VALUE self, VALUE main_proc, VALUE arg,
VALUE ensure_proc, VALUE arg2) {
VALUE main_array, ensure_array;
@@ -242,6 +251,13 @@ VALUE kernel_spec_rb_syserr_fail(VALUE self, VALUE err, VALUE msg) {
return Qnil;
}
+VALUE kernel_spec_rb_syserr_fail_str(VALUE self, VALUE err, VALUE msg) {
+ if (self != Qundef) {
+ rb_syserr_fail_str(NUM2INT(err), msg);
+ }
+ return Qnil;
+}
+
VALUE kernel_spec_rb_warn(VALUE self, VALUE msg) {
rb_warn("%s", StringValuePtr(msg));
return Qnil;
@@ -323,6 +339,10 @@ static VALUE kernel_spec_rb_f_sprintf(VALUE self, VALUE ary) {
return rb_f_sprintf((int)RARRAY_LEN(ary), RARRAY_PTR(ary));
}
+static VALUE kernel_spec_rb_str_format(VALUE self, VALUE count, VALUE ary, VALUE format) {
+ return rb_str_format(FIX2INT(count), RARRAY_PTR(ary), format);
+}
+
static VALUE kernel_spec_rb_make_backtrace(VALUE self) {
return rb_make_backtrace();
}
@@ -381,6 +401,8 @@ void Init_kernel_spec(void) {
rb_define_method(cls, "rb_block_lambda", kernel_spec_rb_block_lambda, 0);
rb_define_method(cls, "rb_frame_this_func_test", kernel_spec_rb_frame_this_func, 0);
rb_define_method(cls, "rb_frame_this_func_test_again", kernel_spec_rb_frame_this_func, 0);
+ rb_define_method(cls, "rb_category_warn_deprecated", kernel_spec_rb_category_warn_deprecated, 0);
+ rb_define_method(cls, "rb_category_warn_deprecated_with_integer_extra_value", kernel_spec_rb_category_warn_deprecated_with_integer_extra_value, 1);
rb_define_method(cls, "rb_ensure", kernel_spec_rb_ensure, 4);
rb_define_method(cls, "rb_eval_string", kernel_spec_rb_eval_string, 1);
rb_define_method(cls, "rb_eval_cmd_kw", kernel_spec_rb_eval_cmd_kw, 3);
@@ -400,6 +422,7 @@ void Init_kernel_spec(void) {
rb_define_method(cls, "rb_catch_obj", kernel_spec_rb_catch_obj, 2);
rb_define_method(cls, "rb_sys_fail", kernel_spec_rb_sys_fail, 1);
rb_define_method(cls, "rb_syserr_fail", kernel_spec_rb_syserr_fail, 2);
+ rb_define_method(cls, "rb_syserr_fail_str", kernel_spec_rb_syserr_fail_str, 2);
rb_define_method(cls, "rb_warn", kernel_spec_rb_warn, 1);
rb_define_method(cls, "rb_yield", kernel_spec_rb_yield, 1);
rb_define_method(cls, "rb_yield_indirected", kernel_spec_rb_yield_indirected, 1);
@@ -410,6 +433,7 @@ void Init_kernel_spec(void) {
rb_define_method(cls, "rb_exec_recursive", kernel_spec_rb_exec_recursive, 1);
rb_define_method(cls, "rb_set_end_proc", kernel_spec_rb_set_end_proc, 1);
rb_define_method(cls, "rb_f_sprintf", kernel_spec_rb_f_sprintf, 1);
+ rb_define_method(cls, "rb_str_format", kernel_spec_rb_str_format, 3);
rb_define_method(cls, "rb_make_backtrace", kernel_spec_rb_make_backtrace, 0);
rb_define_method(cls, "rb_funcallv", kernel_spec_rb_funcallv, 3);
#ifdef RUBY_VERSION_IS_3_0
diff --git a/spec/ruby/optional/capi/ext/string_spec.c b/spec/ruby/optional/capi/ext/string_spec.c
index 94f412267f..a140c86347 100644
--- a/spec/ruby/optional/capi/ext/string_spec.c
+++ b/spec/ruby/optional/capi/ext/string_spec.c
@@ -581,6 +581,11 @@ static VALUE string_spec_rb_enc_interned_str_cstr(VALUE self, VALUE str, VALUE e
return rb_enc_interned_str_cstr(RSTRING_PTR(str), e);
}
+static VALUE string_spec_rb_enc_interned_str(VALUE self, VALUE str, VALUE len, VALUE enc) {
+ rb_encoding *e = NIL_P(enc) ? 0 : rb_to_encoding(enc);
+ return rb_enc_interned_str(RSTRING_PTR(str), FIX2LONG(len), e);
+}
+
static VALUE string_spec_rb_str_to_interned_str(VALUE self, VALUE str) {
return rb_str_to_interned_str(str);
}
@@ -687,6 +692,7 @@ void Init_string_spec(void) {
rb_define_method(cls, "rb_str_locktmp", string_spec_rb_str_locktmp, 1);
rb_define_method(cls, "rb_str_unlocktmp", string_spec_rb_str_unlocktmp, 1);
rb_define_method(cls, "rb_enc_interned_str_cstr", string_spec_rb_enc_interned_str_cstr, 2);
+ rb_define_method(cls, "rb_enc_interned_str", string_spec_rb_enc_interned_str, 3);
rb_define_method(cls, "rb_str_to_interned_str", string_spec_rb_str_to_interned_str, 1);
}
diff --git a/spec/ruby/optional/capi/hash_spec.rb b/spec/ruby/optional/capi/hash_spec.rb
index a0e49ffc4c..08e03fcb26 100644
--- a/spec/ruby/optional/capi/hash_spec.rb
+++ b/spec/ruby/optional/capi/hash_spec.rb
@@ -194,6 +194,61 @@ describe "C-API Hash function" do
end
end
+ describe "rb_hash_bulk_insert" do
+ it 'inserts key-value pairs into the hash' do
+ arr = [:a, 1, :b, 2, :c, 3]
+ hash = {}
+
+ @s.rb_hash_bulk_insert(arr.length, arr, hash)
+
+ hash.should == {a: 1, b: 2, c: 3}
+ end
+
+ it 'overwrites existing keys' do
+ arr = [:a, 4, :b, 5, :c, 6]
+ hash = {a: 1, b: 2}
+
+ @s.rb_hash_bulk_insert(arr.length, arr, hash)
+
+ hash.should == {a: 4, b: 5, c: 6}
+ end
+
+ it 'uses the last key in the array if it appears multiple times' do
+ arr = [:a, 1, :b, 2, :a, 3]
+ hash = {}
+
+ @s.rb_hash_bulk_insert(arr.length, arr, hash)
+
+ hash.should == {a: 3, b: 2}
+ end
+
+ it 'allows the array to be NULL if the length is zero' do
+ hash = {}
+
+ @s.rb_hash_bulk_insert(0, nil, hash)
+
+ hash.should == {}
+ end
+
+ it 'does not include any keys after the given length' do
+ arr = [:a, 1, :b, 2, :c, 3, :d, 4]
+ hash = {}
+
+ @s.rb_hash_bulk_insert(arr.length - 2, arr, hash)
+
+ hash.should == {a: 1, b: 2, c: 3}
+ end
+
+ it 'does not modify the hash if the length is zero' do
+ arr = []
+ hash = {a: 1, b: 2}
+
+ @s.rb_hash_bulk_insert(arr.length, arr, hash)
+
+ hash.should == {a: 1, b: 2}
+ end
+ end
+
describe "rb_hash_size" do
it "returns the size of the hash" do
hsh = {fast: 'car', good: 'music'}
diff --git a/spec/ruby/optional/capi/io_spec.rb b/spec/ruby/optional/capi/io_spec.rb
index 01588408e1..dbfaf556f6 100644
--- a/spec/ruby/optional/capi/io_spec.rb
+++ b/spec/ruby/optional/capi/io_spec.rb
@@ -516,6 +516,152 @@ describe "C-API IO function" do
@o.rb_io_path(@rw_io).should == @name
end
end
+
+ describe "rb_io_closed_p" do
+ it "returns false when io is not closed" do
+ @o.rb_io_closed_p(@r_io).should == false
+ @r_io.closed?.should == false
+ end
+
+ it "returns true when io is closed" do
+ @r_io.close
+
+ @o.rb_io_closed_p(@r_io).should == true
+ @r_io.closed?.should == true
+ end
+ end
+
+ quarantine! do # "Errno::EBADF: Bad file descriptor" at closing @r_io, @rw_io etc in the after :each hook
+ describe "rb_io_open_descriptor" do
+ it "creates a new IO instance" do
+ io = @o.rb_io_open_descriptor(File, @r_io.fileno, 0, "a.txt", 60, "US-ASCII", "UTF-8", 0, {})
+ io.should.is_a?(IO)
+ end
+
+ it "return an instance of the specified class" do
+ io = @o.rb_io_open_descriptor(File, @r_io.fileno, 0, "a.txt", 60, "US-ASCII", "UTF-8", 0, {})
+ io.class.should == File
+
+ io = @o.rb_io_open_descriptor(IO, @r_io.fileno, 0, "a.txt", 60, "US-ASCII", "UTF-8", 0, {})
+ io.class.should == IO
+ end
+
+ it "sets the specified file descriptor" do
+ io = @o.rb_io_open_descriptor(File, @r_io.fileno, 0, "a.txt", 60, "US-ASCII", "UTF-8", 0, {})
+ io.fileno.should == @r_io.fileno
+ end
+
+ it "sets the specified path" do
+ io = @o.rb_io_open_descriptor(File, @r_io.fileno, 0, "a.txt", 60, "US-ASCII", "UTF-8", 0, {})
+ io.path.should == "a.txt"
+ end
+
+ it "sets the specified mode" do
+ io = @o.rb_io_open_descriptor(File, @r_io.fileno, CApiIOSpecs::FMODE_BINMODE, "a.txt", 60, "US-ASCII", "UTF-8", 0, {})
+ io.should.binmode?
+
+ io = @o.rb_io_open_descriptor(File, @r_io.fileno, CApiIOSpecs::FMODE_TEXTMODE, "a.txt", 60, "US-ASCII", "UTF-8", 0, {})
+ io.should_not.binmode?
+ end
+
+ it "sets the specified timeout" do
+ io = @o.rb_io_open_descriptor(File, @r_io.fileno, 0, "a.txt", 60, "US-ASCII", "UTF-8", 0, {})
+ io.timeout.should == 60
+ end
+
+ it "sets the specified internal encoding" do
+ io = @o.rb_io_open_descriptor(File, @r_io.fileno, 0, "a.txt", 60, "US-ASCII", "UTF-8", 0, {})
+ io.internal_encoding.should == Encoding::US_ASCII
+ end
+
+ it "sets the specified external encoding" do
+ io = @o.rb_io_open_descriptor(File, @r_io.fileno, 0, "a.txt", 60, "US-ASCII", "UTF-8", 0, {})
+ io.external_encoding.should == Encoding::UTF_8
+ end
+
+ it "does not apply the specified encoding flags" do
+ name = tmp("rb_io_open_descriptor_specs")
+ File.write(name, "123\r\n456\n89")
+ file = File.open(name, "r")
+
+ io = @o.rb_io_open_descriptor(File, file.fileno, CApiIOSpecs::FMODE_READABLE, "a.txt", 60, "US-ASCII", "UTF-8", CApiIOSpecs::ECONV_UNIVERSAL_NEWLINE_DECORATOR, {})
+ io.read_nonblock(20).should == "123\r\n456\n89"
+ ensure
+ file.close
+ rm_r name
+ end
+
+ it "ignores the IO open options" do
+ io = @o.rb_io_open_descriptor(File, @r_io.fileno, 0, "a.txt", 60, "US-ASCII", "UTF-8", 0, {external_encoding: "windows-1251"})
+ io.external_encoding.should == Encoding::UTF_8
+
+ io = @o.rb_io_open_descriptor(File, @r_io.fileno, 0, "a.txt", 60, "US-ASCII", "UTF-8", 0, {internal_encoding: "windows-1251"})
+ io.internal_encoding.should == Encoding::US_ASCII
+
+ io = @o.rb_io_open_descriptor(File, @r_io.fileno, 0, "a.txt", 60, "US-ASCII", "UTF-8", 0, {encoding: "windows-1251:binary"})
+ io.external_encoding.should == Encoding::UTF_8
+ io.internal_encoding.should == Encoding::US_ASCII
+
+ io = @o.rb_io_open_descriptor(File, @r_io.fileno, 0, "a.txt", 60, "US-ASCII", "UTF-8", 0, {textmode: false})
+ io.should_not.binmode?
+
+ io = @o.rb_io_open_descriptor(File, @r_io.fileno, 0, "a.txt", 60, "US-ASCII", "UTF-8", 0, {binmode: true})
+ io.should_not.binmode?
+
+ io = @o.rb_io_open_descriptor(File, @r_io.fileno, 0, "a.txt", 60, "US-ASCII", "UTF-8", 0, {autoclose: false})
+ io.should.autoclose?
+
+ io = @o.rb_io_open_descriptor(File, @r_io.fileno, 0, "a.txt", 60, "US-ASCII", "UTF-8", 0, {path: "a.txt"})
+ io.path.should == "a.txt"
+ end
+
+ it "ignores the IO encoding options" do
+ io = @o.rb_io_open_descriptor(File, @w_io.fileno, CApiIOSpecs::FMODE_WRITABLE, "a.txt", 60, "US-ASCII", "UTF-8", 0, {crlf_newline: true})
+
+ io.write("123\r\n456\n89")
+ io.flush
+
+ @r_io.read_nonblock(20).should == "123\r\n456\n89"
+ end
+
+ it "allows wrong mode" do
+ io = @o.rb_io_open_descriptor(File, @w_io.fileno, CApiIOSpecs::FMODE_READABLE, "a.txt", 60, "US-ASCII", "UTF-8", 0, {})
+ io.should.is_a?(File)
+
+ platform_is_not :windows do
+ -> { io.read_nonblock(1) }.should raise_error(Errno::EBADF)
+ end
+
+ platform_is :windows do
+ -> { io.read_nonblock(1) }.should raise_error(IO::EWOULDBLOCKWaitReadable)
+ end
+ end
+
+ it "tolerates NULL as rb_io_encoding *encoding parameter" do
+ io = @o.rb_io_open_descriptor_without_encoding(File, @r_io.fileno, 0, "a.txt", 60)
+ io.should.is_a?(File)
+ end
+
+ it "deduplicates path String" do
+ path = "a.txt".dup
+ io = @o.rb_io_open_descriptor(File, @r_io.fileno, 0, path, 60, "US-ASCII", "UTF-8", 0, {})
+ io.path.should_not equal(path)
+
+ path = "a.txt".freeze
+ io = @o.rb_io_open_descriptor(File, @r_io.fileno, 0, path, 60, "US-ASCII", "UTF-8", 0, {})
+ io.path.should_not equal(path)
+ end
+
+ it "calls #to_str to convert a path to a String" do
+ path = Object.new
+ def path.to_str; "a.txt"; end
+
+ io = @o.rb_io_open_descriptor(File, @r_io.fileno, 0, path, 60, "US-ASCII", "UTF-8", 0, {})
+
+ io.path.should == "a.txt"
+ end
+ end
+ end
end
ruby_version_is "3.4" do
diff --git a/spec/ruby/optional/capi/kernel_spec.rb b/spec/ruby/optional/capi/kernel_spec.rb
index a169813cd5..c90e50f1db 100644
--- a/spec/ruby/optional/capi/kernel_spec.rb
+++ b/spec/ruby/optional/capi/kernel_spec.rb
@@ -156,26 +156,16 @@ describe "C-API Kernel function" do
end
describe "rb_warn" do
- before :each do
- @stderr, $stderr = $stderr, IOStub.new
- @verbose = $VERBOSE
- end
-
- after :each do
- $stderr = @stderr
- $VERBOSE = @verbose
- end
-
it "prints a message to $stderr if $VERBOSE evaluates to true" do
- $VERBOSE = true
- @s.rb_warn("This is a warning")
- $stderr.should =~ /This is a warning/
+ -> {
+ @s.rb_warn("This is a warning")
+ }.should complain(/warning: This is a warning/, verbose: true)
end
it "prints a message to $stderr if $VERBOSE evaluates to false" do
- $VERBOSE = false
- @s.rb_warn("This is a warning")
- $stderr.should =~ /This is a warning/
+ -> {
+ @s.rb_warn("This is a warning")
+ }.should complain(/warning: This is a warning/, verbose: false)
end
end
@@ -197,13 +187,47 @@ describe "C-API Kernel function" do
it "raises an exception from the given error" do
-> do
@s.rb_syserr_fail(Errno::EINVAL::Errno, "additional info")
- end.should raise_error(Errno::EINVAL, /additional info/)
+ end.should raise_error(Errno::EINVAL, "Invalid argument - additional info")
end
it "can take a NULL message" do
-> do
@s.rb_syserr_fail(Errno::EINVAL::Errno, nil)
- end.should raise_error(Errno::EINVAL)
+ end.should raise_error(Errno::EINVAL, "Invalid argument")
+ end
+
+ it "uses an 'unknown error' message when errno is unknown" do
+ platform_is_not :windows do
+ -> { @s.rb_syserr_fail(-10, nil) }.should raise_error(SystemCallError, /Unknown error(:)? -10/)
+ end
+
+ platform_is :windows do
+ -> { @s.rb_syserr_fail(-1, nil) }.should raise_error(SystemCallError, "The operation completed successfully.")
+ end
+ end
+ end
+
+ describe "rb_syserr_fail_str" do
+ it "raises an exception from the given error" do
+ -> do
+ @s.rb_syserr_fail_str(Errno::EINVAL::Errno, "additional info")
+ end.should raise_error(Errno::EINVAL, "Invalid argument - additional info")
+ end
+
+ it "can take nil as a message" do
+ -> do
+ @s.rb_syserr_fail_str(Errno::EINVAL::Errno, nil)
+ end.should raise_error(Errno::EINVAL, "Invalid argument")
+ end
+
+ it "uses an 'unknown error' message when errno is unknown" do
+ platform_is_not :windows do
+ -> { @s.rb_syserr_fail_str(-10, nil) }.should raise_error(SystemCallError, /Unknown error(:)? -10/)
+ end
+
+ platform_is :windows do
+ -> { @s.rb_syserr_fail_str(-1, nil) }.should raise_error(SystemCallError, "The operation completed successfully.")
+ end
end
end
@@ -530,6 +554,40 @@ describe "C-API Kernel function" do
end
end
+ describe "rb_category_warn" do
+ it "emits a warning into stderr" do
+ Warning[:deprecated] = true
+
+ -> {
+ @s.rb_category_warn_deprecated
+ }.should complain(/warning: foo/, verbose: true)
+ end
+
+ it "supports printf format modifiers" do
+ Warning[:deprecated] = true
+
+ -> {
+ @s.rb_category_warn_deprecated_with_integer_extra_value(42)
+ }.should complain(/warning: foo 42/, verbose: true)
+ end
+
+ it "does not emits a warning when a category is disabled" do
+ Warning[:deprecated] = false
+
+ -> {
+ @s.rb_category_warn_deprecated
+ }.should_not complain(verbose: true)
+ end
+
+ it "does not emits a warning when $VERBOSE is nil" do
+ Warning[:deprecated] = true
+
+ -> {
+ @s.rb_category_warn_deprecated
+ }.should_not complain(verbose: nil)
+ end
+ end
+
describe "rb_ensure" do
it "executes passed function and returns its value" do
proc = -> x { x }
@@ -868,4 +926,10 @@ describe "C-API Kernel function" do
@s.rb_check_funcall(object, :protected_method, []).should == :protected
end
end
+
+ describe "rb_str_format" do
+ it "returns a string according to format and arguments" do
+ @s.rb_str_format(3, [10, 2.5, "test"], "%d %f %s").should == "10 2.500000 test"
+ end
+ end
end
diff --git a/spec/ruby/optional/capi/string_spec.rb b/spec/ruby/optional/capi/string_spec.rb
index 8f2244bcea..801d50f117 100644
--- a/spec/ruby/optional/capi/string_spec.rb
+++ b/spec/ruby/optional/capi/string_spec.rb
@@ -1265,6 +1265,51 @@ end
end
end
+ describe "rb_enc_interned_str" do
+ it "returns a frozen string" do
+ str = "hello"
+ val = @s.rb_enc_interned_str(str, str.bytesize, Encoding::US_ASCII)
+
+ val.should.is_a?(String)
+ val.encoding.should == Encoding::US_ASCII
+ val.should.frozen?
+ end
+
+ it "returns the same frozen string" do
+ str = "hello"
+ result1 = @s.rb_enc_interned_str(str, str.bytesize, Encoding::US_ASCII)
+ result2 = @s.rb_enc_interned_str(str, str.bytesize, Encoding::US_ASCII)
+ result1.should.equal?(result2)
+ end
+
+ it "returns different frozen strings for different encodings" do
+ str = "hello"
+ result1 = @s.rb_enc_interned_str(str, str.bytesize, Encoding::US_ASCII)
+ result2 = @s.rb_enc_interned_str(str, str.bytesize, Encoding::UTF_8)
+ result1.should_not.equal?(result2)
+ end
+
+ it 'returns the same string when using non-ascii characters' do
+ str = 'こんにちは'
+ result1 = @s.rb_enc_interned_str(str, str.bytesize, Encoding::UTF_8)
+ result2 = @s.rb_enc_interned_str(str, str.bytesize, Encoding::UTF_8)
+ result1.should.equal?(result2)
+ end
+
+ it "returns the same string as String#-@" do
+ str = "hello"
+ @s.rb_enc_interned_str(str, str.bytesize, Encoding::UTF_8).should.equal?(-str)
+ end
+
+ ruby_bug "#20322", ""..."3.4" do
+ it "uses the default encoding if encoding is null" do
+ str = "hello"
+ val = @s.rb_enc_interned_str(str, str.bytesize, nil)
+ val.encoding.should == Encoding::ASCII_8BIT
+ end
+ end
+ end
+
describe "rb_str_to_interned_str" do
it "returns a frozen string" do
str = "hello"
diff --git a/spec/ruby/shared/process/fork.rb b/spec/ruby/shared/process/fork.rb
index 11e18d7b1c..8dbb3d0da4 100644
--- a/spec/ruby/shared/process/fork.rb
+++ b/spec/ruby/shared/process/fork.rb
@@ -23,31 +23,31 @@ describe :process_fork, shared: true do
end
it "returns status zero" do
- pid = Process.fork { exit! 0 }
+ pid = @object.fork { exit! 0 }
_, result = Process.wait2(pid)
result.exitstatus.should == 0
end
it "returns status zero" do
- pid = Process.fork { exit 0 }
+ pid = @object.fork { exit 0 }
_, result = Process.wait2(pid)
result.exitstatus.should == 0
end
it "returns status zero" do
- pid = Process.fork {}
+ pid = @object.fork {}
_, result = Process.wait2(pid)
result.exitstatus.should == 0
end
it "returns status non-zero" do
- pid = Process.fork { exit! 42 }
+ pid = @object.fork { exit! 42 }
_, result = Process.wait2(pid)
result.exitstatus.should == 42
end
it "returns status non-zero" do
- pid = Process.fork { exit 42 }
+ pid = @object.fork { exit 42 }
_, result = Process.wait2(pid)
result.exitstatus.should == 42
end
diff --git a/spec/ruby/shared/string/end_with.rb b/spec/ruby/shared/string/end_with.rb
index 94a7f97513..08f43c1bce 100644
--- a/spec/ruby/shared/string/end_with.rb
+++ b/spec/ruby/shared/string/end_with.rb
@@ -55,7 +55,7 @@ describe :end_with, shared: true do
it "checks that we are starting to match at the head of a character" do
"\xC3\xA9".send(@method).should_not.end_with?("\xA9")
"\xe3\x81\x82".send(@method).should_not.end_with?("\x82")
- "ab".dup.force_encoding("UTF-16BE").send(@method).should_not.end_with?(
- "b".dup.force_encoding("UTF-16BE"))
+ "\xd8\x00\xdc\x00".dup.force_encoding("UTF-16BE").send(@method).should_not.end_with?(
+ "\xdc\x00".dup.force_encoding("UTF-16BE"))
end
end