Sha256: 869b3e6e81f5a9e6c3fa0250b4d09c652327b6caf64e0cac45aa5d5098626d74

Contents?: true

Size: 844 Bytes

Versions: 7

Compression:

Stored size: 844 Bytes

Contents

#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |
#   |_|\___||___/\__|
#
# for lib/facets/io/write.rb

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

class TestSymbolToProc < 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

7 entries across 7 versions & 1 rubygems

Version Path
facets-2.0.5 test/unit/symbol/test_to_proc.rb
facets-2.0.3 test/unit/symbol/test_to_proc.rb
facets-2.0.4 test/unit/symbol/test_to_proc.rb
facets-2.1.2 test/unit/symbol/test_to_proc.rb
facets-2.1.0 test/unit/symbol/test_to_proc.rb
facets-2.1.1 test/unit/symbol/test_to_proc.rb
facets-2.1.3 test/unit/symbol/test_to_proc.rb