git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
eregon 2018-08-21 22:01:34 +00:00
parent 2aefb19888
commit b448f23e21
6 changed files with 51 additions and 56 deletions

View File

@ -37,6 +37,9 @@ Lint/LiteralAsCondition:
Lint/UnneededRequireStatement: Lint/UnneededRequireStatement:
Enabled: false Enabled: false
Lint/UnneededSplatExpansion:
Enabled: false
Lint/UnifiedInteger: Lint/UnifiedInteger:
Enabled: false Enabled: false
@ -52,7 +55,6 @@ Lint/UselessAssignment:
Lint/UselessComparison: Lint/UselessComparison:
Enabled: false Enabled: false
# The cop registers too many false positives to `.should == something`
Lint/Void: Lint/Void:
Enabled: false Enabled: false
@ -65,11 +67,32 @@ Lint/EmptyWhen:
- language/case_spec.rb - language/case_spec.rb
- optional/capi/spec_helper.rb - optional/capi/spec_helper.rb
Lint/FormatParameterMismatch:
Exclude:
- 'core/kernel/shared/sprintf.rb'
- 'core/string/modulo_spec.rb'
Lint/NestedMethodDefinition: Lint/NestedMethodDefinition:
Exclude: Exclude:
- language/def_spec.rb - language/def_spec.rb
- language/fixtures/def.rb - language/fixtures/def.rb
Lint/UnreachableCode:
Exclude:
- 'core/enumerator/lazy/fixtures/classes.rb'
- 'core/kernel/catch_spec.rb'
- 'core/kernel/throw_spec.rb'
- 'language/break_spec.rb'
- 'language/fixtures/break.rb'
- 'language/fixtures/break_lambda_toplevel.rb'
- 'language/fixtures/break_lambda_toplevel_block.rb'
- 'language/fixtures/break_lambda_toplevel_method.rb'
- 'language/fixtures/return.rb'
- 'language/next_spec.rb'
- 'language/return_spec.rb'
- 'optional/capi/kernel_spec.rb'
- 'shared/kernel/raise.rb'
Lint/UriRegexp: Lint/UriRegexp:
Exclude: Exclude:
- 'library/uri/regexp_spec.rb' - 'library/uri/regexp_spec.rb'

View File

@ -32,12 +32,6 @@ Lint/FloatOutOfRange:
Exclude: Exclude:
- 'core/string/modulo_spec.rb' - 'core/string/modulo_spec.rb'
# Offense count: 107
Lint/FormatParameterMismatch:
Exclude:
- 'core/kernel/shared/sprintf.rb'
- 'core/string/modulo_spec.rb'
# Offense count: 29 # Offense count: 29
Lint/HandleExceptions: Lint/HandleExceptions:
Enabled: false Enabled: false
@ -148,42 +142,6 @@ Lint/UnderscorePrefixedVariableName:
- 'core/io/popen_spec.rb' - 'core/io/popen_spec.rb'
- 'language/block_spec.rb' - 'language/block_spec.rb'
# Offense count: 90
# Cop supports --auto-correct.
Lint/UnneededSplatExpansion:
Exclude:
- 'core/array/element_reference_spec.rb'
- 'core/enumerable/fixtures/classes.rb'
- 'core/enumerable/max_by_spec.rb'
- 'core/enumerable/min_by_spec.rb'
- 'core/enumerable/minmax_by_spec.rb'
- 'core/enumerator/lazy/fixtures/classes.rb'
- 'core/file/basename_spec.rb'
- 'core/kernel/p_spec.rb'
- 'language/array_spec.rb'
- 'language/break_spec.rb'
- 'language/case_spec.rb'
- 'language/next_spec.rb'
- 'language/send_spec.rb'
- 'language/variables_spec.rb'
# Offense count: 54
Lint/UnreachableCode:
Exclude:
- 'core/enumerator/lazy/fixtures/classes.rb'
- 'core/kernel/catch_spec.rb'
- 'core/kernel/throw_spec.rb'
- 'language/break_spec.rb'
- 'language/fixtures/break.rb'
- 'language/fixtures/break_lambda_toplevel.rb'
- 'language/fixtures/break_lambda_toplevel_block.rb'
- 'language/fixtures/break_lambda_toplevel_method.rb'
- 'language/fixtures/return.rb'
- 'language/next_spec.rb'
- 'language/return_spec.rb'
- 'optional/capi/kernel_spec.rb'
- 'shared/kernel/raise.rb'
# Offense count: 7 # Offense count: 7
# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods. # Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
Lint/UselessAccessModifier: Lint/UselessAccessModifier:

View File

@ -57,7 +57,7 @@ describe "A block yielded a single" do
result.should == [{"a" => 1, "b" => 2}, {}] result.should == [{"a" => 1, "b" => 2}, {}]
end end
describe("when non-symbol keys are in a keyword arguments Hash") do describe "when non-symbol keys are in a keyword arguments Hash" do
ruby_version_is ""..."2.6" do ruby_version_is ""..."2.6" do
it "separates non-symbol keys and symbol keys" do it "separates non-symbol keys and symbol keys" do
result = m(["a" => 10, b: 2]) { |a=nil, **b| [a, b] } result = m(["a" => 10, b: 2]) { |a=nil, **b| [a, b] }

View File

