mutant 0.8.11 → 0.8.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +1 -0
  3. data/Changelog.md +29 -3
  4. data/README.md +2 -0
  5. data/config/flay.yml +1 -1
  6. data/lib/mutant.rb +6 -0
  7. data/lib/mutant/ast/meta/send.rb +26 -0
  8. data/lib/mutant/ast/regexp/transformer/direct.rb +1 -0
  9. data/lib/mutant/env/bootstrap.rb +7 -2
  10. data/lib/mutant/meta/example/dsl.rb +8 -0
  11. data/lib/mutant/mutator/node/generic.rb +52 -8
  12. data/lib/mutant/mutator/node/regexp.rb +0 -11
  13. data/lib/mutant/mutator/node/regexp/alternation_meta.rb +21 -0
  14. data/lib/mutant/mutator/node/regexp/capture_group.rb +26 -0
  15. data/lib/mutant/mutator/node/regexp/character_type.rb +29 -0
  16. data/lib/mutant/mutator/node/regexp/end_of_line_anchor.rb +21 -0
  17. data/lib/mutant/mutator/node/regexp/end_of_string_or_before_end_of_line_anchor.rb +21 -0
  18. data/lib/mutant/mutator/node/regexp/greedy_zero_or_more.rb +25 -0
  19. data/lib/mutant/mutator/node/send.rb +20 -1
  20. data/lib/mutant/reporter/cli.rb +2 -0
  21. data/lib/mutant/version.rb +1 -1
  22. data/lib/mutant/zombifier.rb +6 -1
  23. data/meta/regexp.rb +8 -30
  24. data/meta/regexp/character_types.rb +20 -0
  25. data/meta/regexp/regexp_alternation_meta.rb +11 -0
  26. data/meta/regexp/regexp_bol_anchor.rb +1 -6
  27. data/meta/regexp/regexp_bos_anchor.rb +2 -12
  28. data/meta/regexp/regexp_capture_group.rb +17 -0
  29. data/meta/regexp/regexp_eol_anchor.rb +8 -0
  30. data/meta/regexp/regexp_eos_anchor.rb +6 -0
  31. data/meta/regexp/regexp_eos_ob_eol_anchor.rb +8 -0
  32. data/meta/regexp/regexp_greedy_zero_or_more.rb +10 -0
  33. data/meta/regexp/regexp_root_expression.rb +1 -6
  34. data/meta/send.rb +65 -0
  35. data/mutant.gemspec +2 -2
  36. data/spec/integrations.yml +0 -21
  37. data/spec/support/shared_context.rb +0 -13
  38. data/spec/support/warnings.yml +1 -1
  39. data/spec/unit/mutant/actor/mailbox_spec.rb +0 -3
  40. data/spec/unit/mutant/ast/meta/send/proc_predicate_spec.rb +28 -0
  41. data/spec/unit/mutant/ast/regexp_spec.rb +8 -3
  42. data/spec/unit/mutant/cli_spec.rb +0 -1
  43. data/spec/unit/mutant/context_spec.rb +0 -7
  44. data/spec/unit/mutant/env_spec.rb +2 -17
  45. data/spec/unit/mutant/expression_spec.rb +0 -2
  46. data/spec/unit/mutant/matcher/compiler_spec.rb +0 -2
  47. data/spec/unit/mutant/matcher/method/instance_spec.rb +0 -2
  48. data/spec/unit/mutant/matcher/method/singleton_spec.rb +1 -2
  49. data/spec/unit/mutant/meta/example/dsl_spec.rb +16 -0
  50. data/spec/unit/mutant/mutation_spec.rb +0 -3
  51. data/spec/unit/mutant/mutator_spec.rb +0 -2
  52. data/spec/unit/mutant/parallel/master_spec.rb +0 -3
  53. data/spec/unit/mutant/parallel/worker_spec.rb +0 -1
  54. data/spec/unit/mutant/registry_spec.rb +3 -5
  55. data/spec/unit/mutant/reporter/cli/tput_spec.rb +1 -1
  56. data/spec/unit/mutant/result/env_spec.rb +0 -5
  57. data/spec/unit/mutant/result/mutation_spec.rb +1 -13
  58. data/spec/unit/mutant/runner_spec.rb +3 -16
  59. data/spec/unit/mutant/selector/expression_spec.rb +0 -1
  60. data/spec/unit/mutant/subject_spec.rb +1 -6
  61. metadata +24 -9
