Skip to content

Commit

Permalink
Make mutant work on latest rbx, both 1.8 and 1.9 mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Josep M. Bach committed Feb 25, 2012
1 parent 0a570bb commit 83cb1b4
Show file tree
Hide file tree
Showing 28 changed files with 64 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .rvmrc
@@ -1 +1 @@
rvm use rbx-1.2.4@mutant --create
rvm use rbx-head@mutant --create
6 changes: 6 additions & 0 deletions .travis.yml
@@ -0,0 +1,6 @@
rvm:
- rbx-18mode
- rbx-19mode

bundler_args: "--binstubs"
script: "bin/rspec spec"
4 changes: 2 additions & 2 deletions lib/mutant/implementation.rb
Expand Up @@ -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

Expand All @@ -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
2 changes: 1 addition & 1 deletion lib/mutant/method.rb
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions lib/mutant/mutatee.rb
Expand Up @@ -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

Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion 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') {
Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions spec/functional/class_spec.rb
Expand Up @@ -12,6 +12,7 @@ def alphabet_range; 'a'..'k' end
end
"""
write_file 'spec/thing_spec.rb', """
$: << '.'
require 'thing'
describe Thing do
Expand Down
2 changes: 2 additions & 0 deletions spec/functional/instance_method/array_spec.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions spec/functional/instance_method/boolean_spec.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions spec/functional/instance_method/fixnum_spec.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions spec/functional/instance_method/float_spec.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions spec/functional/instance_method/hash_spec.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion spec/functional/instance_method/range_spec.rb
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -48,4 +50,4 @@ def a_range
end
end
end
end
end
2 changes: 2 additions & 0 deletions spec/functional/instance_method/regex_spec.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions spec/functional/instance_method/string_spec.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions spec/functional/instance_method/symbol_spec.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion spec/functional/reporter/method_loaded_spec.rb
Expand Up @@ -12,6 +12,7 @@ def alive?
end
"""
write_file 'spec/thing_spec.rb', """
$: << '.'
require 'thing'
describe 'Thing#alive?' do
Expand Down Expand Up @@ -39,6 +40,7 @@ def alive?
end
"""
write_file 'spec/thing_spec.rb', """
$: << '.'
require 'thing'
describe 'Thing#alive?' do
Expand All @@ -57,4 +59,4 @@ def alive?
end
end
end
end
end
3 changes: 2 additions & 1 deletion spec/functional/reporter/running_mutations_spec.rb
Expand Up @@ -15,6 +15,7 @@ def alive?
end
CODE
write_file 'spec/thing_spec.rb', """
$: << '.'
require 'thing'
describe 'Thing#alive?' do
Expand Down Expand Up @@ -59,4 +60,4 @@ def alive?
STR
end
end
end
end
2 changes: 1 addition & 1 deletion spec/functional/runners/rspec_spec.rb
Expand Up @@ -23,4 +23,4 @@ def alive?; true end
end
end
end
end
end
2 changes: 2 additions & 0 deletions spec/functional/singleton_method/array_spec.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions spec/functional/singleton_method/boolean_spec.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions spec/functional/singleton_method/fixnum_spec.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions spec/functional/singleton_method/float_spec.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions spec/functional/singleton_method/hash_spec.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 83cb1b4

Please sign in to comment.