diff --git a/.rvmrc b/.rvmrc index 0698480..88f5835 100644 --- a/.rvmrc +++ b/.rvmrc @@ -1 +1 @@ -rvm use rbx-1.2.4@mutant --create +rvm use rbx-head@mutant --create diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..7a33a06 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +rvm: + - rbx-18mode + - rbx-19mode + +bundler_args: "--binstubs" +script: "bin/rspec spec" diff --git a/lib/mutant/implementation.rb b/lib/mutant/implementation.rb index 496719a..fe814da 100644 --- a/lib/mutant/implementation.rb +++ b/lib/mutant/implementation.rb @@ -41,7 +41,7 @@ def all_methods def all_singleton_methods constant.singleton_methods(false).delete_if {|meth_name| - meth_name == '__class_init__' }.map {|meth_name| + meth_name.to_s == '__class_init__' }.map {|meth_name| format_method(meth_name, SINGLETON_SCOPE)} end @@ -64,7 +64,7 @@ def to_s private def format_method(meth_name, method_scope_type) - class_name + method_scope_type + meth_name + class_name + method_scope_type + meth_name.to_s end end end diff --git a/lib/mutant/method.rb b/lib/mutant/method.rb index 8eec374..add61de 100644 --- a/lib/mutant/method.rb +++ b/lib/mutant/method.rb @@ -11,8 +11,8 @@ def initialize(method) super(source_file, DEFAULT_LINE) end + # TODO: Check for edge cases where just the line won't work. def match?(ast) - source_name == ast.name && source_line == ast.line end end diff --git a/lib/mutant/mutatee.rb b/lib/mutant/mutatee.rb index 690cb56..d44cc09 100644 --- a/lib/mutant/mutatee.rb +++ b/lib/mutant/mutatee.rb @@ -15,7 +15,7 @@ def initialize(implementation) def clean body.array.delete_if do |literal| - not Mutant::Literal.constants.include?(literal.class.basename) + not Mutant::Literal.constants.map(&:to_sym).include?(literal.class.basename.to_sym) end end @@ -34,11 +34,12 @@ def mutations_remaining end def ast - @ast ||= rbx_method.parse_file && marshal(rbx_method.ast) + @ast ||= rbx_method.parse_file && rbx_method.ast end def body @body ||= rbx_method.is_a?(SingletonMethod) ? ast.body.body : ast.body + end def rbx_method diff --git a/lib/mutant/random.rb b/lib/mutant/random.rb index 91c307e..547b709 100644 --- a/lib/mutant/random.rb +++ b/lib/mutant/random.rb @@ -1,6 +1,7 @@ module Mutant class Random ALLOWED_SYMBOL_CHARACTERS = Array('a'..'z') + Array('A'..'Z') + RANDOM_METHOD = Rubinius.ruby19? ? :sample : :choice def self.string ENV.fetch('RANDOM_STRING') { @@ -10,7 +11,7 @@ def self.string def self.symbol ENV.fetch('RANDOM_SYMBOL') { - Array.new(rand(50).next) { ALLOWED_SYMBOL_CHARACTERS.choice }.join + Array.new(rand(50).next) { ALLOWED_SYMBOL_CHARACTERS.send RANDOM_METHOD }.join }.to_sym end diff --git a/spec/functional/class_spec.rb b/spec/functional/class_spec.rb index 145901a..d267684 100644 --- a/spec/functional/class_spec.rb +++ b/spec/functional/class_spec.rb @@ -12,6 +12,7 @@ def alphabet_range; 'a'..'k' end end """ write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe Thing do diff --git a/spec/functional/instance_method/array_spec.rb b/spec/functional/instance_method/array_spec.rb index a009d05..21a4387 100644 --- a/spec/functional/instance_method/array_spec.rb +++ b/spec/functional/instance_method/array_spec.rb @@ -16,6 +16,7 @@ def to_a context 'with an expectation that the array is [1,2,3]' do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing#to_a' do @@ -33,6 +34,7 @@ def to_a context 'with an expectation that the array responds to length' do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing#to_a' do diff --git a/spec/functional/instance_method/boolean_spec.rb b/spec/functional/instance_method/boolean_spec.rb index e99eb3a..c39b499 100644 --- a/spec/functional/instance_method/boolean_spec.rb +++ b/spec/functional/instance_method/boolean_spec.rb @@ -16,6 +16,7 @@ def alive? context 'with an expectation that the return value is true' do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing#alive?' do @@ -33,6 +34,7 @@ def alive? context 'with an expectation that the return value is true or false' do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing#alive?' do @@ -62,6 +64,7 @@ def alive? context 'with an expectation that the return value is false' do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing.alive?' do @@ -79,6 +82,7 @@ def alive? context 'with an expectation that the return value is true or false' do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing#alive?' do diff --git a/spec/functional/instance_method/fixnum_spec.rb b/spec/functional/instance_method/fixnum_spec.rb index 418f321..3d1afc9 100644 --- a/spec/functional/instance_method/fixnum_spec.rb +++ b/spec/functional/instance_method/fixnum_spec.rb @@ -16,6 +16,7 @@ def answer context 'with an expectation that the return value is 42' do before do write_file 'spec/life_spec.rb', """ + $: << '.' require 'life' describe 'Life#answer' do @@ -33,6 +34,7 @@ def answer context 'with an expectation that the return value is a Fixnum' do before do write_file 'spec/life_spec.rb', """ + $: << '.' require 'life' describe 'Life#answer' do diff --git a/spec/functional/instance_method/float_spec.rb b/spec/functional/instance_method/float_spec.rb index 9045ce2..4001c1e 100644 --- a/spec/functional/instance_method/float_spec.rb +++ b/spec/functional/instance_method/float_spec.rb @@ -16,6 +16,7 @@ def answer context 'with an expectation that the return value is 42.5' do before do write_file 'spec/life_spec.rb', """ + $: << '.' require 'life' describe 'Life#answer' do @@ -33,6 +34,7 @@ def answer context 'with an expectation that the return value is a Float' do before do write_file 'spec/life_spec.rb', """ + $: << '.' require 'life' describe 'Life#answer' do diff --git a/spec/functional/instance_method/hash_spec.rb b/spec/functional/instance_method/hash_spec.rb index e04ddfd..e30e64e 100644 --- a/spec/functional/instance_method/hash_spec.rb +++ b/spec/functional/instance_method/hash_spec.rb @@ -16,6 +16,7 @@ def to_hash context 'with an expectation that hash[:foo][:bar] is 3' do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing#to_hash' do @@ -33,6 +34,7 @@ def to_hash context 'with an expectation that hash[:foo][:bar] is a Fixnum' do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing#to_hash' do diff --git a/spec/functional/instance_method/range_spec.rb b/spec/functional/instance_method/range_spec.rb index 39f528b..d413d1f 100644 --- a/spec/functional/instance_method/range_spec.rb +++ b/spec/functional/instance_method/range_spec.rb @@ -16,6 +16,7 @@ def a_range context "with an expectation that the return value is `'a'..'z'`" do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing#a_range' do @@ -33,6 +34,7 @@ def a_range context "with an expectation that the return value is a range" do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing#a_range' do @@ -48,4 +50,4 @@ def a_range end end end -end \ No newline at end of file +end diff --git a/spec/functional/instance_method/regex_spec.rb b/spec/functional/instance_method/regex_spec.rb index 1969123..96ee399 100644 --- a/spec/functional/instance_method/regex_spec.rb +++ b/spec/functional/instance_method/regex_spec.rb @@ -16,6 +16,7 @@ def regex context 'with an expectation that a string matches the regex' do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing#regex' do @@ -35,6 +36,7 @@ def regex context 'with an expectation that the regex is a Regex' do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing#regex' do diff --git a/spec/functional/instance_method/string_spec.rb b/spec/functional/instance_method/string_spec.rb index e893ad6..0a9a8ef 100644 --- a/spec/functional/instance_method/string_spec.rb +++ b/spec/functional/instance_method/string_spec.rb @@ -16,6 +16,7 @@ def a_string context 'with an expectation that the return value is "foo"' do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing#a_string' do @@ -33,6 +34,7 @@ def a_string context 'with an expectation that the return value is a string' do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing#a_string' do diff --git a/spec/functional/instance_method/symbol_spec.rb b/spec/functional/instance_method/symbol_spec.rb index 9e3bb6b..15c9077 100644 --- a/spec/functional/instance_method/symbol_spec.rb +++ b/spec/functional/instance_method/symbol_spec.rb @@ -16,6 +16,7 @@ def a_symbol context 'with an expectation that the return value is :foo' do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing#a_symbol' do @@ -33,6 +34,7 @@ def a_symbol context 'with an expectation that the return value is a symbol' do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing#a_symbol' do diff --git a/spec/functional/reporter/method_loaded_spec.rb b/spec/functional/reporter/method_loaded_spec.rb index 27c1d64..4c2331a 100644 --- a/spec/functional/reporter/method_loaded_spec.rb +++ b/spec/functional/reporter/method_loaded_spec.rb @@ -12,6 +12,7 @@ def alive? end """ write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing#alive?' do @@ -39,6 +40,7 @@ def alive? end """ write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing#alive?' do @@ -57,4 +59,4 @@ def alive? end end end -end \ No newline at end of file +end diff --git a/spec/functional/reporter/running_mutations_spec.rb b/spec/functional/reporter/running_mutations_spec.rb index f5e6b39..227be9f 100644 --- a/spec/functional/reporter/running_mutations_spec.rb +++ b/spec/functional/reporter/running_mutations_spec.rb @@ -15,6 +15,7 @@ def alive? end CODE write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing#alive?' do @@ -59,4 +60,4 @@ def alive? STR end end -end \ No newline at end of file +end diff --git a/spec/functional/runners/rspec_spec.rb b/spec/functional/runners/rspec_spec.rb index a2645d0..b1a4a2d 100644 --- a/spec/functional/runners/rspec_spec.rb +++ b/spec/functional/runners/rspec_spec.rb @@ -23,4 +23,4 @@ def alive?; true end end end end -end \ No newline at end of file +end diff --git a/spec/functional/singleton_method/array_spec.rb b/spec/functional/singleton_method/array_spec.rb index 1163f8a..2afc2fd 100644 --- a/spec/functional/singleton_method/array_spec.rb +++ b/spec/functional/singleton_method/array_spec.rb @@ -16,6 +16,7 @@ def self.to_a context 'with an expectation that the array is [1,2,3]' do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing.to_a' do @@ -33,6 +34,7 @@ def self.to_a context 'with an expectation that the array responds to length' do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing.to_a' do diff --git a/spec/functional/singleton_method/boolean_spec.rb b/spec/functional/singleton_method/boolean_spec.rb index 57db646..dfa35ca 100644 --- a/spec/functional/singleton_method/boolean_spec.rb +++ b/spec/functional/singleton_method/boolean_spec.rb @@ -16,6 +16,7 @@ def self.alive? context 'with an expectation that the return value is true' do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing.alive?' do @@ -33,6 +34,7 @@ def self.alive? context 'with an expectation that the return value is true or false' do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing.alive?' do @@ -62,6 +64,7 @@ def self.alive? context 'with an expectation that the return value is false' do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing.alive?' do @@ -79,6 +82,7 @@ def self.alive? context 'with an expectation that the return value is true or false' do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing.alive?' do diff --git a/spec/functional/singleton_method/fixnum_spec.rb b/spec/functional/singleton_method/fixnum_spec.rb index 344c060..3628f99 100644 --- a/spec/functional/singleton_method/fixnum_spec.rb +++ b/spec/functional/singleton_method/fixnum_spec.rb @@ -16,6 +16,7 @@ def self.answer context 'with an expectation that the return value is 42' do before do write_file 'spec/life_spec.rb', """ + $: << '.' require 'life' describe 'Life.answer' do @@ -33,6 +34,7 @@ def self.answer context 'with an expectation that the return value is a Fixnum' do before do write_file 'spec/life_spec.rb', """ + $: << '.' require 'life' describe 'Life.answer' do diff --git a/spec/functional/singleton_method/float_spec.rb b/spec/functional/singleton_method/float_spec.rb index e5cdba9..cd201d1 100644 --- a/spec/functional/singleton_method/float_spec.rb +++ b/spec/functional/singleton_method/float_spec.rb @@ -16,6 +16,7 @@ def self.answer context 'with an expectation that the return value is 42.05' do before do write_file 'spec/life_spec.rb', """ + $: << '.' require 'life' describe 'Life.answer' do @@ -33,6 +34,7 @@ def self.answer context 'with an expectation that the return value is a Float' do before do write_file 'spec/life_spec.rb', """ + $: << '.' require 'life' describe 'Life.answer' do diff --git a/spec/functional/singleton_method/hash_spec.rb b/spec/functional/singleton_method/hash_spec.rb index c4b17ed..ea1854c 100644 --- a/spec/functional/singleton_method/hash_spec.rb +++ b/spec/functional/singleton_method/hash_spec.rb @@ -16,6 +16,7 @@ def self.to_hash context 'with an expectation that hash[:foo][:bar] is 3' do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing.to_hash' do @@ -33,6 +34,7 @@ def self.to_hash context 'with an expectation that hash[:foo][:bar] is a Fixnum' do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing.to_hash' do diff --git a/spec/functional/singleton_method/range_spec.rb b/spec/functional/singleton_method/range_spec.rb index a85ea92..23d4ac5 100644 --- a/spec/functional/singleton_method/range_spec.rb +++ b/spec/functional/singleton_method/range_spec.rb @@ -16,6 +16,7 @@ def self.a_range context "with an expectation that the return value is `'a'..'z'`" do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing#a_range' do @@ -33,6 +34,7 @@ def self.a_range context "with an expectation that the return value is a range" do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing.a_string' do @@ -48,4 +50,4 @@ def self.a_range end end end -end \ No newline at end of file +end diff --git a/spec/functional/singleton_method/regex_spec.rb b/spec/functional/singleton_method/regex_spec.rb index e41d719..00a4da0 100644 --- a/spec/functional/singleton_method/regex_spec.rb +++ b/spec/functional/singleton_method/regex_spec.rb @@ -16,6 +16,7 @@ def self.regex context 'with an expectation that a string matches the regex' do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing.regex' do @@ -35,6 +36,7 @@ def self.regex context 'with an expectation that the regex is a Regexp' do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing.regex' do diff --git a/spec/functional/singleton_method/string_spec.rb b/spec/functional/singleton_method/string_spec.rb index ed0c61e..a6f3ef8 100644 --- a/spec/functional/singleton_method/string_spec.rb +++ b/spec/functional/singleton_method/string_spec.rb @@ -16,6 +16,7 @@ def self.a_string context 'with an expectation that the return value is "foo"' do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing.a_string' do @@ -33,6 +34,7 @@ def self.a_string context 'with an expectation that the return value is a string' do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing.a_string' do diff --git a/spec/functional/singleton_method/symbol_spec.rb b/spec/functional/singleton_method/symbol_spec.rb index 60dbd17..ee1ca82 100644 --- a/spec/functional/singleton_method/symbol_spec.rb +++ b/spec/functional/singleton_method/symbol_spec.rb @@ -16,6 +16,7 @@ def self.a_symbol context 'with an expectation that the return value is :foo' do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing.a_symbol' do @@ -33,6 +34,7 @@ def self.a_symbol context 'with an expectation that the return value is a symbol' do before do write_file 'spec/thing_spec.rb', """ + $: << '.' require 'thing' describe 'Thing.a_symbol' do