Skip to content

Commit fb10856

Browse files
committed
1 parent 549f890 commit fb10856

File tree

22 files changed

+241
-143
lines changed

22 files changed

+241
-143
lines changed

spec/ruby/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ ruby/spec is known to be tested in these implementations for every commit:
2828
* [JRuby](https://github.com/jruby/jruby/tree/master/spec/ruby) for both 1.7 and 9.x
2929
* [TruffleRuby](https://github.com/oracle/truffleruby/tree/master/spec/ruby)
3030
* [Opal](https://github.com/opal/opal/tree/master/spec)
31+
* [Artichoke](https://github.com/artichoke/spec/tree/artichoke-vendor)
3132

3233
ruby/spec describes the behavior of Ruby 2.6 and more recent Ruby versions.
3334
More precisely, every latest stable MRI release should [pass](https://github.com/ruby/spec/actions/workflows/ci.yml) all specs of ruby/spec (2.6.x, 2.7.x, 3.0.x, etc), and those are tested in CI.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
require_relative '../../spec_helper'
2+
3+
describe 'Array#intersect?' do
4+
ruby_version_is '3.1' do # https://bugs.ruby-lang.org/issues/15198
5+
describe 'when at least one element in two Arrays is the same' do
6+
it 'returns true' do
7+
[1, 2].intersect?([2, 3]).should == true
8+
end
9+
end
10+
11+
describe 'when there are no elements in common between two Arrays' do
12+
it 'returns false' do
13+
[1, 2].intersect?([3, 4]).should == false
14+
end
15+
end
16+
end
17+
end

spec/ruby/core/enumerable/tally_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
enum.tally(hash).should equal(hash)
5252
end
5353

54-
it "raises a FrozenError and does not udpate the given hash when the hash is frozen" do
54+
it "raises a FrozenError and does not update the given hash when the hash is frozen" do
5555
enum = EnumerableSpecs::Numerous.new('foo', 'bar', 'foo', 'baz')
5656
hash = { 'foo' => 1 }.freeze
5757
-> { enum.tally(hash) }.should raise_error(FrozenError)

spec/ruby/core/gc/stat_spec.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
it "returns hash of values" do
55
stat = GC.stat
66
stat.should be_kind_of(Hash)
7-
stat.keys.should include(:count)
7+
stat.keys.should.include?(:count)
8+
end
9+
10+
it "the values are all Integer since rb_gc_stat() returns size_t" do
11+
GC.stat.values.each { |value| value.should be_kind_of(Integer) }
812
end
913

1014
it "can return a single value" do

spec/ruby/core/io/external_encoding_spec.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,12 @@
9494
rm_r @name
9595
end
9696

97-
it "raises an IOError on closed stream" do
98-
-> { IOSpecs.closed_io.external_encoding }.should raise_error(IOError)
97+
ruby_version_is '3.1' do
98+
it "can be retrieved from a closed stream" do
99+
io = IOSpecs.io_fixture("lines.txt", "r")
100+
io.close
101+
io.external_encoding.should equal(Encoding.default_external)
102+
end
99103
end
100104

101105
describe "with 'r' mode" do

spec/ruby/core/io/internal_encoding_spec.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,12 @@
113113
Encoding.default_internal = @internal
114114
end
115115

116-
it "raises an IOError on closed stream" do
117-
-> { IOSpecs.closed_io.internal_encoding }.should raise_error(IOError)
116+
ruby_version_is '3.1' do
117+
it "can be retrieved from a closed stream" do
118+
io = IOSpecs.io_fixture("lines.txt", "r")
119+
io.close
120+
io.internal_encoding.should equal(Encoding.default_internal)
121+
end
118122
end
119123

120124
describe "with 'r' mode" do

spec/ruby/core/kernel/nil_spec.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
require_relative '../../spec_helper'
22
require_relative 'fixtures/classes'
33

4-
describe "Kernel#nil?" do
5-
it "needs to be reviewed for spec completeness"
4+
describe 'Kernel#nil?' do
5+
it 'returns false' do
6+
Object.should_not.nil?
7+
Object.new.should_not.nil?
8+
''.should_not.nil?
9+
[].should_not.nil?
10+
{}.should_not.nil?
11+
end
612
end

spec/ruby/core/process/spawn_spec.rb

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -212,21 +212,23 @@
212212
end.should output_to_fd("nil\n")
213213
end
214214

215-
it "uses the passed env['PATH'] to search the executable" do
216-
dir = tmp("spawn_path_dir")
217-
mkdir_p dir
218-
begin
219-
exe = 'process-spawn-executable-in-path'
220-
path = "#{dir}/#{exe}"
221-
File.write(path, "#!/bin/sh\necho $1")
222-
File.chmod(0755, path)
223-
224-
env = { "PATH" => "#{dir}#{File::PATH_SEPARATOR}#{ENV['PATH']}" }
225-
Process.wait Process.spawn(env, exe, 'OK', out: @name)
226-
$?.should.success?
227-
File.read(@name).should == "OK\n"
228-
ensure
229-
rm_r dir
215+
platform_is_not :windows do
216+
it "uses the passed env['PATH'] to search the executable" do
217+
dir = tmp("spawn_path_dir")
218+
mkdir_p dir
219+
begin
220+
exe = 'process-spawn-executable-in-path'
221+
path = "#{dir}/#{exe}"
222+
File.write(path, "#!/bin/sh\necho $1")
223+
File.chmod(0755, path)
224+
225+
env = { "PATH" => "#{dir}#{File::PATH_SEPARATOR}#{ENV['PATH']}" }
226+
Process.wait Process.spawn(env, exe, 'OK', out: @name)
227+
$?.should.success?
228+
File.read(@name).should == "OK\n"
229+
ensure
230+
rm_r dir
231+
end
230232
end
231233
end
232234

spec/ruby/core/thread/backtrace/location/absolute_path_spec.rb

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,20 @@
1818
end
1919

2020
context "when used in eval with a given filename" do
21-
it "returns filename" do
22-
code = "caller_locations(0)[0].absolute_path"
23-
eval(code, nil, "foo.rb").should == "foo.rb"
24-
eval(code, nil, "foo/bar.rb").should == "foo/bar.rb"
21+
code = "caller_locations(0)[0].absolute_path"
22+
23+
ruby_version_is ""..."3.1" do
24+
it "returns filename with absolute_path" do
25+
eval(code, nil, "foo.rb").should == "foo.rb"
26+
eval(code, nil, "foo/bar.rb").should == "foo/bar.rb"
27+
end
28+
end
29+
30+
ruby_version_is "3.1" do
31+
it "returns nil with absolute_path" do
32+
eval(code, nil, "foo.rb").should == nil
33+
eval(code, nil, "foo/bar.rb").should == nil
34+
end
2535
end
2636
end
2737

spec/ruby/core/tracepoint/inspect_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ def trace_point_spec_test_return
6464

6565
it 'returns a String showing the event, method, path and line for a :c_call event' do
6666
inspect = nil
67-
line = nil
68-
TracePoint.new(:c_call) { |tp|
67+
tracepoint = TracePoint.new(:c_call) { |tp|
6968
next unless TracePointSpec.target_thread?
7069
inspect ||= tp.inspect
71-
}.enable do
72-
line = __LINE__ + 1
70+
}
71+
line = __LINE__ + 2
72+
tracepoint.enable do
7373
[0, 1].max
7474
end
7575

0 commit comments

Comments
 (0)