require "test/unit" require "libpruby" class TestPRuby < Test::Unit::TestCase def test_treasure_map a = [1,2,3] assert_equal %w[1 2 3], a.treasure_map { |r| r.to_s } end def test_aarghv assert_equal AARGHV, ARGV end def test_dungbie assert_equal('hello', %w{ world hello }.dungbie) end def test_aarghray assert_equal AARGHray, Array end def test_aye assert Aye end def test_fore assert_equal 'hello', %w[hello world].fore end def test_aye? shipmates = %w{ bilbo R.Kelly } assert shipmates.aye? { |mate| mate == 'bilbo' } end def test_plunder assert_equal [], [1,2,3,4,5,6].plunder end def test_furl require "stringio" a = StringIO.new a << "foo" a.furl assert_equal "foo", a.read end def test_maroon assert_equal ['f', "", 't'], "foot".maroon(/o/) end def test_skewer assert_equal [1,2], [111,1,2,3].skewer(1..-2) end def test_blow_me_down assert_raises(AarghYeSunkMeShip) { blow_me_down } end def test_mebbe a = Object.new assert_nil a.mebbe(:lubber) def a.lubber; "ahoy!"; end assert_equal "ahoy!", a.mebbe(:lubber) end def test_me_matey? assert [].me_matey?(Array) assert ![].me_matey?(String) end def test_black_spot a = Object.new a.taint assert a.has_black_spot? assert !"".has_black_spot? end def test_savvy assert Object.savvy?(:send) assert !Object.savvy?(:afsdadsgas) end def test_ahoy assert_equal "", String.ahoy end end