@@ -9,6 +9,8 @@ module Mutant
9
9
  # @param [IO] output
10
10
  #
11
11
  # @return [Reporter::CLI]
12
+ #
13
+ # :reek:ManualDispatch
12
14
  def self.build(output)
13
15
  tput = Tput.detect
14
16
  tty = output.respond_to?(:tty?) && output.tty?
@@ -1,4 +1,4 @@
1
1
  module Mutant
2
2
  # Current mutant version
3
- VERSION = '0.8.11'.freeze
3
+ VERSION = '0.8.12'.freeze
4
4
  end # Mutant
@@ -38,6 +38,11 @@ module Mutant
38
38
 
39
39
  private
40
40
 
41
+ # Original require method
42
+ #
43
+ # @return [Method]
44
+ attr_reader :original
45
+
41
46
  # Run zombifier
42
47
  #
43
48
  # @return [undefined]
@@ -61,7 +66,7 @@ module Mutant
61
66
  # true if successful and false if feature already loaded
62
67
  def require(logical_name)
63
68
  logical_name = logical_name.to_s
64
- loaded = @original.call(logical_name)
69
+ loaded = original.call(logical_name)
65
70
  return loaded unless include?(logical_name)
66
71
  @zombified << logical_name
67
72
  zombify(find(logical_name))
@@ -2,56 +2,39 @@ Mutant::Meta::Example.add :regexp do
2
2
  source '/foo/'
3
3
 
4
4
  singleton_mutations
5
-
6
- # match all inputs
7
- mutation '//'
8
-
9
- # match no input
10
- mutation '/nomatch\A/'
5
+ regexp_mutations
11
6
  end
12
7
 
13
8
  Mutant::Meta::Example.add :regexp do
14
9
  source '/#{foo.bar}n/'
15
10
 
16
11
  singleton_mutations
12
+ regexp_mutations
13
+
17
14
  mutation '/#{foo}n/'
18
15
  mutation '/#{self.bar}n/'
19
16
  mutation '/#{nil}n/'
20
17
  mutation '/#{self}n/'
21
-
22
- # match all inputs
23
- mutation '//'
24
-
25
- # match no input
26
- mutation '/nomatch\A/'
27
18
  end
28
19
 
29
20
  Mutant::Meta::Example.add :regexp do
30
21
  source '/#{foo}/'
31
22
 
32
23
  singleton_mutations
24
+ regexp_mutations
25
+
33
26
  mutation '/#{self}/'
34
27
  mutation '/#{nil}/'
35
-
36
- # match all inputs
37
- mutation '//'
38
-
39
- # match no input
40
- mutation '/nomatch\A/'
41
28
  end
42
29
 
43
30
  Mutant::Meta::Example.add :regexp do
44
31
  source '/#{foo}#{nil}/'
45
32
 
46
33
  singleton_mutations
34
+ regexp_mutations
35
+
47
36
  mutation '/#{nil}#{nil}/'
48
37
  mutation '/#{self}#{nil}/'
49
-
50
- # match all inputs
51
- mutation '//'
52
-
53
- # match no input
54
- mutation '/nomatch\A/'
55
38
  end
56
39
 
57
40
  Mutant::Meta::Example.add :regexp do
@@ -85,12 +68,7 @@ Mutant::Meta::Example.add :regexp do
85
68
  source '/(?(1)(foo)(bar))/'
86
69
 
87
70
  singleton_mutations
88
-
89
- # match all inputs
90
- mutation '//'
91
-
92
- # match no input
93
- mutation '/nomatch\A/'
71
+ regexp_mutations
94
72
  end
95
73
 
96
74
  Pathname
