2016-12-18 16:02:55 +01:00
|
|
|
require_relative "helper"
|
|
|
|
|
2017-01-17 23:05:36 +01:00
|
|
|
module Rubyx
|
2017-08-31 15:18:59 +02:00
|
|
|
class TestCompiler #< MiniTest::Test
|
2016-12-18 16:02:55 +01:00
|
|
|
|
2016-12-18 16:17:58 +01:00
|
|
|
def setup
|
2017-01-19 08:02:29 +01:00
|
|
|
Risc.machine.boot
|
2016-12-18 16:17:58 +01:00
|
|
|
end
|
2016-12-18 19:05:11 +01:00
|
|
|
|
2017-01-15 15:59:29 +01:00
|
|
|
def test_doesnt_create_existing_clas
|
|
|
|
space_class = Parfait.object_space.get_class_by_name(:Space)
|
2017-08-31 13:18:12 +02:00
|
|
|
RubyxCompiler.compile "class Space ; end"
|
2017-01-15 15:59:29 +01:00
|
|
|
clazz = Parfait.object_space.get_class_by_name(:Space)
|
|
|
|
assert_equal clazz , space_class
|
|
|
|
end
|
|
|
|
|
2016-12-18 16:17:58 +01:00
|
|
|
def test_creates_class_without_deriviation
|
2017-08-31 13:18:12 +02:00
|
|
|
RubyxCompiler.compile "class Testing ; end"
|
2017-01-01 20:50:54 +01:00
|
|
|
clazz = Parfait.object_space.get_class_by_name(:Testing)
|
|
|
|
assert clazz , "No classes created"
|
|
|
|
assert_equal :Object , clazz.super_class_name
|
2016-12-18 16:02:55 +01:00
|
|
|
end
|
2016-12-18 16:17:58 +01:00
|
|
|
|
|
|
|
def test_creates_class_with_deriviation
|
2017-08-31 13:18:12 +02:00
|
|
|
RubyxCompiler.compile "class Test2 < List ;end"
|
2017-01-01 20:50:54 +01:00
|
|
|
clazz = Parfait.object_space.get_class_by_name(:Test2)
|
|
|
|
assert clazz, "No classes created"
|
|
|
|
assert_equal :List , clazz.super_class_name
|
2016-12-18 16:17:58 +01:00
|
|
|
end
|
|
|
|
|
2017-01-17 20:25:58 +01:00
|
|
|
def test_space_is_unchanged_by_compile
|
|
|
|
space1 = Parfait.object_space.get_class_by_name(:Space)
|
2017-08-31 13:18:12 +02:00
|
|
|
RubyxCompiler.compile "class Space ;end"
|
2017-01-17 20:25:58 +01:00
|
|
|
space2 = Parfait.object_space.get_class_by_name(:Space)
|
|
|
|
assert_equal space1 , space2
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_space_type_is_unchanged_by_compile
|
|
|
|
space1 = Parfait.object_space.get_class_by_name(:Space).instance_type
|
2017-08-31 13:18:12 +02:00
|
|
|
RubyxCompiler.compile "class Space ;end"
|
2017-01-17 20:25:58 +01:00
|
|
|
space2 = Parfait.object_space.get_class_by_name(:Space).instance_type
|
|
|
|
assert_equal space1 , space2
|
|
|
|
end
|
|
|
|
|
2016-12-18 16:02:55 +01:00
|
|
|
end
|
|
|
|
end
|