Sha256: e19d5f7be5c0e46e87e667bfaf2be208758e595218f2f20d797718c80dbf290a

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

require './test/helper'
require 'ludy/kernel'

class TestKernel < Test::Unit::TestCase
  class C
    def pub; 'pub'; end
    def method_missing msg, *args, &block; args.unshift(msg.to_s.upcase).join(' '); end
    private; def pri; 'pri'; end
  end
  def test_public_send
    c = C.new
    assert_equal 'pub', c.public_send(:pub)
    assert_equal 'PRI', c.public_send(:pri)
    assert_equal 'XD', c.public_send(:xd)
  end
  def test_tap
    assert_equal '11', 10.tap{|i| assert_equal '10', i.to_s}.succ.to_s
  end
  def test_if
    assert_equal  "XD", (true ).if{"XD"}
    assert false.if{"XD"}.nil?
    assert_equal "Orz", (false).if{"XD"}.else{"Orz"}
    assert_equal  "XD", (true ).if{"XD"}.else{"Orz"}
    assert_equal  "XD", (true ).if{"xd"}.upcase
    assert false.if{"xd"}.upcase.nil?
    assert_equal "OTL", (false).if{"xd"}.else{"otl"}.upcase
    assert_equal  "XD", (true ).if{"xd"}.else{"otl"}.upcase
  end
  def test_id_and_m
    assert_equal 'XD', id('XD')
    assert_equal 'Orz', 'Orz'.id
    assert_equal [1,3], [1,3].map(&m(:id))
    assert_equal [2,4], [2,4].map(&:id)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ludy-0.1.15 test/ludy/test_kernel.rb