@@ -0,0 +1,20 @@
1
+ mutations = {
2
+ [:regexp_digit_type, '/\d/'] => [:regexp_nondigit_type, '/\D/'],
3
+ [:regexp_hex_type, '/\h/'] => [:regexp_nonhex_type, '/\H/'],
4
+ [:regexp_space_type, '/\s/'] => [:regexp_nonspace_type, '/\S/'],
5
+ [:regexp_word_boundary_anchor, '/\b/'] => [:regexp_nonword_boundary_anchor, '/\B/'],
6
+ [:regexp_word_type, '/\w/'] => [:regexp_nonword_type, '/\W/']
7
+ }
8
+
9
+ mutations = mutations.merge(mutations.invert)
10
+
11
+ mutations.each do |(source_type, source_mutation), (_, regexp_mutation)|
12
+ Mutant::Meta::Example.add source_type do
13
+ source(source_mutation)
14
+
15
+ singleton_mutations
16
+ regexp_mutations
17
+
18
+ mutation(regexp_mutation)
19
+ end
20
+ end
@@ -0,0 +1,11 @@
1
+ Mutant::Meta::Example.add :regexp_alternation_meta do
2
+ source '/\A(foo|bar|baz)\z/'
3
+
4
+ singleton_mutations
5
+ regexp_mutations
6
+
7
+ mutation '/\A(foo|bar)\z/'
8
+ mutation '/\A(foo|baz)\z/'
9
+ mutation '/\A(bar|baz)\z/'
10
+ mutation '/\A(?:foo|bar|baz)\z/'
11
+ end
@@ -2,12 +2,7 @@ Mutant::Meta::Example.add :regexp_bol_anchor do
2
2
  source '/^/'
3
3
 
4
4
  singleton_mutations
5
-
6
- # match all inputs
7
- mutation '//'
8
-
9
- # match no input
10
- mutation '/nomatch\A/'
5
+ regexp_mutations
11
6
 
12
7
  mutation '/\\A/'
13
8
  end
@@ -2,25 +2,15 @@ Mutant::Meta::Example.add :regexp_bos_anchor do
2
2
  source '/\A/'
3
3
 
4
4
  singleton_mutations
5
-
6
- # match all inputs
7
- mutation '//'
8
-
9
- # match no input
10
- mutation '/nomatch\A/'
5
+ regexp_mutations
11
6
  end
12
7
 
13
8
  Mutant::Meta::Example.add :regexp_bos_anchor do
14
9
  source '/^#{a}/'
15
10
 
16
11
  singleton_mutations
12
+ regexp_mutations
17
13
 
18
14
  mutation '/^#{nil}/'
19
15
  mutation '/^#{self}/'
20
-
21
- # match all inputs
22
- mutation '//'
23
-
24
- # match no input
25
- mutation '/nomatch\A/'
26
16
  end
@@ -0,0 +1,17 @@
1
+ Mutant::Meta::Example.add :regexp_capture_group do
2
+ source '/()/'
3
+
4
+ singleton_mutations
5
+ regexp_mutations
6
+ end
7
+
8
+ Mutant::Meta::Example.add :regexp_capture_group do
9
+ source '/(foo|bar)/'
10
+
11
+ singleton_mutations
12
+ regexp_mutations
13
+
14
+ mutation '/(?:foo|bar)/'
15
+ mutation '/(foo)/'
16
+ mutation '/(bar)/'
17
+ end
@@ -0,0 +1,8 @@
1
+ Mutant::Meta::Example.add :regexp_eol_anchor do
2
+ source '/$/'
3
+
4
+ singleton_mutations
5
+ regexp_mutations
6
+
7
+ mutation '/\z/'
8
+ end
@@ -0,0 +1,6 @@
1
+ Mutant::Meta::Example.add :regexp_eos_anchor do
2
+ source '/\z/'
3
+
4
+ singleton_mutations
5
+ regexp_mutations
6
+ end
@@ -0,0 +1,8 @@
1
+ Mutant::Meta::Example.add :regexp_eos_ob_eol_anchor do
2
+ source '/\Z/'
3
+
4
+ singleton_mutations
5
+ regexp_mutations
6
+
7
+ mutation '/\z/'
8
+ end
@@ -0,0 +1,10 @@
1
+ Mutant::Meta::Example.add :regexp_greedy_zero_or_more do
2
+ source '/\d*/'
3
+
4
+ singleton_mutations
5
+ regexp_mutations
6
+
7
+ mutation '/\d/'
8
+ mutation '/\d+/'
9
+ mutation '/\D*/'
10
+ end
@@ -2,12 +2,7 @@ Mutant::Meta::Example.add :regexp_root_expression do
2
2
  source '/^/'
3
3
 
4
4
  singleton_mutations
5
-
6
- # match all inputs
7
- mutation '//'
8
-
9
- # match no input
10
- mutation '/nomatch\A/'
5
+ regexp_mutations
11
6
 
12
7
  mutation '/\\A/'
13
8
  end
@@ -128,6 +128,13 @@ Mutant::Meta::Example.add :send do
128
128
  mutation 'each'
