Skip to content

Commit c4ed78e

Browse files
committed
1 parent 0401840 commit c4ed78e

File tree

193 files changed

+878
-530
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

193 files changed

+878
-530
lines changed

spec/ruby/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
The Ruby Spec Suite, abbreviated `ruby/spec`, is a test suite for the behavior of the Ruby programming language.
77

8+
### Description and Motivation
9+
810
It is not a standardized specification like the ISO one, and does not aim to become one.
911
Instead, it is a practical tool to describe and test the behavior of Ruby with code.
1012

@@ -30,20 +32,24 @@ ruby/spec is known to be tested in these implementations for every commit:
3032
ruby/spec describes the behavior of Ruby 2.5 and more recent Ruby versions.
3133
More precisely, every latest stable MRI release should [pass](https://travis-ci.org/ruby/spec) all specs of ruby/spec (2.5.x, 2.6.x, 2.7.x, etc), and those are tested in TravisCI.
3234

35+
### Synchronization with Ruby Implementations
36+
3337
The specs are synchronized both ways around once a month by @eregon between ruby/spec, MRI, JRuby and TruffleRuby.
3438
Each of these repositories has a full copy of the specs under `spec/ruby` to ease editing specs.
3539
Any of these repositories can be used to add or edit specs, use what is most convenient for you.
3640

37-
For *testing* a Ruby implementation, one should always test against the implementation's copy of the specs under `spec/ruby`, as that's what the Ruby implementation tests against in their CI.
41+
For *testing* the development version of a Ruby implementation, one should always test against that implementation's copy of the specs under `spec/ruby`, as that's what the Ruby implementation tests against in their CI.
3842
Also, this repository doesn't always contain the latest spec changes from MRI (it's synchronized monthly), and does not contain tags (specs marked as failing on that Ruby implementation).
39-
Running specs in a Ruby implementation can be done with:
43+
Running specs on a Ruby implementation can be done with:
4044

4145
```
4246
$ cd ruby_implementation/spec/ruby
4347
# Add ../ruby_implementation/bin in PATH, or pass -t /path/to/bin/ruby
4448
$ ../mspec/bin/mspec
4549
```
4650

