Sha256: bf1cd49d65b676c110c0215dfbae902e5757483fe1f869c9a0c9b9343960b6a4

Contents?: true

Size: 1.93 KB

Versions: 5

Compression:

Stored size: 1.93 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Mutant::Mutator, 'block' do
  context 'with block' do
    let(:source) { 'foo() { a; b }' }

    let(:mutations) do
      mutations = []
      mutations << 'foo { a }'
      mutations << 'foo { b }'
      mutations << 'foo {}'
      mutations << 'foo { raise }'
      mutations << 'foo { a; nil }'
      mutations << 'foo { nil; b }'
      mutations << 'foo'
      mutations << 'nil'
    end

    it_should_behave_like 'a mutator'
  end

  context 'with block args' do

    let(:source) { 'foo { |a, b| }' }

    let(:mutations) do
      mutations = []
      mutations << 'foo'
      mutations << 'foo { |a, b| raise }'
      mutations << 'foo { |a, b__mutant__| }'
      mutations << 'foo { |a__mutant__, b| }'
      mutations << 'foo { |a| }'
      mutations << 'foo { |b| }'
      mutations << 'foo { || }'
      mutations << 'nil'
    end

    it_should_behave_like 'a mutator'
  end

  context 'with block pattern args' do

    let(:source) { 'foo { |(a, b), c| }' }

    let(:mutations) do
      mutations = []
      mutations << 'foo { || }'
      mutations << 'foo { |a, b, c| }'
      mutations << 'foo { |(a, b), c| raise }'
      mutations << 'foo { |(a), c| }'
      mutations << 'foo { |(b), c| }'
      mutations << 'foo { |(a, b)| }'
      mutations << 'foo { |c| }'
      mutations << 'foo { |(a__mutant__, b), c| }'
      mutations << 'foo { |(a, b__mutant__), c| }'
      mutations << 'foo { |(a, b), c__mutant__| }'
      mutations << 'foo'
      mutations << 'nil'
    end

    it_should_behave_like 'a mutator'
  end

  context 'with mini block pattern arg' do

    let(:source) { 'foo { |(a)| }' }

    let(:mutations) do
      mutations = []
      mutations << 'foo { || }'
      mutations << 'foo { |a| }'
      mutations << 'foo { |(a)| raise }'
      mutations << 'foo { |(a__mutant__)| }'
      mutations << 'foo'
      mutations << 'nil'
    end

    it_should_behave_like 'a mutator'

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mutant-0.5.17 spec/unit/mutant/mutator/node/block_spec.rb
mutant-0.5.16 spec/unit/mutant/mutator/node/block_spec.rb
mutant-0.5.15 spec/unit/mutant/mutator/node/block_spec.rb
mutant-0.5.14 spec/unit/mutant/mutator/node/block_spec.rb
mutant-0.5.13 spec/unit/mutant/mutator/node/block_spec.rb