Fix super as statement

Super is a statement, a send really.
Not an expression (as maybe in c++)
The actual implementation will be a bit tricky, like raise, a bit of stack walking, but not impossible. Still, later
This commit is contained in:
2019-08-19 18:48:13 +03:00
parent 0e694a38f7
commit 57b0ad2c32
10 changed files with 47 additions and 38 deletions

View File

@ -44,16 +44,16 @@ module Ruby
include RubyTests
def test_super0_receiver
lst = compile( "super")
assert_equal SuperExpression , lst.receiver.class
assert_equal SelfExpression , lst.receiver.class
end
def test_super0
lst = compile( "super")
assert_equal SendStatement , lst.class
assert_equal SuperStatement , lst.class
end
def test_super_receiver
lst = compile( "super(1)")
assert_equal SuperExpression , lst.receiver.class
assert_equal SelfExpression , lst.receiver.class
end
def test_super_args
lst = compile( "super(1)")
@ -61,7 +61,7 @@ module Ruby
end
def test_super_name #is nil
lst = compile( "super(1)")
assert_nil lst.name
assert_equal :super , lst.name
end
class TestSendSendArgs < MiniTest::Test
include RubyTests

View File

@ -41,12 +41,11 @@ module Ruby
include RubyTests
def test_super0
lst = compile( "super").to_vool
assert_equal Vool::Statements , lst.class
assert_equal Vool::SendStatement , lst.last.class
assert_equal Vool::SuperStatement , lst.class
end
def test_super0_receiver
lst = compile( "super").to_vool
assert_equal Vool::SuperExpression , lst.first.value.class
assert_equal Vool::SelfExpression , lst.receiver.class
end
end
class TestSendSuperArgsVool < MiniTest::Test
@ -55,14 +54,13 @@ module Ruby
@lst = compile( "super(1)").to_vool
end
def test_super_class
assert_equal Vool::Statements , @lst.class
assert_equal Vool::SendStatement , @lst.last.class
assert_equal Vool::SuperStatement , @lst.class
end
def test_super_receiver
assert_equal Vool::SuperExpression , @lst.first.value.class
assert_equal Vool::SelfExpression , @lst.receiver.class
end
def test_super_name
assert @lst.first.name.to_s.start_with?("tmp")
assert_equal :super, @lst.name
end
end
class TestSendReceiverTypeVool < MiniTest::Test