Sha256: 3f049b3c604f3df25cbb04d5d9cbd847393c6444068c02774ae539703232f286

Contents?: true

Size: 1.67 KB

Versions: 3

Compression:

Stored size: 1.67 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| }' }

    before do
      Mutant::Random.stub(hex_string: 'random')
    end

    let(:mutations) do
      mutations = []
      mutations << 'foo'
      mutations << 'foo { |a, b| raise }'
      mutations << 'foo { |a, srandom| }'
      mutations << 'foo { |srandom, 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

    before do
      Mutant::Random.stub(hex_string: 'random')
    end

    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 { |(srandom, b), c| }'
      mutations << 'foo { |(a, srandom), c| }'
      mutations << 'foo { |(a, b), srandom| }'
      mutations << 'foo'
      mutations << 'nil'
    end

    it_should_behave_like 'a mutator'
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mutant-0.3.0.rc4 spec/unit/mutant/mutator/node/block/mutation_spec.rb
mutant-0.3.0.rc3 spec/unit/mutant/mutator/node/block/mutation_spec.rb
mutant-0.3.0.rc2 spec/unit/mutant/mutator/node/block/mutation_spec.rb