wrap parfait tests in module and boot

This commit is contained in:
Torsten Ruger 2018-04-26 12:31:37 +03:00
parent 30ba626cf9
commit a7207a9984
18 changed files with 1001 additions and 976 deletions

11
test/parfait/helper.rb Normal file
View File

@ -0,0 +1,11 @@
require_relative "../helper"
module Parfait
class ParfaitTest < MiniTest::Test
def setup
@machine = Risc.machine.boot
@space = Parfait.object_space
end
end
end

View File

@ -1,10 +1,10 @@
require_relative "../helper"
require_relative "helper"
class TestAttributes < MiniTest::Test
module Parfait
class TestAttributes < ParfaitTest
def setup
Risc.machine.boot
@space = Parfait.object_space
super
@mess = @space.first_message
@type = @mess.get_type
end
@ -37,4 +37,5 @@ class TestAttributes < MiniTest::Test
def test_type_type_type
assert_equal Parfait::Type , @type.get_type.get_type.get_type.class
end
end
end

View File

@ -1,10 +1,10 @@
require_relative "../helper"
require_relative "helper"
module Parfait
class TestBinaryCode < MiniTest::Test
class TestBinaryCode < ParfaitTest
def setup
Risc.machine.boot
super
@code = BinaryCode.new(10)
end

View File

@ -1,10 +1,10 @@
require_relative "../helper"
require_relative "helper"
class TestClass < MiniTest::Test
module Parfait
class TestClass < ParfaitTest
def setup
Risc.machine.boot
@space = Parfait.object_space
super
@try = @space.create_class :Try , :Object
end
@ -46,4 +46,5 @@ class TestClass < MiniTest::Test
assert before != @space.get_class.instance_type.hash
end
end
end

View File

@ -1,8 +1,10 @@
require_relative "../helper"
require_relative "helper"
class TestDictionary < MiniTest::Test
module Parfait
class TestDictionary < ParfaitTest
def setup
super
@lookup = ::Parfait::Dictionary.new
end
def test_dict_create
@ -73,4 +75,5 @@ class TestDictionary < MiniTest::Test
@lookup[2] = :two
assert @lookup[2] == :two
end
end
end

View File

@ -1,10 +1,10 @@
require_relative "../helper"
require_relative "helper"
module Parfait
class TestInteger < MiniTest::Test
class TestInteger < ParfaitTest
def setup
Risc.machine.boot
super
@int = Integer.new(10)
end

View File

@ -1,8 +1,10 @@
require_relative "../helper"
require_relative "helper"
class TestList < MiniTest::Test
module Parfait
class TestList < ParfaitTest
def setup
super
@list = ::Parfait::List.new
end
def test_isa
@ -195,4 +197,5 @@ class TestList < MiniTest::Test
def test_last_empty
assert_nil @list.last
end
end
end

View File

@ -1,11 +1,10 @@
require_relative "../helper"
require_relative "helper"
module Parfait
class TestMessage < MiniTest::Test
class TestMessage < ParfaitTest
def setup
Risc.machine.boot
@space = Parfait.object_space
super
@mess = @space.first_message
end
def test_length

View File

@ -1,11 +1,10 @@
require_relative "../helper"
require_relative "helper"
module Parfait
class TestNamedLists < MiniTest::Test
class TestNamedLists < ParfaitTest
def setup
Risc.machine.boot
@space = Parfait.object_space
super
@named_list = @space.first_message.frame
@type = @named_list.get_type
end

View File

@ -1,8 +1,10 @@
require_relative "../helper"
require_relative "helper"
class TestObject < MiniTest::Test
module Parfait
class TestObject < ParfaitTest
def setup
super
@object = ::Parfait::Object.new
end
@ -14,4 +16,5 @@ class TestObject < MiniTest::Test
assert_equal @object.get_type , @object.set_internal_word(1, @object.get_type)
end
end
end

View File

@ -1,11 +1,7 @@
require_relative "../helper"
require_relative "helper"
class TestSpace < MiniTest::Test
def setup
@machine = Risc.machine.boot
@space = Parfait.object_space
end
module Parfait
class TestSpace < ParfaitTest
def classes
[:Word,:List,:Message,:NamedList,:Type,:Object,:Class,:Dictionary,:TypedMethod , :Integer]
@ -159,4 +155,5 @@ class TestSpace < MiniTest::Test
end
end
end
end

