Class SymTblGsub::SymTblGsubTest
In: lib/sym_tbl_gsub.rb
Parent: Test::Unit::TestCase

Methods

Included Modules

SymTblGsub::Assertions

Classes and Modules

Class SymTblGsub::SymTblGsubTest::Foo

Public Instance methods

[Source]

# File lib/sym_tbl_gsub.rb, line 290
      def setup
        self.symtbl = SymTbl.new(
          :foo  => :bar,
          :bar  => [1, 2],
           3    => 'foo',
          :i    => '<<j>>',
          :j    => '<<3>>',
          :pwd  => __FILE__.to_path.dirname.to_s,
          :test => '<<pwd>>/../test'
        )
      end

[Source]

# File lib/sym_tbl_gsub.rb, line 330
      def test_array
        assert_symtbl(['<<foo>>', '<<i>>', 'barbar <<3>>' ],
                      ['bar', 'foo', 'barbar foo'])
      end

[Source]

# File lib/sym_tbl_gsub.rb, line 326
      def test_hash
        assert_symtbl({'<<foo>>' => '<<i>>', 'barbar' => '<<3>>' },
                      {'barbar'=>'foo', 'bar'=>'foo'})
      end

[Source]

# File lib/sym_tbl_gsub.rb, line 321
      def test_object
        f = Foo.new
        assert_symtbl f, f
        assert_symtbl_nil f
      end

[Source]

# File lib/sym_tbl_gsub.rb, line 343
      def test_pathlist
        pathlist = ['<<foo>>', '<<i>>'.to_path]
        ls1 = '<<bing>>/../test'.to_path + 'fixtures/autoload_tree/*.rb'
        ls2 = '<<pwd>>/../test'.to_path + 'fixtures/autoload_tree/*.rb'
        ls3 = '<<test>>'.to_path + 'fixtures/foo.{tar*,bz*}'
        pathlist << ls2 << ls1 << ls3
        my = PathList[pathlist].symtbl_gsub(symtbl).map! { |x| x.basename }
        my.all? { |x| assert_kind_of(Pathname, x) }
        ref = %w[ bar foo A.rb B.rb foo.bz2 foo.tar foo.tar.bz2 foo.tar.gz ]
        assert_equal ref.to_set, my.map!{ |x| x.to_s }.to_set
      end

[Source]

# File lib/sym_tbl_gsub.rb, line 354
      def test_pathlist_keep_pending
        pathlist = ['<<foo>>', '<<i>>'.to_path]
        pathlist << '<<bing>>/../test'.to_path + 'fixtures/autoload_tree/*.rb'
        pathlist << '<<pwd>>/../test'.to_path + 'fixtures/autoload_tree/*.rb'
        pathlist << '<<test>>'.to_path + 'fixtures/foo.{tar*,bz*}'
        pathlist = PathList[pathlist]
        assert_equal(['<<foo>>'.to_path, '<<i>>'.to_path], pathlist)
        my = pathlist.symtbl_gsub(symtbl).map! { |x| x.basename }
        my.all? { |x| assert_kind_of(Pathname, x) }
        ref = %w[ bar foo A.rb B.rb foo.bz2 foo.tar foo.tar.bz2 foo.tar.gz ]
        assert_equal ref.to_set, my.map!{ |x| x.to_s }.to_set
      end

[Source]

# File lib/sym_tbl_gsub.rb, line 334
      def test_pathname
        assert_symtbl('foo/<<foo>>/<<i>>'.to_path, 'foo/bar/foo'.to_path)
      end

[Source]

# File lib/sym_tbl_gsub.rb, line 337
      def test_regexp
        assert_symtbl(/<<foo>>(<<i>>)*/, /bar(foo)*/)
      end

[Source]

# File lib/sym_tbl_gsub.rb, line 301
      def test_string
        assert_symtbl '<<foo>>', 'bar'
        assert_symtbl '<<foo>><<3>> >> <<', 'barfoo >> <<'
        assert_symtbl_nil '<<<<>>>>%%><<>>^#^#'
        assert_symtbl '<<<<bar>>>>', '<<[1, 2]>>'
        assert_symtbl '%<<<<foo>>>>#', '%[1, 2]#'
        assert_symtbl "_\n\t\000_<<i>>__", "_\n\t\000_foo__"
        assert_symtbl '<<<<i>>>>', 'bar'
        assert_symtbl '<<dne>> <<foo>>', '<<dne>> bar'
      end

[Source]

# File lib/sym_tbl_gsub.rb, line 340
      def test_symbol
        assert_symtbl('<<foo>> <<i>>''<<foo>> <<i>>', 'bar foo''bar foo')
      end

[Validate]