129
129
  end
130
130
 
131
+ Mutant::Meta::Example.add :send do
132
+ source 'flat_map'
133
+
134
+ singleton_mutations
135
+ mutation 'map'
136
+ end
137
+
131
138
  Mutant::Meta::Example.add :send do
132
139
  source 'foo.to_s'
133
140
 
@@ -681,3 +688,61 @@ Mutant::Meta::Example.add :send do
681
688
  singleton_mutations
682
689
  mutation 'first'
683
690
  end
691
+
692
+ Mutant::Meta::Example.add :send do
693
+ source '!!foo'
694
+
695
+ singleton_mutations
696
+ mutation '!foo'
697
+ mutation '!self'
698
+ mutation '!!self'
699
+ mutation 'foo'
700
+ end
701
+
702
+ Mutant::Meta::Example.add :send do
703
+ source '!foo'
704
+
705
+ singleton_mutations
706
+ mutation 'foo'
707
+ mutation '!self'
708
+ end
709
+
710
+ Mutant::Meta::Example.add :send do
711
+ source '!foo&.!'
712
+
713
+ singleton_mutations
714
+ mutation 'foo&.!'
715
+ mutation '!self'
716
+ mutation '!foo'
717
+ mutation '!self&.!'
718
+ mutation '!(!foo)'
719
+ end
720
+
721
+ Mutant::Meta::Example.add :send do
722
+ source 'custom.proc { }'
723
+
724
+ singleton_mutations
725
+ mutation 'custom.proc'
726
+ mutation 'custom { }'
727
+ mutation 'self.proc { }'
728
+ mutation 'custom.proc { raise }'
729
+ end
730
+
731
+ Mutant::Meta::Example.add :send do
732
+ source 'proc { }'
733
+
734
+ singleton_mutations
735
+ mutation 'proc'
736
+ mutation 'proc { raise }'
737
+ mutation 'lambda { }'
738
+ end
739
+
740
+ Mutant::Meta::Example.add :send do
741
+ source 'Proc.new { }'
742
+
743
+ singleton_mutations
744
+ mutation 'Proc.new'
745
+ mutation 'self.new { }'
746
+ mutation 'Proc.new { raise }'
747
+ mutation 'lambda { }'
748
+ end
@@ -21,7 +21,7 @@ Gem::Specification.new do |gem|
21
21
 
22
22
  gem.required_ruby_version = '>= 2.1'
23
23
 
24
- gem.add_runtime_dependency('parser', '~> 2.3.0', '>= 2.3.0.2')
24
+ gem.add_runtime_dependency('parser', '~> 2.3.1', '>= 2.3.1.4')
25
25
  gem.add_runtime_dependency('ast', '~> 2.2')
26
26
  gem.add_runtime_dependency('diff-lcs', '~> 1.2')
27
27
  gem.add_runtime_dependency('parallel', '~> 1.3')
@@ -37,7 +37,7 @@ Gem::Specification.new do |gem|
37
37
  gem.add_runtime_dependency('concord', '~> 0.1.5')
38
38
  gem.add_runtime_dependency('regexp_parser', '~> 0.3.6')
39
39
 
40
- gem.add_development_dependency('devtools', '~> 0.1.4')
40
+ gem.add_development_dependency('devtools', '~> 0.1.12')
41
41
  gem.add_development_dependency('bundler', '~> 1.10')
42
42
  gem.add_development_dependency('ffi', '~> 1.9.6')
43
43
  end
@@ -21,14 +21,10 @@
21
21
  - core/encoding/invalid_byte_sequence_error/incomplete_input_spec.rb
22
22
  - core/encoding/invalid_byte_sequence_error/readagain_bytes_spec.rb
23
23
  - core/encoding/replicate_spec.rb
24
- - core/file/expand_path_spec.rb
25
24
  - core/io/gets_spec.rb
26
25
  - core/io/read_spec.rb
27
26
  - core/io/shared/gets_ascii.rb
28
27
  - core/io/write_spec.rb
29
- - core/marshal/dump_spec.rb
30
- - core/marshal/fixtures/marshal_data.rb
31
- - core/marshal/shared/load.rb
32
28
  - core/random/bytes_spec.rb
33
29
  - core/regexp/match_spec.rb
34
30
  - core/regexp/shared/new_ascii.rb
@@ -60,29 +56,12 @@
60
56
  - core/time/_load_spec.rb
