2018-04-26 11:31:37 +02:00
|
|
|
require_relative "helper"
|
2015-10-25 12:19:18 +01:00
|
|
|
|
2018-04-26 11:31:37 +02:00
|
|
|
module Parfait
|
|
|
|
class TestClass < ParfaitTest
|
2015-10-25 12:19:18 +01:00
|
|
|
|
2018-04-26 11:31:37 +02:00
|
|
|
def setup
|
|
|
|
super
|
|
|
|
@try = @space.create_class :Try , :Object
|
|
|
|
end
|
2015-10-25 12:19:18 +01:00
|
|
|
|
2018-04-26 11:31:37 +02:00
|
|
|
def test_type_forclass
|
|
|
|
assert_equal "Class(Space)" , @space.get_type.object_class.inspect
|
|
|
|
assert_equal :Space , @space.get_type.object_class.name
|
|
|
|
end
|
|
|
|
def test_new_superclass_name
|
|
|
|
assert_equal :Object , @try.super_class_name
|
|
|
|
end
|
2019-09-22 23:07:30 +02:00
|
|
|
def test_existing_superclass_name
|
|
|
|
assert_equal :Object , @space.classes[:Type].super_class_name
|
|
|
|
end
|
2018-04-26 11:31:37 +02:00
|
|
|
def test_new_superclass
|
|
|
|
assert_equal "Class(Object)" , @try.super_class!.inspect
|
|
|
|
assert_equal "Class(Object)" , @try.super_class.inspect
|
|
|
|
end
|
|
|
|
def test_new_methods
|
|
|
|
assert_equal @try.method_names.class, @try.instance_methods.class
|
|
|
|
assert_equal @try.method_names.get_length , @try.instance_methods.get_length
|
|
|
|
end
|
|
|
|
def test_remove_nothere
|
|
|
|
assert !@try.remove_instance_method(:foo)
|
|
|
|
end
|
|
|
|
def test_resolve
|
|
|
|
assert_nil @try.resolve_method :foo
|
|
|
|
end
|
|
|
|
def test_remove_method
|
|
|
|
assert_equal false , @try.remove_instance_method( :foo)
|
|
|
|
end
|
|
|
|
def test_add_nil_method_raises
|
|
|
|
assert_raises{ @try.add_instance_method(nil)}
|
|
|
|
end
|
|
|
|
def test_add_instance_variable_changes_type
|
|
|
|
before = @space.get_class.instance_type
|
|
|
|
@space.get_class.add_instance_variable(:counter , :Integer)
|
|
|
|
assert before != @space.get_class.instance_type
|
|
|
|
end
|
|
|
|
def test_add_instance_variable_changes_type_hash
|
|
|
|
before = @space.get_class.instance_type.hash
|
|
|
|
@space.get_class.add_instance_variable(:counter , :Integer)
|
|
|
|
assert before != @space.get_class.instance_type.hash
|
|
|
|
end
|
2017-01-15 13:21:57 +01:00
|
|
|
|
2018-04-26 11:31:37 +02:00
|
|
|
end
|
2015-10-25 12:19:18 +01:00
|
|
|
end
|