From 2dbfcb7d588ccc81987730dbf63b4aeae9143dd8 Mon Sep 17 00:00:00 2001 From: Norman Clarke Date: Mon, 1 Dec 2014 13:53:01 -0300 Subject: [PATCH] Remove some dead code from Haml::Util --- lib/haml/util.rb | 32 -------------------------------- test/util_test.rb | 21 --------------------- 2 files changed, 53 deletions(-) diff --git a/lib/haml/util.rb b/lib/haml/util.rb index f3faffbd..42206603 100644 --- a/lib/haml/util.rb +++ b/lib/haml/util.rb @@ -14,38 +14,6 @@ module Haml module Util extend self - # Computes the powerset of the given array. - # This is the set of all subsets of the array. - # - # @example - # powerset([1, 2, 3]) #=> - # Set[Set[], Set[1], Set[2], Set[3], Set[1, 2], Set[2, 3], Set[1, 3], Set[1, 2, 3]] - # @param arr [Enumerable] - # @return [Set] The subsets of `arr` - def powerset(arr) - arr.inject([Set.new].to_set) do |powerset, el| - new_powerset = Set.new - powerset.each do |subset| - new_powerset << subset - new_powerset << subset + [el] - end - new_powerset - end - end - - # Returns information about the caller of the previous method. - # - # @param entry [String] An entry in the `#caller` list, or a similarly formatted string - # @return [[String, Fixnum, (String, nil)]] An array containing the filename, line, and method name of the caller. - # The method name may be nil - def caller_info(entry = caller[1]) - info = entry.scan(/^(.*?):(-?.*?)(?::.*`(.+)')?$/).first - info[1] = info[1].to_i - # This is added by Rubinius to designate a block, but we don't care about it. - info[2].sub!(/ \{\}\Z/, '') if info[2] - info - end - # Silence all output to STDERR within a block. # # @yield A block in which no output will be printed to STDERR diff --git a/test/util_test.rb b/test/util_test.rb index 481decff..c8ef1116 100644 --- a/test/util_test.rb +++ b/test/util_test.rb @@ -3,18 +3,6 @@ require 'test_helper' class UtilTest < Haml::TestCase include Haml::Util - def test_powerset - assert_equal([[].to_set].to_set, - powerset([])) - assert_equal([[].to_set, [1].to_set].to_set, - powerset([1])) - assert_equal([[].to_set, [1].to_set, [2].to_set, [1, 2].to_set].to_set, - powerset([1, 2])) - assert_equal([[].to_set, [1].to_set, [2].to_set, [3].to_set, - [1, 2].to_set, [2, 3].to_set, [1, 3].to_set, [1, 2, 3].to_set].to_set, - powerset([1, 2, 3])) - end - def test_silence_warnings old_stderr, $stderr = $stderr, StringIO.new warn "Out" @@ -25,15 +13,6 @@ class UtilTest < Haml::TestCase $stderr = old_stderr end - def test_caller_info - assert_equal(["/tmp/foo.rb", 12, "fizzle"], caller_info("/tmp/foo.rb:12: in `fizzle'")) - assert_equal(["/tmp/foo.rb", 12, nil], caller_info("/tmp/foo.rb:12")) - assert_equal(["(haml)", 12, "blah"], caller_info("(haml):12: in `blah'")) - assert_equal(["", 12, "boop"], caller_info(":12: in `boop'")) - assert_equal(["/tmp/foo.rb", -12, "fizzle"], caller_info("/tmp/foo.rb:-12: in `fizzle'")) - assert_equal(["/tmp/foo.rb", 12, "fizzle"], caller_info("/tmp/foo.rb:12: in `fizzle {}'")) - end - def test_check_encoding_does_not_destoy_the_given_string string_with_bom = File.read(File.dirname(__FILE__) + '/templates/with_bom.haml', :encoding => Encoding::UTF_8) original = string_with_bom.dup