Skip to content

Commit

Permalink
Merge branch 'master' into new_mavengem
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Aug 7, 2023
2 parents 5bee104 + 96f9c36 commit e1f03db
Show file tree
Hide file tree
Showing 74 changed files with 710 additions and 255 deletions.
1 change: 0 additions & 1 deletion lib/pom.rb
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,6 @@ def installer.ensure_required_ruby_version_met; end
# maintainers like OpenBSD (see #1989).
hack = File.join jruby_gems, 'gems', 'axiom-types-*'
(Dir[File.join(hack, '**/*')] + Dir[File.join(hack, '**/.*' )]).each do |f|
puts "F: #{f}"
FileUtils.chmod 'u+rw,go+r' rescue nil if File.file?(f)
end
end
Expand Down
7 changes: 7 additions & 0 deletions spec/ruby/command_line/dash_upper_u_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
options: '-U').should == 'UTF-8'
end

it "sets Encoding.default_internal to UTF-8 when RUBYOPT is empty or only spaces" do
ruby_exe('p Encoding.default_internal',
options: '-U', env: { 'RUBYOPT' => '' }).should == "#<Encoding:UTF-8>\n"
ruby_exe('p Encoding.default_internal',
options: '-U', env: { 'RUBYOPT' => ' ' }).should == "#<Encoding:UTF-8>\n"
end

it "does nothing different if specified multiple times" do
ruby_exe('print Encoding.default_internal.name',
options: '-U -U').should == 'UTF-8'
Expand Down
7 changes: 7 additions & 0 deletions spec/ruby/core/basicobject/instance_eval_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ def foo

end

ruby_version_is "3.3" do
it "uses the caller location as default location" do
f = Object.new
f.instance_eval("[__FILE__, __LINE__]").should == ["(eval at #{__FILE__}:#{__LINE__})", 1]
end
end

it "has access to receiver's instance variables" do
BasicObjectSpecs::IVars.new.instance_eval { @secret }.should == 99
BasicObjectSpecs::IVars.new.instance_eval("@secret").should == 99
Expand Down
16 changes: 12 additions & 4 deletions spec/ruby/core/binding/eval_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@
bind.eval("#foo\n__LINE__", "(test)", 88).should == 89
end

it "uses (eval) as __FILE__ if single argument given" do
obj = BindingSpecs::Demo.new(1)
bind = obj.get_binding
bind.eval("__FILE__").should == '(eval)'
ruby_version_is ""..."3.3" do
it "uses (eval) as __FILE__ if single argument given" do
obj = BindingSpecs::Demo.new(1)
bind = obj.get_binding
bind.eval("__FILE__").should == '(eval)'
end
end

it "uses 1 as __LINE__" do
Expand Down Expand Up @@ -104,4 +106,10 @@

bind.eval("'bar'.foo").should == "foo"
end

ruby_version_is "3.3" do
it "uses the caller location as default filename" do
binding.eval("[__FILE__, __LINE__]").should == ["(eval at #{__FILE__}:#{__LINE__})", 1]
end
end
end
4 changes: 4 additions & 0 deletions spec/ruby/core/encoding/converter/primitive_convert_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
-> { @ec.primitive_convert("","") }.should_not raise_error
end

it "raises FrozenError when the destination buffer is a frozen String" do
-> { @ec.primitive_convert("", "".freeze) }.should raise_error(FrozenError)
end

it "accepts nil for the destination byte offset" do
-> { @ec.primitive_convert("","", nil) }.should_not raise_error
end
Expand Down
2 changes: 0 additions & 2 deletions spec/ruby/core/exception/case_compare_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@
end

it "returns true if receiver is generic and arg is kind of SystemCallError" do
unknown_error_number = Errno.constants.size
e = SystemCallError.new('foo', @example_errno)
SystemCallError.===(e).should == true
end

it "returns false if receiver is generic and arg is not kind of SystemCallError" do
unknown_error_number = Errno.constants.size
e = Object.new
SystemCallError.===(e).should == false
end
Expand Down
15 changes: 15 additions & 0 deletions spec/ruby/core/false/singleton_method_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require_relative '../../spec_helper'

describe "FalseClass#singleton_method" do
ruby_version_is '3.3' do
it "raises regardless of whether FalseClass defines the method" do
proc{false.singleton_method(:foo)}.should raise_error(NameError)
begin
def false.foo; end
proc{false.singleton_method(:foo)}.should raise_error(NameError)
ensure
FalseClass.send(:remove_method, :foo)
end
end
end
end
53 changes: 42 additions & 11 deletions spec/ruby/core/kernel/eval_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,20 +159,37 @@ class Object
end
end

