Updated with Rubinius Support
This commit is contained in:
2
Rakefile
2
Rakefile
@@ -75,7 +75,7 @@ module RubyImpls
|
|||||||
|
|
||||||
# List of expected ruby implementations.
|
# List of expected ruby implementations.
|
||||||
def self.expected
|
def self.expected
|
||||||
%w(ruby-1.8.6 ruby-1.8.7 ruby-1.9.2 jruby ree)
|
%w(ruby-1.8.6 ruby-1.8.7 ruby-1.9.2 jruby ree rbx)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class AboutMethods < EdgeCase::Koan
|
|||||||
my_global_method
|
my_global_method
|
||||||
end
|
end
|
||||||
#--
|
#--
|
||||||
pattern = "wrong (number|#) of arguments"
|
pattern = "wrong (number|#) of arguments|given \\d+, expected \\d+"
|
||||||
#++
|
#++
|
||||||
assert_match(/#{__(pattern)}/, exception.message)
|
assert_match(/#{__(pattern)}/, exception.message)
|
||||||
|
|
||||||
|
|||||||
@@ -30,20 +30,22 @@ class AboutObjects < EdgeCase::Koan
|
|||||||
assert_equal __(true), obj.object_id != another_obj.object_id
|
assert_equal __(true), obj.object_id != another_obj.object_id
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_some_system_objects_always_have_the_same_id
|
not_in_ruby_version('rbx') do
|
||||||
assert_equal __(0), false.object_id
|
def test_some_system_objects_always_have_the_same_id
|
||||||
assert_equal __(2), true.object_id
|
assert_equal __(0), false.object_id
|
||||||
assert_equal __(4), nil.object_id
|
assert_equal __(2), true.object_id
|
||||||
end
|
assert_equal __(4), nil.object_id
|
||||||
|
end
|
||||||
|
|
||||||
def test_small_integers_have_fixed_ids
|
def test_small_integers_have_fixed_ids
|
||||||
assert_equal __(1), 0.object_id
|
assert_equal __(1), 0.object_id
|
||||||
assert_equal __(3), 1.object_id
|
assert_equal __(3), 1.object_id
|
||||||
assert_equal __(5), 2.object_id
|
assert_equal __(5), 2.object_id
|
||||||
assert_equal __(201), 100.object_id
|
assert_equal __(201), 100.object_id
|
||||||
|
|
||||||
# THINK ABOUT IT:
|
# THINK ABOUT IT:
|
||||||
# What pattern do the object IDs for small integers follow?
|
# What pattern do the object IDs for small integers follow?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_clone_creates_a_different_object
|
def test_clone_creates_a_different_object
|
||||||
|
|||||||
@@ -13,13 +13,18 @@ end
|
|||||||
def ruby_version?(version)
|
def ruby_version?(version)
|
||||||
RUBY_VERSION =~ /^#{version}/ ||
|
RUBY_VERSION =~ /^#{version}/ ||
|
||||||
(version == 'jruby' && defined?(JRUBY_VERSION)) ||
|
(version == 'jruby' && defined?(JRUBY_VERSION)) ||
|
||||||
(version == 'mri' && ! defined?(JRUBY_VERSION))
|
(version == 'mri' && (! defined?(JRUBY_VERSION) && ! defined?(Rubinius))) ||
|
||||||
|
(version == 'rbx' && defined?(Rubinius))
|
||||||
end
|
end
|
||||||
|
|
||||||
def in_ruby_version(*versions)
|
def in_ruby_version(*versions)
|
||||||
yield if versions.any? { |v| ruby_version?(v) }
|
yield if versions.any? { |v| ruby_version?(v) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def not_in_ruby_version(*versions)
|
||||||
|
yield unless versions.any? { |v| ruby_version?(v) }
|
||||||
|
end
|
||||||
|
|
||||||
# Standard, generic replacement value.
|
# Standard, generic replacement value.
|
||||||
# If value19 is given, it is used inplace of value for Ruby 1.9.
|
# If value19 is given, it is used inplace of value for Ruby 1.9.
|
||||||
def __(value="FILL ME IN", value19=:mu)
|
def __(value="FILL ME IN", value19=:mu)
|
||||||
@@ -52,7 +57,7 @@ class Object
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
in_ruby_version("1.9") do
|
in_ruby_version("1.9", "rbx") do
|
||||||
public :method_missing
|
public :method_missing
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user