Skip to content

Commit c37d6ae

Browse files
committed
[GR-14806] Update specs
PullRequest: truffleruby/3444
2 parents d7f4eea + 46ebdf3 commit c37d6ae

File tree

10 files changed

+60
-26
lines changed

10 files changed

+60
-26
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require_relative '../../spec_helper'
2+
require_relative 'fixtures/classes'
3+
4+
ruby_version_is '3.1' do
5+
describe "Enumerable#compact" do
6+
it 'returns array without nil elements' do
7+
arr = EnumerableSpecs::Numerous.new(nil, 1, 2, nil, true)
8+
arr.compact.should == [1, 2, true]
9+
end
10+
end
11+
end

spec/ruby/core/enumerator/lazy/lazy_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
]
1717
lazy_methods += [:chunk_while, :uniq]
1818

19+
ruby_version_is '3.1' do
20+
lazy_methods += [:compact]
21+
end
22+
1923
Enumerator::Lazy.instance_methods(false).should include(*lazy_methods)
2024
end
2125
end
@@ -26,3 +30,13 @@
2630
lazy.lazy.should equal(lazy)
2731
end
2832
end
33+
34+
ruby_version_is '3.1' do
35+
describe "Enumerator::Lazy#compact" do
36+
it 'returns array without nil elements' do
37+
arr = [1, nil, 3, false, 5].to_enum.lazy.compact
38+
arr.should be_an_instance_of(Enumerator::Lazy)
39+
arr.force.should == [1, 3, false, 5]
40+
end
41+
end
42+
end

spec/ruby/core/io/shared/each.rb

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,20 @@
190190
end
191191

192192
describe "when passed chomp and nil as a separator" do
193-
it "yields self's content without trailing new line character" do
194-
@io.pos = 100
195-
@io.send(@method, nil, chomp: true) { |s| ScratchPad << s }
196-
ScratchPad.recorded.should == ["qui a linha cinco.\nHere is line six."]
193+
ruby_version_is "3.2" do
194+
it "yields self's content" do
195+
@io.pos = 100
196+
@io.send(@method, nil, chomp: true) { |s| ScratchPad << s }
197+
ScratchPad.recorded.should == ["qui a linha cinco.\nHere is line six.\n"]
198+
end
199+
end
200+
201+
ruby_version_is ""..."3.2" do
202+
it "yields self's content without trailing new line character" do
203+
@io.pos = 100
204+
@io.send(@method, nil, chomp: true) { |s| ScratchPad << s }
205+
ScratchPad.recorded.should == ["qui a linha cinco.\nHere is line six."]
206+
end
197207
end
198208
end
199209

spec/ruby/core/process/clock_gettime_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,17 @@
8383
end
8484
end
8585

86-
platform_is :freebsd, :openbsd do
86+
platform_is :freebsd do
8787
it "CLOCK_VIRTUAL" do
8888
Process.clock_gettime(Process::CLOCK_VIRTUAL).should be_an_instance_of(Float)
8989
end
9090

9191
it "CLOCK_PROF" do
9292
Process.clock_gettime(Process::CLOCK_PROF).should be_an_instance_of(Float)
9393
end
94+
end
9495

96+
platform_is :freebsd, :openbsd do
9597
it "CLOCK_UPTIME" do
9698
Process.clock_gettime(Process::CLOCK_UPTIME).should be_an_instance_of(Float)
9799
end

spec/ruby/core/string/encoding_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
it "is equal to the source encoding by default" do
1111
s = StringSpecs::ISO88599Encoding.new
1212
s.cedilla.encoding.should == s.source_encoding
13+
s.cedilla.encode("utf-8").should == 350.chr(Encoding::UTF_8) # S-cedilla
1314
end
1415

1516
it "returns the given encoding if #force_encoding has been called" do

spec/ruby/core/string/fixtures/iso-8859-9-encoding.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ class ISO88599Encoding
44
def source_encoding; __ENCODING__; end
55
def x_escape; [0xDF].pack('C').force_encoding("iso-8859-9"); end
66
def ascii_only; "glark"; end
7-
def cedilla; "Ş"; end
7+
def cedilla; "Þ"; end # S-cedilla
88
end
99
end

spec/ruby/core/string/rstrip_spec.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,4 @@
7878
s.valid_encoding?.should be_false
7979
-> { s.rstrip! }.should raise_error(ArgumentError)
8080
end
81-
82-
it "removes broken codepoints" do
83-
" abc \x80 ".rstrip!.should == " abc"
84-
" abc \x80".rstrip!.should == " abc"
85-
end
8681
end

spec/ruby/language/module_spec.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,18 @@ module ModuleSpecs; Reopened = true; end
2828
ModuleSpecs::Reopened.should be_true
2929
end
3030

31-
it "reopens a module included in Object" do
32-
module IncludedModuleSpecs; Reopened = true; end
33-
ModuleSpecs::IncludedInObject::IncludedModuleSpecs::Reopened.should be_true
31+
ruby_version_is '3.2' do
32+
it "does not reopen a module included in Object" do
33+
module IncludedModuleSpecs; Reopened = true; end
34+
ModuleSpecs::IncludedInObject::IncludedModuleSpecs.should_not == Object::IncludedModuleSpecs
35+
end
36+
end
37+
38+
ruby_version_is ''...'3.2' do
39+
it "reopens a module included in Object" do
40+
module IncludedModuleSpecs; Reopened = true; end
41+
ModuleSpecs::IncludedInObject::IncludedModuleSpecs::Reopened.should be_true
42+
end
3443
end
3544

3645
it "raises a TypeError if the constant is a Class" do

spec/ruby/library/openssl/x509/name/verify_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
cert.subject = OpenSSL::X509::Name.parse "/DC=org/DC=truffleruby/CN=TruffleRuby CA"
1111
cert.issuer = cert.subject
1212
cert.public_key = key.public_key
13-
cert.not_before = Time.now
13+
cert.not_before = Time.now - 10
1414
cert.not_after = cert.not_before + 365 * 24 * 60 * 60
1515
cert.sign key, OpenSSL::Digest.new('SHA1')
1616
store = OpenSSL::X509::Store.new
1717
store.add_cert(cert)
18-
store.verify(cert).should == true
18+
[store.verify(cert), store.error, store.error_string].should == [true, 0, "ok"]
1919
end
2020

2121
it "returns false for an expired certificate" do

spec/ruby/library/stringio/truncate_spec.rb

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
@io = StringIO.new('123456789')
77
end
88

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

1513
it "truncated the underlying string down to the passed length" do
@@ -47,12 +45,6 @@
4745
@io.string.should == "1234"
4846
end
4947

50-
it "returns the passed length Object, NOT the result of #to_int" do
51-
obj = mock("to_int")
52-
obj.should_receive(:to_int).and_return(4)
53-
@io.truncate(obj).should equal(obj)
54-
end
55-
5648
it "raises a TypeError when the passed length can't be converted to an Integer" do
5749
-> { @io.truncate(Object.new) }.should raise_error(TypeError)
5850
end

0 commit comments

Comments
 (0)