starting to move builtin into parfait

single object method for now
little framework next
This commit is contained in:
2019-09-10 20:40:41 +03:00
parent feeb9332a2
commit 2c4f040654
6 changed files with 110 additions and 37 deletions

View File

@ -0,0 +1,24 @@
## Pre - testing builtin
In the process of moving builtin from mom to parfait. Considering we started at risc, this
is progress.
Builtin methods should (will) use the Macro idea to actually become code and land in
the parfait code.
On the way there, we start by Testing and moving the old ones. Since we want to be able
to test some methods even after the move, without parsing/processing the whole of parfait
we have to have a method of "injecting" the single? methods.
## Mom level
There a re two test levels to every method. Mom being the first, where we basically just
see if the right Mom instruction has been generated
## Risc
Second level is to check the actual risc instructions that are generated.
Current tests test only the length, but there are some tests in interpreter dir that
test actual instructions. Should move those, as they are too detailed in a mains
(make the interpreter tests less brittle while at it.)

View File

@ -0,0 +1 @@
require_relative "../helper"

View File

@ -0,0 +1,38 @@
require_relative "helper"
module RubyX
module Builtin
class TestObjectGet < MiniTest::Test
def setup
get = <<GET
class Object
def get_internal_word(at)
X.get_internal_word
end
end
GET
@mom = RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(get)
end
def compiler
@mom.method_compilers.first
end
def test_mom_col
assert_equal Mom::MomCollection , @mom.class
end
def test_mom_com
assert_equal Mom::MethodCompiler , @mom.method_compilers.first.class
end
def test_mom_meth
assert_equal :get_internal_word , compiler.callable.name
end
def test_instr_len
assert_equal 7 , compiler.mom_instructions.length
end
def test_instr_get
assert_equal Mom::GetInternalWord , compiler.mom_instructions.next.class
end
def test_risc
assert_equal 18 , compiler.to_risc.risc_instructions.length
end
end
end
end

View File

@ -20,6 +20,6 @@ the RubyXCompiler parfait load list.
The next step is to test the compiled parfait. Since we have tests, the best way would
be to parse and execute the tests. This would involve creating a mini MiniTest and some
fancy footwork in the compilation. But it should be possible to create one executable /
interpreted test for each of the exising Parfait test.
interpreted test for each of the existing Parfait test.
Alas, this is for another day.