helper erro handling
This commit is contained in:
parent
648ec772ec
commit
eaeea29e38
@ -115,7 +115,9 @@ module Parfait
|
|||||||
|
|
||||||
# get the current instance_typ of the class with the given name
|
# get the current instance_typ of the class with the given name
|
||||||
def get_type_by_class_name(name)
|
def get_type_by_class_name(name)
|
||||||
get_class_by_name(name).instance_type
|
clazz = get_class_by_name(name)
|
||||||
|
return nil unless clazz
|
||||||
|
clazz.instance_type
|
||||||
end
|
end
|
||||||
|
|
||||||
# get a class by name (symbol)
|
# get a class by name (symbol)
|
||||||
|
@ -28,6 +28,9 @@ module Parfait
|
|||||||
def test_get_type_by_class_name
|
def test_get_type_by_class_name
|
||||||
assert_equal Parfait::Type , Parfait.object_space.get_type_by_class_name(:Space).class
|
assert_equal Parfait::Type , Parfait.object_space.get_type_by_class_name(:Space).class
|
||||||
end
|
end
|
||||||
|
def test_get_type_by_class_name_nil
|
||||||
|
assert_nil Parfait.object_space.get_type_by_class_name(:Spac)
|
||||||
|
end
|
||||||
def test_get_integer_instance
|
def test_get_integer_instance
|
||||||
int = @space.get_integer
|
int = @space.get_integer
|
||||||
assert_equal Integer , int.class
|
assert_equal Integer , int.class
|
||||||
|
Loading…
Reference in New Issue
Block a user