Sha256: f765d7e1d1fcb52d2564ab6a2a1cae95d4d248ad9fde97e2ef206316e594a26b

Contents?: true

Size: 699 Bytes

Versions: 14

Compression:

Stored size: 699 Bytes

Contents

require 'facets/symbol/to_proc'
require 'test/unit'

class Test_Symbol < Test::Unit::TestCase

  def test_to_proc
    x = (1..10).inject(&:*)
    assert_equal(3628800, x)

    x = %w{foo bar qux}.map(&:reverse)
    assert_equal(%w{oof rab xuq}, x)

    x = [1, 2, nil, 3, nil].reject(&:nil?)
    assert_equal([1, 2, 3], x)

    x = %w{ruby and world}.sort_by(&:reverse)
    assert_equal(%w{world and ruby}, x)
  end

  def test_to_proc_call
    assert_instance_of(Proc, up = :upcase.to_proc )
    assert_equal( "HELLO", up.call("hello") )
  end

  def test_to_proc_map
    q = [[1,2,3], [4,5,6], [7,8,9]].map(&:reverse)
    a = [[3, 2, 1], [6, 5, 4], [9, 8, 7]]
    assert_equal( a, q )
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
facets-2.8.4 test/core/symbol/test_to_proc.rb
facets-2.8.3 test/core/symbol/test_to_proc.rb
facets-2.8.2 test/core/symbol/test_to_proc.rb
facets-2.8.1 test/core/symbol/test_to_proc.rb
facets-2.8.0 test/core/symbol/test_to_proc.rb
facets-2.7.0 test/core/symbol/test_to_proc.rb
facets-2.6.0 test/core/symbol/test_to_proc.rb
facets-2.4.2 test/core/symbol/test_to_proc.rb
facets-2.4.4 test/core/symbol/test_to_proc.rb
facets-2.4.3 test/core/symbol/test_to_proc.rb
facets-2.4.5 test/core/symbol/test_to_proc.rb
facets-2.5.1 test/core/symbol/test_to_proc.rb
facets-2.5.0 test/core/symbol/test_to_proc.rb
facets-2.5.2 test/core/symbol/test_to_proc.rb