Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: cee438ee59ae
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 68cbdcada675
Choose a head ref
  • 3 commits
  • 2 files changed
  • 2 contributors

Commits on Jan 11, 2018

  1. Implement Kernel.yield_self

    For more information, please see feature #6721.
    nomadium committed Jan 11, 2018
    Copy the full SHA
    02a241e View commit details
  2. Copy the full SHA
    f54072b View commit details

Commits on Jan 16, 2018

  1. Merge pull request #4906 from nomadium/implement-kernel-yield-self

    Implement Kernel.yield_self
    enebo authored Jan 16, 2018
    Copy the full SHA
    68cbdca View commit details
Showing with 20 additions and 0 deletions.
  1. +10 −0 core/src/main/java/org/jruby/RubyKernel.java
  2. +10 −0 test/mri/ruby/test_object.rb
10 changes: 10 additions & 0 deletions core/src/main/java/org/jruby/RubyKernel.java
Original file line number Diff line number Diff line change
@@ -1192,6 +1192,16 @@ public static IRubyObject warn(ThreadContext context, IRubyObject recv, IRubyObj
return context.nil;
}

@JRubyMethod(module = true)
public static IRubyObject yield_self(ThreadContext context, IRubyObject recv, Block block) {
if (block.isGiven()) {
return block.yield(context, recv);
} else {
SizeFn enumSizeFn = RubyArray.newArray(context.runtime, context.nil).enumLengthFn();
return RubyEnumerator.enumeratorizeWithSize(context, recv, "yield_self", enumSizeFn);
}
}

@JRubyMethod(module = true, visibility = PRIVATE)
public static IRubyObject set_trace_func(ThreadContext context, IRubyObject recv, IRubyObject trace_func, Block block) {
if (trace_func.isNil()) {
10 changes: 10 additions & 0 deletions test/mri/ruby/test_object.rb
Original file line number Diff line number Diff line change
@@ -18,6 +18,16 @@ def test_itself
assert_same(object, object.itself, feature6373)
end

def test_yield_self
feature = '[ruby-core:46320] [Feature #6721]'
object = Object.new
assert_same(self, object.yield_self {self}, feature)
assert_same(object, object.yield_self {|x| break x}, feature)
enum = object.yield_self
assert_instance_of(Enumerator, enum)
assert_equal(1, enum.size)
end

def test_dup
assert_equal 1, 1.dup
assert_equal true, true.dup