61
57
  - language/regexp/encoding_spec.rb
62
58
  - language/string_spec.rb
63
- - library/digest/md5/shared/constants.rb
64
- - library/digest/md5/shared/sample.rb
65
- - library/digest/sha1/shared/constants.rb
66
- - library/digest/sha256/shared/constants.rb
67
- - library/digest/sha384/shared/constants.rb
68
- - library/digest/sha512/shared/constants.rb
69
59
  - library/openssl/shared/constants.rb
70
60
  - library/socket/basicsocket/recv_spec.rb
71
61
  - library/socket/socket/gethostbyname_spec.rb
72
62
  - library/stringscanner/getch_spec.rb
73
63
  - library/stringscanner/shared/get_byte.rb
74
- - library/zlib/deflate/deflate_spec.rb
75
- - library/zlib/deflate/set_dictionary_spec.rb
76
- - library/zlib/gzipreader/each_byte_spec.rb
77
- - library/zlib/gzipreader/eof_spec.rb
78
- - library/zlib/gzipreader/getc_spec.rb
79
- - library/zlib/gzipreader/pos_spec.rb
80
- - library/zlib/gzipreader/read_spec.rb
81
- - library/zlib/gzipreader/rewind_spec.rb
82
- - library/zlib/inflate/append_spec.rb
83
- - library/zlib/inflate/inflate_spec.rb
84
64
  - library/zlib/inflate/set_dictionary_spec.rb
85
- - library/zlib/zstream/flush_next_out_spec.rb
86
65
  - optional/capi/encoding_spec.rb
87
66
  - optional/capi/string_spec.rb
88
67
  '#<RegexpError: invalid multibyte escape: /\xAA/>':
@@ -37,13 +37,8 @@ module SharedContext
37
37
  let(:env) { instance_double(Mutant::Env, config: config, subjects: [subject_a], mutations: mutations) }
38
38
  let(:job_a) { Mutant::Parallel::Job.new(index: 0, payload: mutation_a) }
39
39
  let(:job_b) { Mutant::Parallel::Job.new(index: 1, payload: mutation_b) }
40
- let(:job_a_result) { Mutant::Runner::JobResult.new(job: job_a, result: mutation_a_result) }
41
- let(:job_b_result) { Mutant::Runner::JobResult.new(job: job_b, result: mutation_b_result) }
42
40
  let(:test_a) { instance_double(Mutant::Test, identification: 'test-a') }
43
- let(:test_b) { instance_double(Mutant::Test, identification: 'test-b') }
44
41
  let(:output) { StringIO.new }
45
- let(:matchable_scopes) { instance_double(Array, length: 10) }
46
- let(:message_sequence) { FakeActor::MessageSequence.new }
47
42
  let(:mutations) { [mutation_a, mutation_b] }
48
43
  let(:mutation_a_node) { s(:false) }
49
44
  let(:mutation_b_node) { s(:nil) }
@@ -126,13 +121,5 @@ module SharedContext
126
121
  mutation_results: [mutation_a_result, mutation_b_result]
127
122
  )
128
123
  end
129
-
130
- let(:empty_subject_a_result) do
131
- subject_a_result.with(mutation_results: [])
132
- end
133
-
134
- let(:partial_subject_a_result) do
135
- subject_a_result.with(mutation_results: [mutation_a_result])
136
- end
137
124
  end
138
125
  end # SharedContext
@@ -1,4 +1,4 @@
1
1
  ---
2
- - 'lib/parser/lexer.rb:10791: warning: assigned but unused variable - testEof'
2
+ - 'lib/parser/lexer.rb:10922: warning: assigned but unused variable - testEof'
3
3
  - 'lib/parser/source/rewriter.rb:392: warning: assigned but unused variable - begin_pos'
4
4
  - 'lib/regexp_parser/scanner.rb:1646: warning: assigned but unused variable - testEof'
@@ -10,9 +10,6 @@ RSpec.describe Mutant::Actor::Mailbox do
10
10
  describe '.new' do
11
11
  subject { described_class.new }
12
12
 
13
- let(:object) { described_class.new }
14
- let(:thread) { instance_double(Thread) }
15
-
16
13
  its(:sender) { should eql(Mutant::Actor::Sender.new(condition_variable, mutex, [])) }
17
14
  its(:receiver) { should eql(Mutant::Actor::Receiver.new(condition_variable, mutex, [])) }
18
15