<commit_before>from ..base import BaseTopazTest


class TestEnumberable(BaseTopazTest):
    def test_first(self, space):
        w_res = space.execute("return [1, 2, 3].first")
        assert self.unwrap(space, w_res) == 1
        w_res = space.execute("return (3..5).first")
        assert self.unwrap(space, w_res) == 3
        w_res = space.execute("return [].first")
        assert w_res == space.w_nil
        w_res = space.execute("return [3, 4, 5].first(2)")
        assert self.unwrap(space, w_res) == [3, 4]
        w_res = space.execute("return (3..5).first(2)")
        assert self.unwrap(space, w_res) == [3, 4]
        w_res = space.execute("""
        class TestFirst
          include Enumerable
          
          def each(&block)
            yield 2
            yield 1
          end
        end
        return TestFirst.new.first
        """)
        assert self.unwrap(space, w_res) == 2

    def test_inject(self, space):
        w_res = space.execute("""
        return (5..10).inject(1) do |prod, n|
            prod * n
        end
        """)
        assert space.int_w(w_res) == 151200

        w_res = space.execute("""
        return (1..10).inject(0) do |sum, n|
            sum + n
        end
        """)
        assert space.int_w(w_res) == 55

    def test_reduce(self, space):
        w_res = space.execute("""
        return [1, 2, 4, 8].reduce(0) do |accum, cur|
            accum + cur
        end<commit_msg># remove not needed tests<commit_after>from ..base import BaseTopazTest


class TestEnumberable(BaseTopazTest):
    def test_inject(self, space):
        w_res = space.execute("""
        return (5..10).inject(1) do |prod, n|
            prod * n
        end
        """)
        assert space.int_w(w_res) == 151200

        w_res = space.execute("""
        return (1..10).inject(0) do |sum, n|
            sum + n
        end
        """)
        assert space.int_w(w_res) == 55

    def test_reduce(self, space):
        w_res = space.execute("""
        return [1, 2, 4, 8].reduce(0) do |accum, cur|
            accum + cur
        end
{'fraction_non_alphanumeric': 0.13793103448275862, 'fraction_numerical': 0.03017241379310345, 'mean_word_length': 1.7705570291777188, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3496593', 'n_tokens_mistral': 720, 'n_tokens_neox': 679, 'n_words': 168}