View File

@ -1,9 +1,10 @@
require_relative "../helper"
require_relative "helper"
class TestMethod < MiniTest::Test
module Parfait
class TestMethod < ParfaitTest
def setup
Risc.machine.boot
super
obj = Parfait.object_space.get_class_by_name(:Object).instance_type
args = Parfait::Type.for_hash( obj.object_class , { bar: :Integer , foo: :Type})
frame = Parfait::Type.for_hash( obj.object_class , { local_bar: :Integer , local_foo: :Type})
@ -94,4 +95,5 @@ class TestMethod < MiniTest::Test
def test_created_with_binary
assert @method.binary
end
end
end

View File

@ -1,6 +1,7 @@
require_relative "../helper"
require_relative "helper"
module Parfait
class TestEmptyWord < MiniTest::Test
class TestEmptyWord < ParfaitTest
def setup
Risc.machine.boot
@ -25,11 +26,11 @@ class TestEmptyWord < MiniTest::Test
@word.set_char(1 , 32)
end
end
end
class TestWord < MiniTest::Test
end
class TestWord < ParfaitTest
def setup
Risc.machine.boot
super
@word = Parfait::Word.new(5)
end
def test_len
@ -109,5 +110,5 @@ class TestWord < MiniTest::Test
two = Parfait.new_word("one")
assert one.compare(two)
end
end
end
end

View File

@ -1,10 +1,10 @@
require_relative "../../helper"
require_relative "../helper"
class BasicType < MiniTest::Test
module Parfait
class BasicType < ParfaitTest
def setup
Risc.machine.boot
@space = Parfait.object_space
super
@mess = @space.first_message
assert @mess
@type = @mess.get_type()
@ -72,4 +72,5 @@ class BasicType < MiniTest::Test
type = @mess.get_type
assert_equal type , @mess.get_internal_word(1)
end
end
end

View File

@ -1,10 +1,10 @@
require_relative "../../helper"
require_relative "../helper"
class TypeHash < MiniTest::Test
module Parfait
class TypeHash < ParfaitTest
def setup
Risc.machine.boot
@space = Parfait.object_space
super
@types = @space.instance_variable_ged("@types")
@first = @types.values.first
end
@ -42,4 +42,5 @@ class TypeHash < MiniTest::Test
t2 = Parfait::Type.for_hash( list , type: :NewObj)
assert t1.hash != t2.hash , "Hashes should differ"
end
end
end

View File

@ -1,10 +1,10 @@
require_relative "../../helper"
require_relative "../helper"
class TypeMessages < MiniTest::Test
module Parfait
class TypeMessages < ParfaitTest
def setup
Risc.machine.boot
@space = Parfait.object_space
super
@mess = @space.first_message
end
@ -26,4 +26,5 @@ class TypeMessages < MiniTest::Test
assert_equal 5 , @mess.get_type.get_type.variable_index(:methods)
end
end
end

View File

@ -1,10 +1,10 @@
require_relative "../../helper"
require_relative "../helper"
class TestMethodApi < MiniTest::Test
module Parfait
class TestMethodApi < ParfaitTest
def setup
Risc.machine.boot
@space = Parfait.object_space
super
@try_class = @space.create_class( :Try )
@try_type = @try_class.instance_type
end
@ -79,4 +79,5 @@ class TestMethodApi < MiniTest::Test
def test_resolve_fail
assert_nil object_type.resolve_method( :foo )
end
end
end

View File

@ -1,10 +1,10 @@
require_relative "../../helper"
require_relative "../helper"
class TypeApi < MiniTest::Test
module Parfait
class TypeApi < ParfaitTest
def setup
Risc.machine.boot
@space = Parfait.object_space
super
tc = @space.get_class_by_name( :NamedList )
@type = tc.instance_type
end
@ -90,4 +90,5 @@ class TypeApi < MiniTest::Test
assert counter.empty? , counter.inspect
end
end
end