Permalink
Browse files

Make mutant work on latest rbx, both 1.8 and 1.9 mode

  • Loading branch information...
1 parent 0a570bb commit 83cb1b4992c6ceaba4984d55c8fda7077001ead3 @txus committed Feb 25, 2012
View
2 .rvmrc
@@ -1 +1 @@
-rvm use rbx-1.2.4@mutant --create
+rvm use rbx-head@mutant --create
View
@@ -0,0 +1,6 @@
+rvm:
+ - rbx-18mode
+ - rbx-19mode
+
+bundler_args: "--binstubs"
+script: "bin/rspec spec"
@@ -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
View
@@ -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
View
@@ -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
View
@@ -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
@@ -12,6 +12,7 @@ def alphabet_range; 'a'..'k' end
end
"""
write_file 'spec/thing_spec.rb', """
+ $: << '.'
require 'thing'
describe Thing do
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
+end
@@ -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
@@ -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
@@ -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
@@ -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
+end
@@ -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
+end
@@ -23,4 +23,4 @@ def alive?; true end
end
end
end
-end
+end
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
Oops, something went wrong.

0 comments on commit 83cb1b4

Please sign in to comment.