<commit_before>require 'test_helper'

class FiltersTest < Haml::TestCase
  test "should be registered as filters when including Haml::Filters::Base" do
    begin
      refute Haml::Filters.defined.has_key? "bar"
      Module.new {def self.name; "Foo::Bar"; end; include Haml::Filters::Base}
      assert Haml::Filters.defined.has_key? "bar"
    ensure
      Haml::Filters.remove_filter "Bar"
    end
  end

  test "should raise error when attempting to register a defined Tilt filter" do
    begin
      assert_raises RuntimeError do
        2.times do
          Haml::Filters.register_tilt_filter "Foo"
        end
      end
    ensure
      Haml::Filters.remove_filter "Foo"
    end
  end

  test "should raise error when a Tilt filters dependencies are unavailable for extension" do
    begin
      assert_raises Haml::Error do
        Haml::Filters.register_tilt_filter "Textile"
        Haml::Filters.defined["textile"].template_class
      end
    ensure
      Haml::Filters.remove_filter "Textile"
    end
  end

  test "should raise error when a Tilt filters dependencies are unavailable for filter without extension" do
    begin
      assert_raises Haml::Error do<commit_msg>Ignore Tilt warnings in test. Fix #816<commit_after>require 'test_helper'

class FiltersTest < Haml::TestCase
  test "should be registered as filters when including Haml::Filters::Base" do
    begin
      refute Haml::Filters.defined.has_key? "bar"
      Module.new {def self.name; "Foo::Bar"; end; include Haml::Filters::Base}
      assert Haml::Filters.defined.has_key? "bar"
    ensure
      Haml::Filters.remove_filter "Bar"
    end
  end

  test "should raise error when attempting to register a defined Tilt filter" do
    begin
      assert_raises RuntimeError do
        2.times do
          Haml::Filters.register_tilt_filter "Foo"
        end
      end
    ensure
      Haml::Filters.remove_filter "Foo"
    end
  end

  test "should raise error when a Tilt filters dependencies are unavailable for extension" do
    begin
      assert_raises Haml::Error do
        # ignore warnings from Tilt
        Kernel.silence_warnings do
          Haml::Filters.register_tilt_filter "Textile"
          Haml::Filters.defined["textile"].template_class
        end
      end
    ensure
      Haml::Filters.remove_filter "Textile"
    end
  end

  test "should raise error when a Tilt filters dependencies are unavailable for filter without extension" do
    begin
      assert_raises Haml::Error do
{'fraction_non_alphanumeric': 0.0717163577759871, 'fraction_numerical': 0.00201450443190975, 'mean_word_length': 2.985553772070626, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3473819', 'n_tokens_mistral': 722, 'n_tokens_neox': 722, 'n_words': 230}