<commit_before>
#
# specifying flor
#
# Fri Nov 17 06:01:34 JST 2017
#

require 'spec_helper'


describe 'Flor procedures' do

  before :each do

    @executor = Flor::TransientExecutor.new
  end

  describe 'reduce' do

    it 'reduces with a func' do

      r = @executor.launch(
        %q{
          reduce [ '0', 1, 'b', 3 ]
            def r x
              r + x
        })

      expect(r['point']).to eq('terminated')
      expect(r['payload']['ret']).to eq('01b3')
    end

    it 'reduces with a proc' do

      r = @executor.launch(
        %q{
          reduce [ '0', 1, 'b', 3, '3f' ] v.+
        })

      expect(r['point']).to eq('terminated')
      expect(r['payload']['ret']).to eq('01b33f')
    end
  end
end
<commit_msg>Add "reduce" specs<commit_after>
#
# specifying flor
#
# Fri Nov 17 06:01:34 JST 2017
#

require 'spec_helper'


describe 'Flor procedures' do

  before :each do

    @executor = Flor::TransientExecutor.new
  end

  describe 'reduce' do

    it 'reduces with a func' do

      r = @executor.launch(
        %q{
          reduce [ '0', 1, 'b', 3 ]
            def r x
              r + x
        })

      expect(r['point']).to eq('terminated')
      expect(r['payload']['ret']).to eq('01b3')
    end

    it 'reduces with a func and a start value' do

      r = @executor.launch(
        %q{
          reduce [ 0, 1, 2, 3 ] 7
            def r x \ r + x
        })

      expect(r['point']).to eq('terminated')
      expect(r['payload']['ret']).to eq(13)
    end

    it 'reduces with a func and a start value' do

      r = @executor.launch(
        %q{
          reduce 7 [ 1, 2, 3, 4 ]
            def r x \ r + x
        })

      expect(r['point']).to eq('terminated')
      expect(r['payload']['ret']).to eq(17)
    end

    it 'reduces with a proc' do

      r = @executor.launch(
        %q{
          reduce [ '0', 1, 'b', 3, '3f' ] v.+
        })

      expect(r['point']).to eq('terminated')
      expect(r['payload']['ret']).to eq('01b33f')
    end

    it 'reduces with a proc and a start value' do

      r = @executor.launch(
        %q{
          reduce 4 [ 1, 2, 3 ] v.+
        })

      expect(r['point']).to eq('terminated')
      expect(r['payload']['ret']).to eq(10)
    end
  end
end

{'fraction_non_alphanumeric': 0.1602136181575434, 'fraction_numerical': 0.03204272363150868, 'mean_word_length': 1.8170426065162908, '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': '5077860', 'n_tokens_mistral': 880, 'n_tokens_neox': 785, 'n_words': 226}