Skip to content
This repository
tag: 1.5.0.RC3
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 25 lines (18 sloc) 0.448 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
require 'test/unit'

class TestObject19 < Test::Unit::TestCase
  def test_tap
    value = nil
    1.tap { |v| value = v }
    assert_equal 1, value

    [].tap { |v| value = v }
    assert_equal [], value

    assert_equal 1, 1.tap { }

    obj = Object.new

    assert_equal obj, obj.tap { }

    assert_equal "str", "str".tap { value = "foo" }
    assert_equal "foo", value

    assert_raises(LocalJumpError) do
      "str".tap
    end
  end
end
Something went wrong with that request. Please try again.