it "uses (eval) filename if none is provided" do
eval("__FILE__").should == "(eval)"
eval("__FILE__", binding).should == "(eval)"
eval("__FILE__", binding, "success").should == "success"
eval("eval '__FILE__', binding").should == "(eval)"
eval("eval '__FILE__', binding", binding).should == "(eval)"
eval("eval '__FILE__', binding", binding, 'success').should == '(eval)'
eval("eval '__FILE__', binding, 'success'", binding).should == 'success'
end
ruby_version_is ""..."3.3" do
it "uses (eval) filename if none is provided" do
eval("__FILE__").should == "(eval)"
eval("__FILE__", binding).should == "(eval)"
eval("__FILE__", binding, "success").should == "success"
eval("eval '__FILE__', binding").should == "(eval)"
eval("eval '__FILE__', binding", binding).should == "(eval)"
eval("eval '__FILE__', binding", binding, 'success').should == '(eval)'
eval("eval '__FILE__', binding, 'success'", binding).should == 'success'
end

it 'uses (eval) for __FILE__ and 1 for __LINE__ with a binding argument' do
eval("[__FILE__, __LINE__]", binding).should == ["(eval)", 1]
it 'uses (eval) for __FILE__ and 1 for __LINE__ with a binding argument' do
eval("[__FILE__, __LINE__]", binding).should == ["(eval)", 1]
end
end

ruby_version_is "3.3" do
it "uses (eval at __FILE__:__LINE__) if none is provided" do
eval("__FILE__").should == "(eval at #{__FILE__}:#{__LINE__})"
eval("__FILE__", binding).should == "(eval at #{__FILE__}:#{__LINE__})"
eval("__FILE__", binding, "success").should == "success"
eval("eval '__FILE__', binding").should == "(eval at (eval at #{__FILE__}:#{__LINE__}):1)"
eval("eval '__FILE__', binding", binding).should == "(eval at (eval at #{__FILE__}:#{__LINE__}):1)"
eval("eval '__FILE__', binding", binding, 'success').should == "(eval at success:1)"
eval("eval '__FILE__', binding, 'success'", binding).should == 'success'
end

it 'uses (eval at __FILE__:__LINE__) for __FILE__ and 1 for __LINE__ with a binding argument' do
eval("[__FILE__, __LINE__]", binding).should == ["(eval at #{__FILE__}:#{__LINE__})", 1]
end
end
# Found via Rubinius bug github:#149
it "does not alter the value of __FILE__ in the binding" do
first_time = EvalSpecs.call_eval
Expand Down Expand Up @@ -209,6 +226,20 @@ class Object
-> { eval("return :eval") }.call.should == :eval
end

it "returns from the method calling #eval when evaluating 'return'" do
def eval_return(n)
eval("return n*2")
end
-> { eval_return(3) }.call.should == 6
end

it "returns from the method calling #eval when evaluating 'return' in BEGIN" do
def eval_return(n)
eval("BEGIN {return n*3}")
end
-> { eval_return(4) }.call.should == 12
end

it "unwinds through a Proc-style closure and returns from a lambda-style closure in the closure chain" do
code = fixture __FILE__, "eval_return_with_lambda.rb"
ruby_exe(code).chomp.should == "a,b,c,eval,f"
Expand Down
2 changes: 1 addition & 1 deletion spec/ruby/core/module/const_get_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
-> { ConstantSpecs.const_get("CS_CONST1", false) }.should raise_error(NameError)
end

it "returns a constant whose module is defined the the toplevel" do
it "returns a constant whose module is defined the toplevel" do
ConstantSpecs.const_get("ConstantSpecsTwo::Foo").should == :cs_two_foo
ConstantSpecsThree.const_get("ConstantSpecsTwo::Foo").should == :cs_three_foo
end
Expand Down
11 changes: 11 additions & 0 deletions spec/ruby/core/module/define_method_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,17 @@ class << klass
klass.should have_public_instance_method(:baz)
end
end

it "sets the method owner for a dynamically added method with a different original owner" do
mixin_module = Module.new do
def bar; end
end

foo = Object.new
foo.singleton_class.define_method(:bar, mixin_module.instance_method(:bar))

foo.method(:bar).owner.should == foo.singleton_class
end
end

describe "passed a block" do
Expand Down
Loading

0 comments on commit e1f03db

Please sign in to comment.