<commit_before>require 'spec_helper'

describe "Transproc::Function" do
  describe "#>>" do
    it "composes named functions" do
      f1 = t(:symbolize_keys)
      f2 = t(:map_hash, user_name: :name)

      f3 = f1 >> f2

      expect(f3.to_ast).to eql(
        [
          :symbolize_keys, [],
          [
            :map_hash, [ user_name: :name ]
          ]
        ]
      )

      expect(f3['user_name' => 'Jane']).to eql(name: 'Jane')

      f4 = f3 >> t(:nest, :details, [:name])

      expect(f4.to_ast).to eql(
        [
          :symbolize_keys, [],
          [
            :map_hash, [ user_name: :name ]
          ],
          [
            :nest, [:details, [:name]]
          ]
        ]
      )

      expect(f4['user_name' => 'Jane']).to eql(details: { name: 'Jane' })
    end

    it "composes anonymous functions" do
      f1 = Transproc -> (v, m) { v * m }, 2
      f2 = Transproc -> (v) { v.to_s }

      f3 = f1 >> f2

      expect(f3.to_ast).to eql(
        [
          f1.fn, [2],
          [
            f2.fn, []
          ]
        ]
      )
    end
  end
end
<commit_msg>Make spec 1.9-compatible due to JRuby<commit_after>require 'spec_helper'

describe "Transproc::Function" do
  describe "#>>" do
    it "composes named functions" do
      f1 = t(:symbolize_keys)
      f2 = t(:map_hash, user_name: :name)

      f3 = f1 >> f2

      expect(f3.to_ast).to eql(
        [
          :symbolize_keys, [],
          [
            :map_hash, [ user_name: :name ]
          ]
        ]
      )

      expect(f3['user_name' => 'Jane']).to eql(name: 'Jane')

      f4 = f3 >> t(:nest, :details, [:name])

      expect(f4.to_ast).to eql(
        [
          :symbolize_keys, [],
          [
            :map_hash, [ user_name: :name ]
          ],
          [
            :nest, [:details, [:name]]
          ]
        ]
      )

      expect(f4['user_name' => 'Jane']).to eql(details: { name: 'Jane' })
    end

    it "composes anonymous functions" do
      # TODO: Use Transproc -> (v) { v.to_s } after release of jruby-9k
      f1 = Transproc proc { |v, m| v * m }, 2
      f2 = Transproc proc { |v| v.to_s }

      f3 = f1 >> f2

      expect(f3.to_ast).to eql(
        [
          f1.fn, [2],
          [
            f2.fn, []
          ]
        ]
      )
    end
  end
end

{'fraction_non_alphanumeric': 0.15364583333333334, 'fraction_numerical': 0.01953125, 'mean_word_length': 1.4161425576519917, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 26, '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': '3931901', 'n_tokens_mistral': 872, 'n_tokens_neox': 833, 'n_words': 172}