get fragment tests back online
the 58% REALLY doesn’t look good and things have settle down, so no more excuses
This commit is contained in:
parent
f4f703975b
commit
7b1e89effb
@ -1,3 +1,5 @@
|
||||
require 'parslet/convenience'
|
||||
|
||||
module Virtual
|
||||
# The Virtual Machine is a object based virtual machine in which ruby is implemented.
|
||||
#
|
||||
|
@ -1,34 +1,15 @@
|
||||
require_relative '../helper'
|
||||
require 'parslet/convenience'
|
||||
|
||||
#test the generation of code fragments.
|
||||
# ie parse assumes @string_input
|
||||
# compile
|
||||
# assemble/write assume a @should array with the bytes in it
|
||||
|
||||
# since the bytes are store, the test can be run on any machine.
|
||||
|
||||
# but to get the bytes, one needs to link and run the object file to confirm correctness (to be automated)
|
||||
# simple tests to check parsing pworks and the first classes come out right.
|
||||
#
|
||||
# build up from small to check larger expressions are correct
|
||||
|
||||
module Fragments
|
||||
# need a code generator, for arm
|
||||
def setup
|
||||
@object_machine = Virtual::Machin.new "Arm"
|
||||
end
|
||||
|
||||
def parse
|
||||
parser = Parser::Salama.new
|
||||
syntax = parser.parse_with_debug(@string_input)
|
||||
parts = Parser::Transform.new.apply(syntax)
|
||||
# file is a list of expressions, all but the last must be a function
|
||||
# and the last is wrapped as a main
|
||||
parts.each_with_index do |part,index|
|
||||
if part.is_a? Ast::FunctionExpression
|
||||
expr = part.compile( @object_machine.context )
|
||||
else
|
||||
puts part.inspect if part.is_a? Hash
|
||||
expr = part.compile( @object_machine.context )
|
||||
end
|
||||
def check
|
||||
expressions = Virtual.machine.boot.compile_main @string_input
|
||||
@expect.each_with_index do | should , i |
|
||||
assert_equal should , expressions[i].class
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
|
||||
require_relative "test_foo"
|
||||
require_relative "test_functions"
|
||||
require_relative "test_hello"
|
||||
require_relative "test_if"
|
||||
require_relative "test_putint"
|
||||
require_relative "test_recursive_fibo"
|
||||
require_relative "test_while_fibo"
|
||||
#require_relative "test_functions"
|
||||
#require_relative "test_hello"
|
||||
#require_relative "test_if"
|
||||
#require_relative "test_putint"
|
||||
#require_relative "test_recursive_fibo"
|
||||
#require_relative "test_while_fibo"
|
||||
|
@ -3,18 +3,23 @@ require_relative 'helper'
|
||||
class TestFoo < MiniTest::Test
|
||||
include Fragments
|
||||
|
||||
def test_foo
|
||||
def test_foo2
|
||||
@string_input = <<HERE
|
||||
def foo(x)
|
||||
a = 5
|
||||
end
|
||||
3.foo( 4 )
|
||||
HERE
|
||||
@should = [0x0,0x40,0x2d,0xe9,0x5,0x0,0xa0,0xe3,0x0,0x80,0xbd,0xe8]
|
||||
@output = ""
|
||||
parse
|
||||
@target = [:Object , :foo]
|
||||
write "foo"
|
||||
end
|
||||
@expect = [Parfait::Method , Virtual::Return ]
|
||||
check
|
||||
end
|
||||
|
||||
def test_foo
|
||||
@string_input = <<HERE
|
||||
3.foo( 4 )
|
||||
HERE
|
||||
@expect = [Virtual::Return ]
|
||||
check
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -1,4 +1,6 @@
|
||||
# All working tests (ahm), still working on the others, so no use to be constantly reminded
|
||||
require_relative "parfait/test_all"
|
||||
|
||||
require_relative "fragments/test_all"
|
||||
|
||||
require_relative "virtual/test_all"
|
||||
|
Loading…
Reference in New Issue
Block a user