51+
### Specs for old Ruby versions
52+
4753
For older specs try these commits:
4854
* Ruby 2.0.0-p647 - [Suite](https://github.com/ruby/spec/commit/245862558761d5abc676843ef74f86c9bcc8ea8d) using [MSpec](https://github.com/ruby/mspec/commit/f90efa068791064f955de7a843e96e2d7d3041c2) (may encounter 2 failures)
4955
* Ruby 2.1.9 - [Suite](https://github.com/ruby/spec/commit/f029e65241374386077ac500add557ae65069b55) using [MSpec](https://github.com/ruby/mspec/commit/55568ea3918c6380e64db8c567d732fa5781efed)

spec/ruby/command_line/feature_spec.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,16 @@
3737
ruby_exe("p 'foo'.frozen?", options: "--disable-frozen-string-literal").chomp.should == "false"
3838
end
3939

40-
it "can be used with all" do
40+
it "can be used with all for enable" do
4141
e = "p [defined?(Gem), defined?(DidYouMean), $VERBOSE, 'foo'.frozen?]"
4242
env = {'RUBYOPT' => '-w'}
43-
ruby_exe(e, options: "--enable=all", env: env).chomp.should == "[\"constant\", \"constant\", true, true]"
43+
# Use a single variant here because it can be quite slow as it might enable jit, etc
4444
ruby_exe(e, options: "--enable-all", env: env).chomp.should == "[\"constant\", \"constant\", true, true]"
45+
end
46+
47+
it "can be used with all for disable" do
48+
e = "p [defined?(Gem), defined?(DidYouMean), $VERBOSE, 'foo'.frozen?]"
49+
env = {'RUBYOPT' => '-w'}
4550
ruby_exe(e, options: "--disable=all", env: env).chomp.should == "[nil, nil, false, false]"
4651
ruby_exe(e, options: "--disable-all", env: env).chomp.should == "[nil, nil, false, false]"
4752
end

spec/ruby/core/binding/eval_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
bind2.local_variables.should == []
2424
end
2525

26-
ruby_version_is ""..."2.8" do
26+
ruby_version_is ""..."3.0" do
2727
it "inherits __LINE__ from the enclosing scope" do
2828
obj = BindingSpecs::Demo.new(1)
2929
bind = obj.get_binding
@@ -50,7 +50,7 @@
5050
end
5151
end
5252

53-
ruby_version_is "2.8" do
53+
ruby_version_is "3.0" do
5454
it "starts with line 1 if single argument is given" do
5555
obj = BindingSpecs::Demo.new(1)
5656
bind = obj.get_binding
@@ -89,15 +89,15 @@
8989
bind.eval("#foo\n__LINE__", "(test)", 88).should == 89
9090
end
9191

92-
ruby_version_is ""..."2.8" do
92+
ruby_version_is ""..."3.0" do
9393
it "inherits __FILE__ from the enclosing scope" do
9494
obj = BindingSpecs::Demo.new(1)
9595
bind = obj.get_binding
9696
suppress_warning {bind.eval("__FILE__")}.should == obj.get_file_of_binding
9797
end
9898
end
9999

100-
ruby_version_is "2.8" do
100+
ruby_version_is "3.0" do
101101
it "Uses (eval) as __FILE__ if single argument given" do
102102
obj = BindingSpecs::Demo.new(1)
103103
bind = obj.get_binding

spec/ruby/core/complex/to_c_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
require_relative '../../spec_helper'
2+
3+
describe "Complex#to_c" do
4+
it "returns self" do
5+
value = Complex(1, 5)
6+
value.to_c.should equal(value)
7+
end
8+
9+
it 'returns the same value' do
10+
Complex(1, 5).to_c.should == Complex(1, 5)
11+
end
12+
end

spec/ruby/core/env/delete_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
ScratchPad.recorded.should == "foo"
3131
end
3232

33-
ruby_version_is "2.8" do
33+
ruby_version_is "3.0" do
3434
it "returns the result of given block if the named environment variable does not exist" do
3535
ENV.delete("foo")
3636
ENV.delete("foo") { |name| "bar" }.should == "bar"

spec/ruby/core/exception/no_method_error_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def inspect
104104
end
105105
end
106106

107-
ruby_version_is "2.8" do
107+
ruby_version_is "3.0" do
108108
it "uses #name to display the receiver if it is a class or a module" do
109109
klass = Class.new { def self.name; "MyClass"; end }
110110
begin

spec/ruby/core/exception/top_level_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
it "the Exception#cause is printed to STDERR with backtraces" do
1010
code = <<-RUBY
1111
def raise_cause
12-
raise "the cause"
12+
raise "the cause"
1313
end
1414
def raise_wrapped
1515
raise "wrapped"
@@ -22,7 +22,7 @@ def raise_wrapped
2222
RUBY
2323
lines = ruby_exe(code, args: "2>&1").lines
2424
lines.reject! { |l| l.include?('rescue in') }
25-
lines.map! { |l| l.split(':')[2..-1].join(':').chomp }
25+
lines.map! { |l| l.chomp[/:(in.+)/, 1] }
2626
lines.should == ["in `raise_wrapped': wrapped (RuntimeError)",
2727
"in `<main>'",
2828
"in `raise_cause': the cause (RuntimeError)",

spec/ruby/core/hash/except_spec.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
require_relative '../../spec_helper'
2+
3+
ruby_version_is "3.0" do
4+
describe "Hash#except" do
5+
before :each do
6+
@hash = { a: 1, b: 2, c: 3 }
7+
end
8+
9+
it "returns a new duplicate hash without arguments" do
10+
ret = @hash.except
11+
ret.should_not equal(@hash)
12+
ret.should == @hash
13+
end
14+
15+
it "returns a hash without the requested subset" do
16+
@hash.except(:c, :a).should == { b: 2 }
17+
end
18+
19+
it "ignores keys not present in the original hash" do
20+
@hash.except(:a, :chunky_bacon).should == { b: 2, c: 3 }
21+
end
22+
23+
it "returns an instance of a subclass" do
24+
klass = Class.new(Hash)
25+
h = klass.new
26+
h[:bar] = 12
27+
h[:foo] = 42
28+
r = h.except(:foo)
29+
r.should == {bar: 12}
30+
r.class.should == klass
31+
end
32+
end
33+
end

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
ary.sort.should == ["a", "b", "c"]
2222
end
2323

24-
ruby_version_is ""..."2.8" do
24+
ruby_version_is ""..."3.0" do
2525
it "yields 2 values and not an Array of 2 elements when given a callable of arity 2" do
2626
obj = Object.new
2727
def obj.foo(key, value)
@@ -38,8 +38,8 @@ def obj.foo(key, value)
3838
end
3939
end
4040

41-
ruby_version_is "2.8" do
42-
it "yields an Array of 2 elements when given a callable of arity 2" do
41+
ruby_version_is "3.0" do
42+
it "always yields an Array of 2 elements, even when given a callable of arity 2" do
4343
obj = Object.new
4444
def obj.foo(key, value)
4545
end

spec/ruby/core/hash/to_proc_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
@proc = @hash.to_proc
2020
end
2121

22-
ruby_version_is ""..."2.8" do
22+
ruby_version_is ""..."3.0" do
2323
it "is not a lambda" do
2424
@proc.should_not.lambda?
2525
end
2626
end
2727

28-
ruby_version_is "2.8" do
28+
ruby_version_is "3.0" do
2929
it "is a lambda" do
3030
@proc.should.lambda?
3131
end

0 commit comments

Comments
 (0)