rubyx/test/melon/compiler/test_class.rb

30 lines
935 B
Ruby
Raw Normal View History

require_relative "helper"
module Melon
class TestClass < MiniTest::Test
2016-12-18 16:17:58 +01:00
def setup
Register.machine.boot unless Register.machine.booted
end
2016-12-18 16:17:58 +01:00
def test_creates_class_without_deriviation
Compiler.compile "class Testing ; end"
assert t = Parfait::Space.object_space.get_class_by_name(:Testing) , "No classes created"
assert_equal :Object , t.super_class_name
end
2016-12-18 16:17:58 +01:00
def test_creates_class_with_deriviation
Compiler.compile "class Test2 < List ;end"
assert t = Parfait::Space.object_space.get_class_by_name(:Test2) , "No classes created"
assert_equal :List , t.super_class_name
end
def test_picks_up_an_ivar_name
Compiler.compile "class TestIvar < Object ; def meth; return @ivar;end; end"
itest = Parfait::Space.object_space.get_class_by_name(:TestIvar)
assert itest.instance_names.include?(:ivar) , itest.instance_names.inspect
end
end
end