Skip to content

Commit

Permalink
[GR-14806] Update specs
Browse files Browse the repository at this point in the history
PullRequest: truffleruby/3444
  • Loading branch information
eregon committed Jul 27, 2022
2 parents d7f4eea + 46ebdf3 commit c37d6ae
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 26 deletions.
11 changes: 11 additions & 0 deletions spec/ruby/core/enumerable/compact_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'

ruby_version_is '3.1' do
describe "Enumerable#compact" do
it 'returns array without nil elements' do
arr = EnumerableSpecs::Numerous.new(nil, 1, 2, nil, true)
arr.compact.should == [1, 2, true]
end
end
end
14 changes: 14 additions & 0 deletions spec/ruby/core/enumerator/lazy/lazy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
]
lazy_methods += [:chunk_while, :uniq]

ruby_version_is '3.1' do
lazy_methods += [:compact]
end

Enumerator::Lazy.instance_methods(false).should include(*lazy_methods)
end
end
Expand All @@ -26,3 +30,13 @@
lazy.lazy.should equal(lazy)
end
end

ruby_version_is '3.1' do
describe "Enumerator::Lazy#compact" do
it 'returns array without nil elements' do
arr = [1, nil, 3, false, 5].to_enum.lazy.compact
arr.should be_an_instance_of(Enumerator::Lazy)
arr.force.should == [1, 3, false, 5]
end
end
end
18 changes: 14 additions & 4 deletions spec/ruby/core/io/shared/each.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,20 @@
end

describe "when passed chomp and nil as a separator" do
it "yields self's content without trailing new line character" do
@io.pos = 100
@io.send(@method, nil, chomp: true) { |s| ScratchPad << s }
ScratchPad.recorded.should == ["qui a linha cinco.\nHere is line six."]
ruby_version_is "3.2" do
it "yields self's content" do
@io.pos = 100
@io.send(@method, nil, chomp: true) { |s| ScratchPad << s }
ScratchPad.recorded.should == ["qui a linha cinco.\nHere is line six.\n"]
end
end

ruby_version_is ""..."3.2" do
it "yields self's content without trailing new line character" do
@io.pos = 100
@io.send(@method, nil, chomp: true) { |s| ScratchPad << s }
ScratchPad.recorded.should == ["qui a linha cinco.\nHere is line six."]
end
end
end

Expand Down
4 changes: 3 additions & 1 deletion spec/ruby/core/process/clock_gettime_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,17 @@
end
end

platform_is :freebsd, :openbsd do
platform_is :freebsd do
it "CLOCK_VIRTUAL" do
Process.clock_gettime(Process::CLOCK_VIRTUAL).should be_an_instance_of(Float)
end

it "CLOCK_PROF" do
Process.clock_gettime(Process::CLOCK_PROF).should be_an_instance_of(Float)
end
end

platform_is :freebsd, :openbsd do
it "CLOCK_UPTIME" do
Process.clock_gettime(Process::CLOCK_UPTIME).should be_an_instance_of(Float)
end
Expand Down
1 change: 1 addition & 0 deletions spec/ruby/core/string/encoding_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
it "is equal to the source encoding by default" do
s = StringSpecs::ISO88599Encoding.new
s.cedilla.encoding.should == s.source_encoding
s.cedilla.encode("utf-8").should == 350.chr(Encoding::UTF_8) # S-cedilla
end

it "returns the given encoding if #force_encoding has been called" do
Expand Down
2 changes: 1 addition & 1 deletion spec/ruby/core/string/fixtures/iso-8859-9-encoding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ class ISO88599Encoding
def source_encoding; __ENCODING__; end
def x_escape; [0xDF].pack('C').force_encoding("iso-8859-9"); end
def ascii_only; "glark"; end
def cedilla; "Ş"; end
def cedilla; "Þ"; end # S-cedilla
end
end
5 changes: 0 additions & 5 deletions spec/ruby/core/string/rstrip_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,4 @@
s.valid_encoding?.should be_false
-> { s.rstrip! }.should raise_error(ArgumentError)
end

it "removes broken codepoints" do
" abc \x80 ".rstrip!.should == " abc"
" abc \x80".rstrip!.should == " abc"
end
end
15 changes: 12 additions & 3 deletions spec/ruby/language/module_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,18 @@ module ModuleSpecs; Reopened = true; end
ModuleSpecs::Reopened.should be_true
end

it "reopens a module included in Object" do
module IncludedModuleSpecs; Reopened = true; end
ModuleSpecs::IncludedInObject::IncludedModuleSpecs::Reopened.should be_true
ruby_version_is '3.2' do
it "does not reopen a module included in Object" do
module IncludedModuleSpecs; Reopened = true; end
ModuleSpecs::IncludedInObject::IncludedModuleSpecs.should_not == Object::IncludedModuleSpecs
end
end

ruby_version_is ''...'3.2' do
it "reopens a module included in Object" do
module IncludedModuleSpecs; Reopened = true; end
ModuleSpecs::IncludedInObject::IncludedModuleSpecs::Reopened.should be_true
end
end

it "raises a TypeError if the constant is a Class" do
Expand Down
4 changes: 2 additions & 2 deletions spec/ruby/library/openssl/x509/name/verify_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
cert.subject = OpenSSL::X509::Name.parse "/DC=org/DC=truffleruby/CN=TruffleRuby CA"
cert.issuer = cert.subject
cert.public_key = key.public_key
cert.not_before = Time.now
cert.not_before = Time.now - 10
cert.not_after = cert.not_before + 365 * 24 * 60 * 60
cert.sign key, OpenSSL::Digest.new('SHA1')
store = OpenSSL::X509::Store.new
store.add_cert(cert)
store.verify(cert).should == true
[store.verify(cert), store.error, store.error_string].should == [true, 0, "ok"]
end

it "returns false for an expired certificate" do
Expand Down
12 changes: 2 additions & 10 deletions spec/ruby/library/stringio/truncate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
@io = StringIO.new('123456789')
end

# TODO: Report to Ruby-Core: The RDoc says it always returns 0
it "returns the passed length" do
@io.truncate(4).should eql(4)
@io.truncate(10).should eql(10)
it "returns an Integer" do
@io.truncate(4).should be_kind_of(Integer)
end

it "truncated the underlying string down to the passed length" do
Expand Down Expand Up @@ -47,12 +45,6 @@
@io.string.should == "1234"
end

it "returns the passed length Object, NOT the result of #to_int" do
obj = mock("to_int")
obj.should_receive(:to_int).and_return(4)
@io.truncate(obj).should equal(obj)
end

it "raises a TypeError when the passed length can't be converted to an Integer" do
-> { @io.truncate(Object.new) }.should raise_error(TypeError)
end
Expand Down

0 comments on commit c37d6ae

Please sign in to comment.