Class: Mutant::Env Private

Inherits:
Object
  • Object
show all
Includes:
Adamantium::Flat
Defined in:
lib/mutant/env.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Abstract base class for mutant environments

Constant Summary collapse

SEMANTICS_MESSAGE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

"Fix your lib to follow normal ruby semantics!\n" \
'{Module,Class}#name should return resolvable constant name as String or nil'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.empty(world, config) ⇒ Env

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Construct minimal empty env

Parameters:

Returns:



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/mutant/env.rb', line 27

def self.empty(world, config)
  new(
    config:           config,
    integration:      Integration::Null.new(config),
    matchable_scopes: EMPTY_ARRAY,
    mutations:        EMPTY_ARRAY,
    parser:           Parser.new,
    selector:         Selector::Null.new,
    subjects:         EMPTY_ARRAY,
    world:            world
  )
end

Instance Method Details

#amount_mutationsInteger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Amount of mutations

Returns:

  • (Integer)


88
89
90
# File 'lib/mutant/env.rb', line 88

def amount_mutations
  mutations.length
end

#amount_selected_testsInteger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Amount of selected tests

Returns:

  • (Integer)


112
113
114
# File 'lib/mutant/env.rb', line 112

def amount_selected_tests
  selected_tests.length
end

#amount_subjectsInteger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Amount of selected subjects

Returns:

  • (Integer)


104
105
106
# File 'lib/mutant/env.rb', line 104

def amount_subjects
  subjects.length
end

#amount_total_testsInteger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Amount of tests reachable by integration

Returns:

  • (Integer)


96
97
98
# File 'lib/mutant/env.rb', line 96

def amount_total_tests
  integration.all_tests.length
end

#kill(mutation) ⇒ Result::Mutation

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Kill mutation

Parameters:

Returns:



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/mutant/env.rb', line 45

def kill(mutation)
  start = Timer.now

  tests = selections.fetch(mutation.subject)

  Result::Mutation.new(
    isolation_result: run_mutation_tests(mutation, tests),
    mutation:         mutation,
    runtime:          Timer.now - start
  )
end

#selected_testsSet<Test>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Selected tests

Returns:



80
81
82
# File 'lib/mutant/env.rb', line 80

def selected_tests
  selections.values.flatten.to_set
end

#selectionsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The test selections



60
61
62
63
64
# File 'lib/mutant/env.rb', line 60

def selections
  subjects.map do |subject|
    [subject, selector.call(subject)]
  end.to_h
end

#test_subject_ratioRational

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Ratio between selected tests and subjects

Returns:

  • (Rational)


120
121
122
123
124
# File 'lib/mutant/env.rb', line 120

def test_subject_ratio
  return Rational(0) if amount_subjects.zero?

  Rational(amount_selected_tests, amount_subjects)
end

#warn(message) ⇒ self

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Emit warning

Parameters:

  • warning (String)

Returns:

  • (self)


72
73
74
75
# File 'lib/mutant/env.rb', line 72

def warn(message)
  config.reporter.warn(message)
  self
end