Sha256: f6e198497a681d2760d5431a2eedb42b6b9075635d455209c6f61faf44512c40

Contents?: true

Size: 1.3 KB

Versions: 19

Compression:

Stored size: 1.3 KB

Contents

require 'test_helper'
require 'tins/xt'

if RUBY_VERSION >= "1.9"
  module Tins
    class MethodDescriptionTest < Test::Unit::TestCase
      class A
        def foo
        end

        def self.foo
        end
      end

      def test_static_nonstatic
        assert_equal 'Tins::MethodDescriptionTest::A#foo()', A.instance_method(:foo).to_s
        assert_equal '#<UnboundMethod: Tins::MethodDescriptionTest::A#foo()>', A.instance_method(:foo).inspect
        assert_equal 'Tins::MethodDescriptionTest::A.foo()', A.method(:foo).to_s
        assert_equal '#<Method: Tins::MethodDescriptionTest::A.foo()>', A.method(:foo).inspect
      end

      class B
        def foo(x, y = 1, *r, &b)
        end
      end

      def test_standard_parameters
        assert_equal 'Tins::MethodDescriptionTest::B#foo(x,y=,*r,&b)', B.instance_method(:foo).to_s
      end

      if RUBY_VERSION >= "2.0"
        eval %{
          class C
            def foo(x, k: true, &b)
            end

            def bar(x, **k, &b)
            end
          end

          def test_keyword_parameters
            assert_equal 'Tins::MethodDescriptionTest::C#foo(x,k:,&b)', C.instance_method(:foo).to_s
            assert_equal 'Tins::MethodDescriptionTest::C#bar(x,**k,&b)', C.instance_method(:bar).to_s
          end
        }
      end
    end
  end
end

Version data entries

19 entries across 18 versions & 3 rubygems

Version Path
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/tins-0.13.2/tests/method_description_test.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/tins-0.13.2/tests/method_description_test.rb
tdiary-5.0.8 vendor/bundle/ruby/2.5.0/gems/tins-0.13.2/tests/method_description_test.rb
tdiary-5.0.8 vendor/bundle/gems/tins-0.13.2/tests/method_description_test.rb
tins-1.3.0 tests/method_description_test.rb
tins-1.2.0 tests/method_description_test.rb
tins-1.1.0 tests/method_description_test.rb
tins-1.0.1 tests/method_description_test.rb
tins-1.0.0 tests/method_description_test.rb
tins-0.13.2 tests/method_description_test.rb
social_url_stats-0.0.1 vendor/ruby/1.9.1/gems/tins-0.13.1/tests/method_description_test.rb
tins-0.13.1 tests/method_description_test.rb
tins-0.13.0 tests/method_description_test.rb
tins-0.12.0 tests/method_description_test.rb
tins-0.11.0 tests/method_description_test.rb
tins-0.10.0 tests/method_description_test.rb
tins-0.9.0 tests/method_description_test.rb
tins-0.8.4 tests/method_description_test.rb
tins-0.8.3 tests/method_description_test.rb