summaryrefslogtreecommitdiff
path: root/spec/ruby/library
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library')
-rw-r--r--spec/ruby/library/bigdecimal/fix_spec.rb28
-rw-r--r--spec/ruby/library/date/mon_spec.rb3
-rw-r--r--spec/ruby/library/date/month_spec.rb6
-rw-r--r--spec/ruby/library/date/shared/month.rb6
-rw-r--r--spec/ruby/library/erb/new_spec.rb2
-rw-r--r--spec/ruby/library/logger/logger/new_spec.rb26
-rw-r--r--spec/ruby/library/pathname/glob_spec.rb8
-rw-r--r--spec/ruby/library/rbconfig/rbconfig_spec.rb7
-rw-r--r--spec/ruby/library/set/hash_spec.rb5
-rw-r--r--spec/ruby/library/set/merge_spec.rb12
-rw-r--r--spec/ruby/library/socket/addrinfo/initialize_spec.rb2
-rw-r--r--spec/ruby/library/socket/basicsocket/send_spec.rb38
-rw-r--r--spec/ruby/library/stringio/fixtures/classes.rb4
-rw-r--r--spec/ruby/library/stringio/set_encoding_by_bom_spec.rb237
-rw-r--r--spec/ruby/library/stringio/shared/sysread.rb2
-rw-r--r--spec/ruby/library/stringio/sysread_spec.rb5
-rw-r--r--spec/ruby/library/time/shared/rfc2822.rb24
-rw-r--r--spec/ruby/library/time/shared/xmlschema.rb50
18 files changed, 372 insertions, 93 deletions
diff --git a/spec/ruby/library/bigdecimal/fix_spec.rb b/spec/ruby/library/bigdecimal/fix_spec.rb
index 231c9a587e..2c6276899e 100644
--- a/spec/ruby/library/bigdecimal/fix_spec.rb
+++ b/spec/ruby/library/bigdecimal/fix_spec.rb
@@ -2,20 +2,20 @@ require_relative '../../spec_helper'
require 'bigdecimal'
describe "BigDecimal#fix" do
- before :each do
- @zero = BigDecimal("0")
- @mixed = BigDecimal("1.23456789")
- @pos_int = BigDecimal("2E5555")
- @neg_int = BigDecimal("-2E5555")
- @pos_frac = BigDecimal("2E-9999")
- @neg_frac = BigDecimal("-2E-9999")
-
- @infinity = BigDecimal("Infinity")
- @infinity_neg = BigDecimal("-Infinity")
- @nan = BigDecimal("NaN")
- @zero_pos = BigDecimal("+0")
- @zero_neg = BigDecimal("-0")
- end
+ before :each do
+ @zero = BigDecimal("0")
+ @mixed = BigDecimal("1.23456789")
+ @pos_int = BigDecimal("2E5555")
+ @neg_int = BigDecimal("-2E5555")
+ @pos_frac = BigDecimal("2E-9999")
+ @neg_frac = BigDecimal("-2E-9999")
+
+ @infinity = BigDecimal("Infinity")
+ @infinity_neg = BigDecimal("-Infinity")
+ @nan = BigDecimal("NaN")
+ @zero_pos = BigDecimal("+0")
+ @zero_neg = BigDecimal("-0")
+ end
it "returns a BigDecimal" do
BigDecimal("2E100000000").fix.kind_of?(BigDecimal).should == true
diff --git a/spec/ruby/library/date/mon_spec.rb b/spec/ruby/library/date/mon_spec.rb
index 724e7d6564..616d72cf88 100644
--- a/spec/ruby/library/date/mon_spec.rb
+++ b/spec/ruby/library/date/mon_spec.rb
@@ -1,6 +1,7 @@
require_relative '../../spec_helper'
+require_relative 'shared/month'
require 'date'
describe "Date#mon" do
- it "needs to be reviewed for spec completeness"
+ it_behaves_like :date_month, :mon
end
diff --git a/spec/ruby/library/date/month_spec.rb b/spec/ruby/library/date/month_spec.rb
index e040f9a94c..f493ec8119 100644
--- a/spec/ruby/library/date/month_spec.rb
+++ b/spec/ruby/library/date/month_spec.rb
@@ -1,9 +1,7 @@
require_relative '../../spec_helper'
+require_relative 'shared/month'
require 'date'
describe "Date#month" do
- it "returns the month" do
- m = Date.new(2000, 7, 1).month
- m.should == 7
- end
+ it_behaves_like :date_month, :month
end
diff --git a/spec/ruby/library/date/shared/month.rb b/spec/ruby/library/date/shared/month.rb
new file mode 100644
index 0000000000..5fcb2cbeb0
--- /dev/null
+++ b/spec/ruby/library/date/shared/month.rb
@@ -0,0 +1,6 @@
+describe :date_month, shared: true do
+ it "returns the month" do
+ m = Date.new(2000, 7, 1).send(@method)
+ m.should == 7
+ end
+end
diff --git a/spec/ruby/library/erb/new_spec.rb b/spec/ruby/library/erb/new_spec.rb
index a5aeeaeed1..f721529ab0 100644
--- a/spec/ruby/library/erb/new_spec.rb
+++ b/spec/ruby/library/erb/new_spec.rb
@@ -130,7 +130,7 @@ END
<b><%#= item %></b>
<%# end %>
END
- ERBSpecs.new_erb(input).result.should == "\n<b></b>\n\n"
+ ERBSpecs.new_erb(input).result.should == "\n<b></b>\n\n"
ERBSpecs.new_erb(input, trim_mode: '<>').result.should == "<b></b>\n"
end
diff --git a/spec/ruby/library/logger/logger/new_spec.rb b/spec/ruby/library/logger/logger/new_spec.rb
index d3100ee2d1..6dcb030ae1 100644
--- a/spec/ruby/library/logger/logger/new_spec.rb
+++ b/spec/ruby/library/logger/logger/new_spec.rb
@@ -13,19 +13,19 @@ describe "Logger#new" do
rm_r @file_path
end
- it "creates a new logger object" do
- l = Logger.new(STDERR)
- -> { l.add(Logger::WARN, "Foo") }.should output_to_fd(/Foo/, STDERR)
- end
-
- it "receives a logging device as first argument" do
- l = Logger.new(@log_file)
- l.add(Logger::WARN, "Test message")
-
- @log_file.rewind
- LoggerSpecs.strip_date(@log_file.readline).should == "WARN -- : Test message\n"
- l.close
- end
+ it "creates a new logger object" do
+ l = Logger.new(STDERR)
+ -> { l.add(Logger::WARN, "Foo") }.should output_to_fd(/Foo/, STDERR)
+ end
+
+ it "receives a logging device as first argument" do
+ l = Logger.new(@log_file)
+ l.add(Logger::WARN, "Test message")
+
+ @log_file.rewind
+ LoggerSpecs.strip_date(@log_file.readline).should == "WARN -- : Test message\n"
+ l.close
+ end
it "receives a frequency rotation as second argument" do
-> { Logger.new(@log_file, "daily") }.should_not raise_error
diff --git a/spec/ruby/library/pathname/glob_spec.rb b/spec/ruby/library/pathname/glob_spec.rb
index ced810fa90..de322bab47 100644
--- a/spec/ruby/library/pathname/glob_spec.rb
+++ b/spec/ruby/library/pathname/glob_spec.rb
@@ -21,6 +21,10 @@ describe 'Pathname.glob' do
Pathname.glob(@dir + 'lib/*.js').should == []
end
+ it 'returns [] when the pathname does not exist' do
+ Pathname.glob('i_dont_exist/lib/*.js').should == []
+ end
+
it 'returns matching file paths' do
Pathname.glob(@dir + 'lib/*i*.rb').sort.should == [Pathname.new(@file_1), Pathname.new(@file_2)].sort
end
@@ -67,6 +71,10 @@ describe 'Pathname#glob' do
Pathname.new(@dir).glob('lib/*.js').should == []
end
+ it 'returns [] when the pathname does not exist' do
+ Pathname.new('./i_dont_exist').glob('lib/*.js').should == []
+ end
+
it 'returns matching file paths' do
Pathname.new(@dir).glob('lib/*i*.rb').sort.should == [Pathname.new(@file_1), Pathname.new(@file_2)].sort
end
diff --git a/spec/ruby/library/rbconfig/rbconfig_spec.rb b/spec/ruby/library/rbconfig/rbconfig_spec.rb
index 3e06219621..b9a4588bf0 100644
--- a/spec/ruby/library/rbconfig/rbconfig_spec.rb
+++ b/spec/ruby/library/rbconfig/rbconfig_spec.rb
@@ -9,6 +9,13 @@ describe 'RbConfig::CONFIG' do
end
end
+ it 'has MAJOR, MINOR, TEENY, and PATCHLEVEL matching RUBY_VERSION and RUBY_PATCHLEVEL' do
+ major, minor, teeny = RUBY_VERSION.split('.')
+ RbConfig::CONFIG.values_at("MAJOR", "MINOR", "TEENY", "PATCHLEVEL").should == [
+ major, minor, teeny, RUBY_PATCHLEVEL.to_s
+ ]
+ end
+
# These directories have no meanings before the installation.
guard -> { RbConfig::TOPDIR } do
it "['rubylibdir'] returns the directory containing Ruby standard libraries" do
diff --git a/spec/ruby/library/set/hash_spec.rb b/spec/ruby/library/set/hash_spec.rb
index 47c43c05f1..c5bab73931 100644
--- a/spec/ruby/library/set/hash_spec.rb
+++ b/spec/ruby/library/set/hash_spec.rb
@@ -10,4 +10,9 @@ describe "Set#hash" do
Set[].hash.should_not == Set[1, 2, 3].hash
Set[1, 2, 3].hash.should_not == Set[:a, "b", ?c].hash
end
+
+ # see https://github.com/jruby/jruby/issues/8393
+ it "is equal to nil.hash for an uninitialized Set" do
+ Set.allocate.hash.should == nil.hash
+ end
end
diff --git a/spec/ruby/library/set/merge_spec.rb b/spec/ruby/library/set/merge_spec.rb
index a8e3ffc870..3ae0da827c 100644
--- a/spec/ruby/library/set/merge_spec.rb
+++ b/spec/ruby/library/set/merge_spec.rb
@@ -16,4 +16,16 @@ describe "Set#merge" do
-> { Set[1, 2].merge(1) }.should raise_error(ArgumentError)
-> { Set[1, 2].merge(Object.new) }.should raise_error(ArgumentError)
end
+
+ ruby_version_is ""..."3.3" do
+ it "accepts only a single argument" do
+ -> { Set[].merge([], []) }.should raise_error(ArgumentError, "wrong number of arguments (given 2, expected 1)")
+ end
+ end
+
+ ruby_version_is "3.3" do
+ it "accepts multiple arguments" do
+ Set[:a, :b].merge(Set[:b, :c], [:d]).should == Set[:a, :b, :c, :d]
+ end
+ end
end
diff --git a/spec/ruby/library/socket/addrinfo/initialize_spec.rb b/spec/ruby/library/socket/addrinfo/initialize_spec.rb
index 83b204b575..d8885c5d62 100644
--- a/spec/ruby/library/socket/addrinfo/initialize_spec.rb
+++ b/spec/ruby/library/socket/addrinfo/initialize_spec.rb
@@ -335,7 +335,7 @@ describe "Addrinfo#initialize" do
@sockaddr = ['AF_INET6', 80, 'hostname', '127.0.0.1']
end
- it "raises SocketError when using any Socket constant except except AF_INET(6)/PF_INET(6)" do
+ it "raises SocketError when using any Socket constant except AF_INET(6)/PF_INET(6)" do
Socket.constants.grep(/(^AF_|^PF_)(?!INET)/).each do |constant|
value = Socket.const_get(constant)
-> {
diff --git a/spec/ruby/library/socket/basicsocket/send_spec.rb b/spec/ruby/library/socket/basicsocket/send_spec.rb
index 86b5567026..1c028480e3 100644
--- a/spec/ruby/library/socket/basicsocket/send_spec.rb
+++ b/spec/ruby/library/socket/basicsocket/send_spec.rb
@@ -16,27 +16,27 @@ describe "BasicSocket#send" do
@socket.close
end
- it "sends a message to another socket and returns the number of bytes sent" do
- data = +""
- t = Thread.new do
- client = @server.accept
- loop do
- got = client.recv(5)
- break if got.nil? || got.empty?
- data << got
- end
- client.close
- end
- Thread.pass while t.status and t.status != "sleep"
- t.status.should_not be_nil
+ it "sends a message to another socket and returns the number of bytes sent" do
+ data = +""
+ t = Thread.new do
+ client = @server.accept
+ loop do
+ got = client.recv(5)
+ break if got.nil? || got.empty?
+ data << got
+ end
+ client.close
+ end
+ Thread.pass while t.status and t.status != "sleep"
+ t.status.should_not be_nil
- @socket.send('hello', 0).should == 5
- @socket.shutdown(1) # indicate, that we are done sending
- @socket.recv(10)
+ @socket.send('hello', 0).should == 5
+ @socket.shutdown(1) # indicate, that we are done sending
+ @socket.recv(10)
- t.join
- data.should == 'hello'
- end
+ t.join
+ data.should == 'hello'
+ end
platform_is_not :solaris, :windows do
it "accepts flags to specify unusual sending behaviour" do
diff --git a/spec/ruby/library/stringio/fixtures/classes.rb b/spec/ruby/library/stringio/fixtures/classes.rb
index bb8dc354cc..832c5457d7 100644
--- a/spec/ruby/library/stringio/fixtures/classes.rb
+++ b/spec/ruby/library/stringio/fixtures/classes.rb
@@ -4,12 +4,12 @@ class StringSubclass < String; end
module StringIOSpecs
def self.build
- str = <<-EOS
+ str = <<-EOS
each
peach
pear
plum
- EOS
+ EOS
StringIO.new(str)
end
end
diff --git a/spec/ruby/library/stringio/set_encoding_by_bom_spec.rb b/spec/ruby/library/stringio/set_encoding_by_bom_spec.rb
new file mode 100644
index 0000000000..1030aad042
--- /dev/null
+++ b/spec/ruby/library/stringio/set_encoding_by_bom_spec.rb
@@ -0,0 +1,237 @@
+require 'stringio'
+require_relative '../../spec_helper'
+
+# Should be synced with specs for IO#set_encoding_by_bom
+describe "StringIO#set_encoding_by_bom" do
+ it "returns nil if not readable" do
+ io = StringIO.new("".b, "wb")
+
+ io.set_encoding_by_bom.should be_nil
+ io.external_encoding.should == Encoding::ASCII_8BIT
+ end
+
+ it "returns the result encoding if found BOM UTF-8 sequence" do
+ io = StringIO.new("\u{FEFF}".b, "rb")
+
+ io.set_encoding_by_bom.should == Encoding::UTF_8
+ io.external_encoding.should == Encoding::UTF_8
+ io.read.b.should == "".b
+
+ io = StringIO.new("\u{FEFF}abc".b, "rb")
+
+ io.set_encoding_by_bom.should == Encoding::UTF_8
+ io.external_encoding.should == Encoding::UTF_8
+ io.read.b.should == "abc".b
+ end
+
+ it "returns the result encoding if found BOM UTF_16LE sequence" do
+ io = StringIO.new("\xFF\xFE".b, "rb")
+
+ io.set_encoding_by_bom.should == Encoding::UTF_16LE
+ io.external_encoding.should == Encoding::UTF_16LE
+ io.read.b.should == "".b
+
+ io = StringIO.new("\xFF\xFEabc".b, "rb")
+
+ io.set_encoding_by_bom.should == Encoding::UTF_16LE
+ io.external_encoding.should == Encoding::UTF_16LE
+ io.read.b.should == "abc".b
+ end
+
+ it "returns the result encoding if found BOM UTF_16BE sequence" do
+ io = StringIO.new("\xFE\xFF".b, "rb")
+
+ io.set_encoding_by_bom.should == Encoding::UTF_16BE
+ io.external_encoding.should == Encoding::UTF_16BE
+ io.read.b.should == "".b
+
+ io = StringIO.new("\xFE\xFFabc".b, "rb")
+
+ io.set_encoding_by_bom.should == Encoding::UTF_16BE
+ io.external_encoding.should == Encoding::UTF_16BE
+ io.read.b.should == "abc".b
+ end
+
+ it "returns the result encoding if found BOM UTF_32LE sequence" do
+ io = StringIO.new("\xFF\xFE\x00\x00".b, "rb")
+
+ io.set_encoding_by_bom.should == Encoding::UTF_32LE
+ io.external_encoding.should == Encoding::UTF_32LE
+ io.read.b.should == "".b
+
+ io = StringIO.new("\xFF\xFE\x00\x00abc".b, "rb")
+
+ io.set_encoding_by_bom.should == Encoding::UTF_32LE
+ io.external_encoding.should == Encoding::UTF_32LE
+ io.read.b.should == "abc".b
+ end
+
+ it "returns the result encoding if found BOM UTF_32BE sequence" do
+ io = StringIO.new("\x00\x00\xFE\xFF".b, "rb")
+
+ io.set_encoding_by_bom.should == Encoding::UTF_32BE
+ io.external_encoding.should == Encoding::UTF_32BE
+ io.read.b.should == "".b
+
+ io = StringIO.new("\x00\x00\xFE\xFFabc".b, "rb")
+
+ io.set_encoding_by_bom.should == Encoding::UTF_32BE
+ io.external_encoding.should == Encoding::UTF_32BE
+ io.read.b.should == "abc".b
+ end
+
+ it "returns nil if io is empty" do
+ io = StringIO.new("".b, "rb")
+ io.set_encoding_by_bom.should be_nil
+ io.external_encoding.should == Encoding::ASCII_8BIT
+ end
+
+ it "returns nil if UTF-8 BOM sequence is incomplete" do
+ io = StringIO.new("\xEF".b, "rb")
+
+ io.set_encoding_by_bom.should == nil
+ io.external_encoding.should == Encoding::ASCII_8BIT
+ io.read.b.should == "\xEF".b
+
+ io = StringIO.new("\xEFa".b, "rb")
+
+ io.set_encoding_by_bom.should == nil
+ io.external_encoding.should == Encoding::ASCII_8BIT
+ io.read.b.should == "\xEFa".b
+
+ io = StringIO.new("\xEF\xBB".b, "rb")
+
+ io.set_encoding_by_bom.should == nil
+ io.external_encoding.should == Encoding::ASCII_8BIT
+ io.read.b.should == "\xEF\xBB".b
+
+ io = StringIO.new("\xEF\xBBa".b, "rb")
+
+ io.set_encoding_by_bom.should == nil
+ io.external_encoding.should == Encoding::ASCII_8BIT
+ io.read.b.should == "\xEF\xBBa".b
+ end
+
+ it "returns nil if UTF-16BE BOM sequence is incomplete" do
+ io = StringIO.new("\xFE".b, "rb")
+
+ io.set_encoding_by_bom.should == nil
+ io.external_encoding.should == Encoding::ASCII_8BIT
+ io.read.b.should == "\xFE".b
+
+ io = StringIO.new("\xFEa".b, "rb")
+
+ io.set_encoding_by_bom.should == nil
+ io.external_encoding.should == Encoding::ASCII_8BIT
+ io.read.b.should == "\xFEa".b
+ end
+
+ it "returns nil if UTF-16LE/UTF-32LE BOM sequence is incomplete" do
+ io = StringIO.new("\xFF".b, "rb")
+
+ io.set_encoding_by_bom.should == nil
+ io.external_encoding.should == Encoding::ASCII_8BIT
+ io.read.b.should == "\xFF".b
+
+ io = StringIO.new("\xFFa".b, "rb")
+
+ io.set_encoding_by_bom.should == nil
+ io.external_encoding.should == Encoding::ASCII_8BIT
+ io.read.b.should == "\xFFa".b
+ end
+
+ it "returns UTF-16LE if UTF-32LE BOM sequence is incomplete" do
+ io = StringIO.new("\xFF\xFE".b, "rb")
+
+ io.set_encoding_by_bom.should == Encoding::UTF_16LE
+ io.external_encoding.should == Encoding::UTF_16LE
+ io.read.b.should == "".b
+
+ io = StringIO.new("\xFF\xFE\x00".b, "rb")
+
+ io.set_encoding_by_bom.should == Encoding::UTF_16LE
+ io.external_encoding.should == Encoding::UTF_16LE
+ io.read.b.should == "\x00".b
+
+ io = StringIO.new("\xFF\xFE\x00a".b, "rb")
+
+ io.set_encoding_by_bom.should == Encoding::UTF_16LE
+ io.external_encoding.should == Encoding::UTF_16LE
+ io.read.b.should == "\x00a".b
+ end
+
+ it "returns nil if UTF-32BE BOM sequence is incomplete" do
+ io = StringIO.new("\x00".b, "rb")
+
+ io.set_encoding_by_bom.should == nil
+ io.external_encoding.should == Encoding::ASCII_8BIT
+ io.read.b.should == "\x00".b
+
+ io = StringIO.new("\x00a".b, "rb")
+
+ io.set_encoding_by_bom.should == nil
+ io.external_encoding.should == Encoding::ASCII_8BIT
+ io.read.b.should == "\x00a".b
+
+ io = StringIO.new("\x00\x00".b, "rb")
+
+ io.set_encoding_by_bom.should == nil
+ io.external_encoding.should == Encoding::ASCII_8BIT
+ io.read.b.should == "\x00\x00".b
+
+ io = StringIO.new("\x00\x00a".b, "rb")
+
+ io.set_encoding_by_bom.should == nil
+ io.external_encoding.should == Encoding::ASCII_8BIT
+ io.read.b.should == "\x00\x00a".b
+
+ io = StringIO.new("\x00\x00\xFE".b, "rb")
+
+ io.set_encoding_by_bom.should == nil
+ io.external_encoding.should == Encoding::ASCII_8BIT
+ io.read.b.should == "\x00\x00\xFE".b
+
+ io = StringIO.new("\x00\x00\xFEa".b, "rb")
+
+ io.set_encoding_by_bom.should == nil
+ io.external_encoding.should == Encoding::ASCII_8BIT
+ io.read.b.should == "\x00\x00\xFEa".b
+ end
+
+ it "returns nil if found BOM sequence not provided" do
+ io = StringIO.new("abc".b, "rb")
+
+ io.set_encoding_by_bom.should == nil
+ io.external_encoding.should == Encoding::ASCII_8BIT
+ io.read(3).should == "abc".b
+ end
+
+ it "does not raise exception if io not in binary mode" do
+ io = StringIO.new("", 'r')
+ io.set_encoding_by_bom.should == nil
+ end
+
+ it "does not raise exception if encoding already set" do
+ io = StringIO.new("".b, "rb")
+ io.set_encoding("utf-8")
+ io.set_encoding_by_bom.should == nil
+ end
+
+ it "does not raise exception if encoding conversion is already set" do
+ io = StringIO.new("".b, "rb")
+ io.set_encoding(Encoding::UTF_8, Encoding::UTF_16BE)
+
+ io.set_encoding_by_bom.should == nil
+ end
+
+ it "raises FrozenError when io is frozen" do
+ io = StringIO.new()
+ io.freeze
+ -> { io.set_encoding_by_bom }.should raise_error(FrozenError)
+ end
+
+ it "does not raise FrozenError when initial string is frozen" do
+ io = StringIO.new("".freeze)
+ io.set_encoding_by_bom.should == nil
+ end
+end
diff --git a/spec/ruby/library/stringio/shared/sysread.rb b/spec/ruby/library/stringio/shared/sysread.rb
index 937bac705c..3e23fbc233 100644
--- a/spec/ruby/library/stringio/shared/sysread.rb
+++ b/spec/ruby/library/stringio/shared/sysread.rb
@@ -10,6 +10,6 @@ describe :stringio_sysread_length, shared: true do
it "raises an EOFError when passed length > 0 and no data remains" do
@io.read.should == "example"
- -> { @io.sysread(1) }.should raise_error(EOFError)
+ -> { @io.send(@method, 1) }.should raise_error(EOFError)
end
end
diff --git a/spec/ruby/library/stringio/sysread_spec.rb b/spec/ruby/library/stringio/sysread_spec.rb
index 8f78073f42..fabb06dd9a 100644
--- a/spec/ruby/library/stringio/sysread_spec.rb
+++ b/spec/ruby/library/stringio/sysread_spec.rb
@@ -1,6 +1,7 @@
require_relative '../../spec_helper'
require "stringio"
require_relative 'shared/read'
+require_relative 'shared/sysread'
describe "StringIO#sysread when passed length, buffer" do
it_behaves_like :stringio_read, :sysread
@@ -32,6 +33,10 @@ describe "StringIO#sysread when passed nil" do
end
end
+describe "StringIO#sysread when passed length" do
+ it_behaves_like :stringio_sysread_length, :sysread
+end
+
describe "StringIO#sysread when passed [length]" do
before :each do
@io = StringIO.new("example")
diff --git a/spec/ruby/library/time/shared/rfc2822.rb b/spec/ruby/library/time/shared/rfc2822.rb
index d99f1f76de..e460d655a6 100644
--- a/spec/ruby/library/time/shared/rfc2822.rb
+++ b/spec/ruby/library/time/shared/rfc2822.rb
@@ -1,33 +1,33 @@
describe :time_rfc2822, shared: true do
it "parses RFC-822 strings" do
t1 = (Time.utc(1976, 8, 26, 14, 30) + 4 * 3600)
- t2 = Time.rfc2822("26 Aug 76 14:30 EDT")
+ t2 = Time.send(@method, "26 Aug 76 14:30 EDT")
t1.should == t2
t3 = Time.utc(1976, 8, 27, 9, 32) + 7 * 3600
- t4 = Time.rfc2822("27 Aug 76 09:32 PDT")
+ t4 = Time.send(@method, "27 Aug 76 09:32 PDT")
t3.should == t4
end
it "parses RFC-2822 strings" do
t1 = Time.utc(1997, 11, 21, 9, 55, 6) + 6 * 3600
- t2 = Time.rfc2822("Fri, 21 Nov 1997 09:55:06 -0600")
+ t2 = Time.send(@method, "Fri, 21 Nov 1997 09:55:06 -0600")
t1.should == t2
t3 = Time.utc(2003, 7, 1, 10, 52, 37) - 2 * 3600
- t4 = Time.rfc2822("Tue, 1 Jul 2003 10:52:37 +0200")
+ t4 = Time.send(@method, "Tue, 1 Jul 2003 10:52:37 +0200")
t3.should == t4
t5 = Time.utc(1997, 11, 21, 10, 1, 10) + 6 * 3600
- t6 = Time.rfc2822("Fri, 21 Nov 1997 10:01:10 -0600")
+ t6 = Time.send(@method, "Fri, 21 Nov 1997 10:01:10 -0600")
t5.should == t6
t7 = Time.utc(1997, 11, 21, 11, 0, 0) + 6 * 3600
- t8 = Time.rfc2822("Fri, 21 Nov 1997 11:00:00 -0600")
+ t8 = Time.send(@method, "Fri, 21 Nov 1997 11:00:00 -0600")
t7.should == t8
t9 = Time.utc(1997, 11, 24, 14, 22, 1) + 8 * 3600
- t10 = Time.rfc2822("Mon, 24 Nov 1997 14:22:01 -0800")
+ t10 = Time.send(@method, "Mon, 24 Nov 1997 14:22:01 -0800")
t9.should == t10
begin
@@ -36,11 +36,11 @@ describe :time_rfc2822, shared: true do
# ignore
else
t11 = Time.utc(1969, 2, 13, 23, 32, 54) + 3 * 3600 + 30 * 60
- t12 = Time.rfc2822("Thu, 13 Feb 1969 23:32:54 -0330")
+ t12 = Time.send(@method, "Thu, 13 Feb 1969 23:32:54 -0330")
t11.should == t12
t13 = Time.utc(1969, 2, 13, 23, 32, 0) + 3 * 3600 + 30 * 60
- t14 = Time.rfc2822(" Thu,
+ t14 = Time.send(@method, " Thu,
13
Feb
1969
@@ -50,16 +50,16 @@ describe :time_rfc2822, shared: true do
end
t15 = Time.utc(1997, 11, 21, 9, 55, 6)
- t16 = Time.rfc2822("21 Nov 97 09:55:06 GMT")
+ t16 = Time.send(@method, "21 Nov 97 09:55:06 GMT")
t15.should == t16
t17 = Time.utc(1997, 11, 21, 9, 55, 6) + 6 * 3600
- t18 = Time.rfc2822("Fri, 21 Nov 1997 09 : 55 : 06 -0600")
+ t18 = Time.send(@method, "Fri, 21 Nov 1997 09 : 55 : 06 -0600")
t17.should == t18
-> {
# inner comment is not supported.
- Time.rfc2822("Fri, 21 Nov 1997 09(comment): 55 : 06 -0600")
+ Time.send(@method, "Fri, 21 Nov 1997 09(comment): 55 : 06 -0600")
}.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/library/time/shared/xmlschema.rb b/spec/ruby/library/time/shared/xmlschema.rb
index 831d8509a7..0002886ca5 100644
--- a/spec/ruby/library/time/shared/xmlschema.rb
+++ b/spec/ruby/library/time/shared/xmlschema.rb
@@ -2,23 +2,23 @@ describe :time_library_xmlschema, shared: true do
it "parses ISO-8601 strings" do
t = Time.utc(1985, 4, 12, 23, 20, 50, 520000)
s = "1985-04-12T23:20:50.52Z"
- t.should == Time.xmlschema(s)
- #s.should == t.xmlschema(2)
+ t.should == Time.send(@method, s)
+ #s.should == t.send(@method, 2)
t = Time.utc(1996, 12, 20, 0, 39, 57)
s = "1996-12-19T16:39:57-08:00"
- t.should == Time.xmlschema(s)
+ t.should == Time.send(@method, s)
# There is no way to generate time string with arbitrary timezone.
s = "1996-12-20T00:39:57Z"
- t.should == Time.xmlschema(s)
- #assert_equal(s, t.xmlschema)
+ t.should == Time.send(@method, s)
+ #assert_equal(s, t.send(@method))
t = Time.utc(1990, 12, 31, 23, 59, 60)
s = "1990-12-31T23:59:60Z"
- t.should == Time.xmlschema(s)
+ t.should == Time.send(@method, s)
# leap second is representable only if timezone file has it.
s = "1990-12-31T15:59:60-08:00"
- t.should == Time.xmlschema(s)
+ t.should == Time.send(@method, s)
begin
Time.at(-1)
@@ -27,27 +27,27 @@ describe :time_library_xmlschema, shared: true do
else
t = Time.utc(1937, 1, 1, 11, 40, 27, 870000)
s = "1937-01-01T12:00:27.87+00:20"
- t.should == Time.xmlschema(s)
+ t.should == Time.send(@method, s)
end
# more
- # (Time.utc(1999, 5, 31, 13, 20, 0) + 5 * 3600).should == Time.xmlschema("1999-05-31T13:20:00-05:00")
- # (Time.local(2000, 1, 20, 12, 0, 0)).should == Time.xmlschema("2000-01-20T12:00:00")
- # (Time.utc(2000, 1, 20, 12, 0, 0)).should == Time.xmlschema("2000-01-20T12:00:00Z")
- # (Time.utc(2000, 1, 20, 12, 0, 0) - 12 * 3600).should == Time.xmlschema("2000-01-20T12:00:00+12:00")
- # (Time.utc(2000, 1, 20, 12, 0, 0) + 13 * 3600).should == Time.xmlschema("2000-01-20T12:00:00-13:00")
- # (Time.utc(2000, 3, 4, 23, 0, 0) - 3 * 3600).should == Time.xmlschema("2000-03-04T23:00:00+03:00")
- # (Time.utc(2000, 3, 4, 20, 0, 0)).should == Time.xmlschema("2000-03-04T20:00:00Z")
- # (Time.local(2000, 1, 15, 0, 0, 0)).should == Time.xmlschema("2000-01-15T00:00:00")
- # (Time.local(2000, 2, 15, 0, 0, 0)).should == Time.xmlschema("2000-02-15T00:00:00")
- # (Time.local(2000, 1, 15, 12, 0, 0)).should == Time.xmlschema("2000-01-15T12:00:00")
- # (Time.utc(2000, 1, 16, 12, 0, 0)).should == Time.xmlschema("2000-01-16T12:00:00Z")
- # (Time.local(2000, 1, 1, 12, 0, 0)).should == Time.xmlschema("2000-01-01T12:00:00")
- # (Time.utc(1999, 12, 31, 23, 0, 0)).should == Time.xmlschema("1999-12-31T23:00:00Z")
- # (Time.local(2000, 1, 16, 12, 0, 0)).should == Time.xmlschema("2000-01-16T12:00:00")
- # (Time.local(2000, 1, 16, 0, 0, 0)).should == Time.xmlschema("2000-01-16T00:00:00")
- # (Time.utc(2000, 1, 12, 12, 13, 14)).should == Time.xmlschema("2000-01-12T12:13:14Z")
- # (Time.utc(2001, 4, 17, 19, 23, 17, 300000)).should == Time.xmlschema("2001-04-17T19:23:17.3Z")
+ # (Time.utc(1999, 5, 31, 13, 20, 0) + 5 * 3600).should == Time.send(@method, "1999-05-31T13:20:00-05:00")
+ # (Time.local(2000, 1, 20, 12, 0, 0)).should == Time.send(@method, "2000-01-20T12:00:00")
+ # (Time.utc(2000, 1, 20, 12, 0, 0)).should == Time.send(@method, "2000-01-20T12:00:00Z")
+ # (Time.utc(2000, 1, 20, 12, 0, 0) - 12 * 3600).should == Time.send(@method, "2000-01-20T12:00:00+12:00")
+ # (Time.utc(2000, 1, 20, 12, 0, 0) + 13 * 3600).should == Time.send(@method, "2000-01-20T12:00:00-13:00")
+ # (Time.utc(2000, 3, 4, 23, 0, 0) - 3 * 3600).should == Time.send(@method, "2000-03-04T23:00:00+03:00")
+ # (Time.utc(2000, 3, 4, 20, 0, 0)).should == Time.send(@method, "2000-03-04T20:00:00Z")
+ # (Time.local(2000, 1, 15, 0, 0, 0)).should == Time.send(@method, "2000-01-15T00:00:00")
+ # (Time.local(2000, 2, 15, 0, 0, 0)).should == Time.send(@method, "2000-02-15T00:00:00")
+ # (Time.local(2000, 1, 15, 12, 0, 0)).should == Time.send(@method, "2000-01-15T12:00:00")
+ # (Time.utc(2000, 1, 16, 12, 0, 0)).should == Time.send(@method, "2000-01-16T12:00:00Z")
+ # (Time.local(2000, 1, 1, 12, 0, 0)).should == Time.send(@method, "2000-01-01T12:00:00")
+ # (Time.utc(1999, 12, 31, 23, 0, 0)).should == Time.send(@method, "1999-12-31T23:00:00Z")
+ # (Time.local(2000, 1, 16, 12, 0, 0)).should == Time.send(@method, "2000-01-16T12:00:00")
+ # (Time.local(2000, 1, 16, 0, 0, 0)).should == Time.send(@method, "2000-01-16T00:00:00")
+ # (Time.utc(2000, 1, 12, 12, 13, 14)).should == Time.send(@method, "2000-01-12T12:13:14Z")
+ # (Time.utc(2001, 4, 17, 19, 23, 17, 300000)).should == Time.send(@method, "2001-04-17T19:23:17.3Z")
end
end