Renaming Vool exppressions rightly

Class, Method and Lambda (was block) are expressions.
Just making things clearer, especially for the blocks (ahem, lambdas) is matters.
wip
This commit is contained in:
2019-08-19 11:33:12 +03:00
parent ae16551ed0
commit f87526f86f
44 changed files with 162 additions and 92 deletions

View File

@ -29,13 +29,13 @@ module Ruby
@vool.body.statements.last
end
def test_class
assert_equal Vool::ClassStatement , @vool.class
assert_equal Vool::ClassExpression , @vool.class
end
def test_body
assert_equal Vool::Statements , @vool.body.class
end
def test_getter
assert_equal Vool::MethodStatement , getter.class
assert_equal Vool::MethodExpression , getter.class
end
def test_getter_return
assert_equal Vool::ReturnStatement , getter.body.class

View File

@ -18,7 +18,7 @@ module Ruby
input = "def self.tryout(arg) ; arg = true ; return arg ; end "
@str = compile( input ).to_s
assert @str.include?("def self.tryou"), @str
assert @str.include?("arg = true"), @str
assert @str.include?("arg = true"), @str
end
end
class TestClassMethodStatement2 < MiniTest::Test
@ -43,7 +43,7 @@ module Ruby
@lst = compile( input ).to_vool
end
def test_method
assert_equal Vool::ClassMethodStatement , @lst.class
assert_equal Vool::ClassMethodExpression , @lst.class
end
def test_method_args
assert_equal [:arg1, :arg2] , @lst.args

View File

@ -9,7 +9,7 @@ module Ruby
@vool = compile( input ).to_vool
end
def test_class
assert_equal Vool::ClassStatement , @vool.class
assert_equal Vool::ClassExpression , @vool.class
end
def test_body
assert_equal Vool::Statements , @vool.body.class

View File

@ -12,7 +12,7 @@ module Ruby
assert_equal 2 , @vool.body.length , "setter, getter"
end
def test_setter
assert_equal Vool::MethodStatement , setter.class
assert_equal Vool::MethodExpression , setter.class
end
def test_setter_assign
assert_equal Vool::Statements , setter.body.class

View File

@ -11,7 +11,7 @@ module Ruby
assert_equal 4 , @vool.body.length , "2 setters, 2 getters"
end
def test_setter
assert_equal Vool::MethodStatement , setter.class
assert_equal Vool::MethodExpression , setter.class
end
def test_setter_assign
assert_equal Vool::Statements , setter.body.class

View File

@ -38,7 +38,7 @@ module Ruby
def test_first
assert_equal Vool::LocalAssignment , @lst.first.class
assert @lst.first.name.to_s.start_with?("implicit_block_")
assert_equal Vool::LambdaStatement , @lst.first.value.class
assert_equal Vool::LambdaExpression , @lst.first.value.class
end
def test_last_send
assert_equal 2 , @lst.length

View File

@ -41,7 +41,7 @@ module Ruby
assert @lst.first.first.name.to_s.start_with?("implicit_block")
end
def test_block_assign_right
assert_equal Vool::LambdaStatement , @lst.first.first.value.class
assert_equal Vool::LambdaExpression , @lst.first.first.value.class
end
def test_a_assign
assert_equal Vool::LocalAssignment , @lst.first.last.class

View File

@ -55,8 +55,8 @@ module Ruby
class TestVariablesVool < MiniTest::Test
include RubyTests
def test_local_basic
lst = compile( "foo = 1 ; foo").to_vool
assert_equal Vool::LocalVariable , lst.statements[1].class
lst = compile( "foo = 1 ; return foo").to_vool
assert_equal Vool::LocalVariable , lst.statements[1].return_value.class
end
def test_instance_basic

View File

@ -0,0 +1,41 @@
require_relative "helper"
module RubyX
class TestDatObjectCompile #< MiniTest::Test
include ParfaitHelper
def setup
@compiler = compiler
@compiler.ruby_to_vool load_parfait(:object)
end
def source
load_parfait(:data_object)
end
def test_load
assert source.include?("class DataObject")
assert source.length > 1500 , source.length
end
def test_vool
vool = @compiler.ruby_to_vool source
assert_equ Vool::ScopeStatement , vool.class
assert_equal Vool::ClassStatement , vool[0].class
assert_equal Vool::ScopeStatement , vool[1].class
assert_equal Vool::ClassStatement , vool[1][0].class
assert_equal :DataObject , vool[1][0].name
assert_equal :Data4 , vool[1][1].name
assert_equal :Data8 , vool[1][2].name
end
def test_mom
mom = @compiler.ruby_to_mom source
assert_equal Mom::MomCollection , mom.class
end
def qtest_risc
risc = compiler.ruby_to_risc source
assert_equal Risc::RiscCollection , risc.class
end
def qtest_binary
risc = compiler.ruby_to_binary source , :interpreter
assert_equal Risc::Linker , risc.class
end
end
end

View File

@ -0,0 +1,32 @@
require_relative "helper"
module RubyX
class TestIntegerCompile < MiniTest::Test
include ParfaitHelper
def source
load_parfait(:integer)
end
def test_load
assert source.include?("class Integer")
assert source.length > 2000
end
def qtest_vool
vool = compiler.ruby_to_vool source
assert_equal Vool::ClassStatement , vool.class
assert_equal :Object , vool.name
end
def qtest_mom
mom = compiler.ruby_to_mom source
assert_equal Mom::MomCollection , mom.class
end
def qtest_risc
risc = compiler.ruby_to_risc source
assert_equal Risc::RiscCollection , risc.class
end
def qtest_binary
risc = compiler.ruby_to_binary source , :interpreter
assert_equal Risc::Linker , risc.class
end
end
end