require 'test/unit' require 'facet/symbol/gen' require 'facet/symbol/succ' require 'facet/symbol/to_const' require 'facet/symbol/to_proc' require 'facet/symbol/to_str' require 'facet/symbol/pad' class TC_Symbol < Test::Unit::TestCase TESTCONST = 1 # gen def test_gen o = Object.new s = :class.gen( o ) assert( ! respond_to?(s) ) end # succ def test_succ assert_equal( :b, :a.succ ) assert_equal( :aab, :aaa.succ ) assert_equal( :"2", :"1".succ ) end # to_constant def test_to_const assert_equal( 1, :"TC_Symbol::TESTCONST".to_const ) end # to_proc def test_to_proc assert_instance_of(Proc, up = :upcase.to_proc ) assert_equal( "HELLO", up.call("hello") ) end # to_str def test_to_str assert_equal( "a", :a.to_str ) assert_equal( "abc", :abc.to_str ) assert_equal( '#$%', :'#$%'.to_str ) end # pad def test_pad assert_equal( :__a__, :a.pad(2) ) assert_equal( :_a_, :__a__.pad(-1) ) end end