Skip to content

Commit 50593d5

Browse files
committed
1 parent 5e7e604 commit 50593d5

File tree

24 files changed

+456
-22
lines changed

24 files changed

+456
-22
lines changed

spec/ruby/.rubocop_todo.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Lint/FloatOutOfRange:
4444
Lint/ImplicitStringConcatenation:
4545
Exclude:
4646
- 'language/string_spec.rb'
47+
- 'core/string/chilled_string_spec.rb'
4748

4849
# Offense count: 4
4950
Lint/IneffectiveAccessModifier:

spec/ruby/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ ruby/spec is known to be tested in these implementations for every commit:
2626

2727
* [MRI](https://rubyci.org/) on 30 platforms and 4 versions
2828
* [JRuby](https://github.com/jruby/jruby/tree/master/spec/ruby) for both 1.7 and 9.x
29-
* [TruffleRuby](https://github.com/oracle/truffleruby/tree/master/spec/ruby)
29+
* [TruffleRuby](https://github.com/truffleruby/truffleruby/tree/master/spec/ruby)
3030
* [Opal](https://github.com/opal/opal/tree/master/spec)
3131
* [Artichoke](https://github.com/artichoke/spec/tree/artichoke-vendor)
3232

spec/ruby/core/array/shared/unshift.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
-> { ArraySpecs.frozen_array.send(@method) }.should raise_error(FrozenError)
5050
end
5151

52-
# https://github.com/oracle/truffleruby/issues/2772
52+
# https://github.com/truffleruby/truffleruby/issues/2772
5353
it "doesn't rely on Array#[]= so it can be overridden" do
5454
subclass = Class.new(Array) do
5555
def []=(*)

spec/ruby/core/io/readpartial_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@
9393
@rd.readpartial(0).should == ""
9494
end
9595

96+
it "raises IOError if the stream is closed and the length argument is 0" do
97+
@rd.close
98+
-> { @rd.readpartial(0) }.should raise_error(IOError, "closed stream")
99+
end
100+
96101
it "clears and returns the given buffer if the length argument is 0" do
97102
buffer = +"existing content"
98103
@rd.readpartial(0, buffer).should == buffer

spec/ruby/core/kernel/Float_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ def to_f() 1.2 end
163163
-> { @object.send(:Float, "+1.") }.should raise_error(ArgumentError)
164164
-> { @object.send(:Float, "-1.") }.should raise_error(ArgumentError)
165165
-> { @object.send(:Float, "1.e+0") }.should raise_error(ArgumentError)
166+
-> { @object.send(:Float, "1.e-2") }.should raise_error(ArgumentError)
166167
end
167168
end
168169

@@ -172,6 +173,7 @@ def to_f() 1.2 end
172173
@object.send(:Float, "+1.").should == 1.0
173174
@object.send(:Float, "-1.").should == -1.0
174175
@object.send(:Float, "1.e+0").should == 1.0
176+
@object.send(:Float, "1.e-2").should be_close(0.01, TOLERANCE)
175177
end
176178
end
177179

spec/ruby/core/kernel/shared/sprintf.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ def obj.to_str
449449

450450
it "is escaped by %" do
451451
@method.call("%%").should == "%"
452-
@method.call("%%d", 10).should == "%d"
452+
@method.call("%%d").should == "%d"
453453
end
454454
end
455455
end

spec/ruby/core/kernel/singleton_method_spec.rb

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require_relative '../../spec_helper'
22

33
describe "Kernel#singleton_method" do
4-
it "find a method defined on the singleton class" do
4+
it "finds a method defined on the singleton class" do
55
obj = Object.new
66
def obj.foo; end
77
obj.singleton_method(:foo).should be_an_instance_of(Method)
@@ -38,4 +38,48 @@ def foo
3838
e.class.should == NameError
3939
}
4040
end
41+
42+
ruby_bug "#20620", ""..."3.4" do
43+
it "finds a method defined in a module included in the singleton class" do
44+
m = Module.new do
45+
def foo
46+
:foo
47+
end
48+
end
49+
50+
obj = Object.new
51+
obj.singleton_class.include(m)
52+
53+
obj.singleton_method(:foo).should be_an_instance_of(Method)
54+
obj.singleton_method(:foo).call.should == :foo
55+
end
56+
57+
it "finds a method defined in a module prepended in the singleton class" do
58+
m = Module.new do
59+
def foo
60+
:foo
61+
end
62+
end
63+
64+
obj = Object.new
65+
obj.singleton_class.prepend(m)
66+
67+
obj.singleton_method(:foo).should be_an_instance_of(Method)
68+
obj.singleton_method(:foo).call.should == :foo
69+
end
70+
71+
it "finds a method defined in a module that an object is extended with" do
72+
m = Module.new do
73+
def foo
74+
:foo
75+
end
76+
end
77+
78+
obj = Object.new
79+
obj.extend(m)
80+
81+
obj.singleton_method(:foo).should be_an_instance_of(Method)
82+
obj.singleton_method(:foo).call.should == :foo
83+
end
84+
end
4185
end

spec/ruby/core/kernel/sprintf_spec.rb

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,52 @@
1313

1414
describe "Kernel#sprintf" do
1515
it_behaves_like :kernel_sprintf, -> format, *args {
16-
sprintf(format, *args)
16+
r = nil
17+
-> {
18+
r = sprintf(format, *args)
19+
}.should_not complain(verbose: true)
20+
r
1721
}
1822

1923
it_behaves_like :kernel_sprintf_encoding, -> format, *args {
20-
sprintf(format, *args)
24+
r = nil
25+
-> {
26+
r = sprintf(format, *args)
27+
}.should_not complain(verbose: true)
28+
r
2129
}
2230

2331
it_behaves_like :kernel_sprintf_to_str, -> format, *args {
24-
sprintf(format, *args)
32+
r = nil
33+
-> {
34+
r = sprintf(format, *args)
35+
}.should_not complain(verbose: true)
36+
r
2537
}
2638
end
2739

2840
describe "Kernel.sprintf" do
2941
it_behaves_like :kernel_sprintf, -> format, *args {
30-
Kernel.sprintf(format, *args)
42+
r = nil
43+
-> {
44+
r = Kernel.sprintf(format, *args)
45+
}.should_not complain(verbose: true)
46+
r
3147
}
3248

3349
it_behaves_like :kernel_sprintf_encoding, -> format, *args {
34-
Kernel.sprintf(format, *args)
50+
r = nil
51+
-> {
52+
r = Kernel.sprintf(format, *args)
53+
}.should_not complain(verbose: true)
54+
r
3555
}
3656

3757
it_behaves_like :kernel_sprintf_to_str, -> format, *args {
38-
Kernel.sprintf(format, *args)
58+
r = nil
59+
-> {
60+
r = Kernel.sprintf(format, *args)
61+
}.should_not complain(verbose: true)
62+
r
3963
}
4064
end

spec/ruby/core/kernel/warn_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@
112112
ruby_exe(file, options: "-rrubygems", args: "2>&1").should == "#{file}:2: warning: warn-require-warning\n"
113113
end
114114

115+
it "doesn't show the caller when the uplevel is `nil`" do
116+
w = KernelSpecs::WarnInNestedCall.new
117+
118+
-> { w.f4("foo", nil) }.should output(nil, "foo\n")
119+
end
120+
115121
guard -> { Kernel.instance_method(:tap).source_location } do
116122
it "skips <internal: core library methods defined in Ruby" do
117123
file, line = Kernel.instance_method(:tap).source_location

spec/ruby/core/module/autoload_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,21 @@ def r
718718
end
719719
end
720720

721+
it "should trigger the autoload when using `private_constant`" do
722+
@remove << :DynClass
723+
module ModuleSpecs::Autoload
724+
autoload :DynClass, fixture(__FILE__, "autoload_c.rb")
725+
private_constant :DynClass
726+
727+
ScratchPad.recorded.should be_nil
728+
729+
DynClass::C.new.loaded.should == :dynclass_c
730+
ScratchPad.recorded.should == :loaded
731+
end
732+
733+
-> { ModuleSpecs::Autoload::DynClass }.should raise_error(NameError, /private constant/)
734+
end
735+
721736
# [ruby-core:19127] [ruby-core:29941]
722737
it "does NOT raise a NameError when the autoload file did not define the constant and a module is opened with the same name" do
723738
module ModuleSpecs::Autoload

0 commit comments

Comments
 (0)