@ -511,6 +511,15 @@ describe "A method" do
m(2).should == 2 m(2).should == 2
end end
evaluate <<-ruby do
def m() end
ruby
m().should be_nil
m(*[]).should be_nil
m(**{}).should be_nil
end
evaluate <<-ruby do evaluate <<-ruby do
def m(*) end def m(*) end
ruby ruby
@ -527,6 +536,8 @@ describe "A method" do
m().should == [] m().should == []
m(1).should == [1] m(1).should == [1]
m(1, 2, 3).should == [1, 2, 3] m(1, 2, 3).should == [1, 2, 3]
m(*[]).should == []
m(**{}).should == []
end end
evaluate <<-ruby do evaluate <<-ruby do
@ -561,6 +572,8 @@ describe "A method" do
m().should == {} m().should == {}
m(a: 1, b: 2).should == { a: 1, b: 2 } m(a: 1, b: 2).should == { a: 1, b: 2 }
m(*[]).should == {}
m(**{}).should == {}
lambda { m(2) }.should raise_error(ArgumentError) lambda { m(2) }.should raise_error(ArgumentError)
end end

View File

@ -13,4 +13,4 @@ specs:
5. Name the C functions 'array_spec_rb_ary_new'. 5. Name the C functions 'array_spec_rb_ary_new'.
6. Wrap the code in the optional/capi/ext/array_spec.c in 6. Wrap the code in the optional/capi/ext/array_spec.c in
'#ifdef HAVE_RB_ARY_NEW' '#ifdef HAVE_RB_ARY_NEW'
6. Attach the C function to the class using the name 'rb_ary_new' 7. Attach the C function to the class using the name 'rb_ary_new'

View File

@ -1,4 +1,4 @@
require_relative '../../spec_helper' # Require the main spec_helper.rb at the end to let `ruby ...spec.rb` work
# MRI magic to use built but not installed ruby # MRI magic to use built but not installed ruby
$extmk = false $extmk = false
@ -6,13 +6,9 @@ $extmk = false
require 'rbconfig' require 'rbconfig'
OBJDIR ||= File.expand_path("../../../ext/#{RUBY_ENGINE}/#{RUBY_VERSION}", __FILE__) OBJDIR ||= File.expand_path("../../../ext/#{RUBY_ENGINE}/#{RUBY_VERSION}", __FILE__)
mkdir_p(OBJDIR)
def extension_path
File.expand_path("../ext", __FILE__)
end
def object_path def object_path
mkdir_p(OBJDIR)
OBJDIR OBJDIR
end end
@ -20,6 +16,7 @@ def compile_extension(name)
debug = false debug = false
run_mkmf_in_process = RUBY_ENGINE == 'truffleruby' run_mkmf_in_process = RUBY_ENGINE == 'truffleruby'
ext_dir = File.expand_path("../ext", __FILE__)
ext = "#{name}_spec" ext = "#{name}_spec"
lib = "#{object_path}/#{ext}.#{RbConfig::CONFIG['DLEXT']}" lib = "#{object_path}/#{ext}.#{RbConfig::CONFIG['DLEXT']}"
ruby_header = "#{RbConfig::CONFIG['rubyhdrdir']}/ruby.h" ruby_header = "#{RbConfig::CONFIG['rubyhdrdir']}/ruby.h"
@ -31,8 +28,8 @@ def compile_extension(name)
# not found, then compile # not found, then compile
else else
case # if lib is older than headers, source or libruby, then recompile case # if lib is older than headers, source or libruby, then recompile
when mtime <= File.mtime("#{extension_path}/rubyspec.h") when mtime <= File.mtime("#{ext_dir}/rubyspec.h")
when mtime <= File.mtime("#{extension_path}/#{ext}.c") when mtime <= File.mtime("#{ext_dir}/#{ext}.c")
when mtime <= File.mtime(ruby_header) when mtime <= File.mtime(ruby_header)
when libruby_so && mtime <= File.mtime("#{RbConfig::CONFIG['libdir']}/#{libruby_so}") when libruby_so && mtime <= File.mtime("#{RbConfig::CONFIG['libdir']}/#{libruby_so}")
else else
@ -45,7 +42,7 @@ def compile_extension(name)
Dir.mkdir(tmpdir) Dir.mkdir(tmpdir)
begin begin
["rubyspec.h", "#{ext}.c"].each do |file| ["rubyspec.h", "#{ext}.c"].each do |file|
cp "#{extension_path}/#{file}", "#{tmpdir}/#{file}" cp "#{ext_dir}/#{file}", "#{tmpdir}/#{file}"
end end
Dir.chdir(tmpdir) do Dir.chdir(tmpdir) do
@ -108,8 +105,8 @@ end
def load_extension(name) def load_extension(name)
require compile_extension(name) require compile_extension(name)
rescue LoadError rescue LoadError => e
if %r{/usr/sbin/execerror ruby "\(ld 3 1 main ([/a-zA-Z0-9_\-.]+_spec\.so)"} =~ $!.message if %r{/usr/sbin/execerror ruby "\(ld 3 1 main ([/a-zA-Z0-9_\-.]+_spec\.so)"} =~ e.message
system('/usr/sbin/execerror', "#{RbConfig::CONFIG["bindir"]}/ruby", "(ld 3 1 main #{$1}") system('/usr/sbin/execerror', "#{RbConfig::CONFIG["bindir"]}/ruby", "(ld 3 1 main #{$1}")
end end
raise raise
@ -117,3 +114,7 @@ end
# Constants # Constants
CAPI_SIZEOF_LONG = [0].pack('l!').size CAPI_SIZEOF_LONG = [0].pack('l!').size
# Require the main spec_helper.rb only here so load_extension() is defined
# when running specs with `ruby ...spec.rb`
require_relative '../../spec_helper'