2017-04-02 19:13:14 +03:00
|
|
|
require_relative "helper"
|
2017-04-02 12:59:07 +03:00
|
|
|
|
2018-07-19 14:46:51 +03:00
|
|
|
module Ruby
|
2019-08-16 18:42:57 +03:00
|
|
|
class TestAssignmentRuby < MiniTest::Test
|
2018-06-29 22:46:39 +03:00
|
|
|
include RubyTests
|
2017-04-02 12:59:07 +03:00
|
|
|
|
|
|
|
def test_local
|
2018-06-29 22:46:39 +03:00
|
|
|
lst = compile( "foo = bar")
|
2017-04-02 12:59:07 +03:00
|
|
|
assert_equal LocalAssignment , lst.class
|
|
|
|
end
|
|
|
|
def test_local_name
|
2018-06-29 22:46:39 +03:00
|
|
|
lst = compile( "foo = bar")
|
2017-04-02 12:59:07 +03:00
|
|
|
assert_equal :foo , lst.name
|
|
|
|
end
|
2017-04-04 18:10:28 +03:00
|
|
|
def test_instance
|
2018-06-29 22:46:39 +03:00
|
|
|
lst = compile( "@foo = bar")
|
2017-04-12 20:29:45 +03:00
|
|
|
assert_equal IvarAssignment , lst.class
|
2017-04-04 18:10:28 +03:00
|
|
|
end
|
|
|
|
def test_instance_name
|
2018-06-29 22:46:39 +03:00
|
|
|
lst = compile( "@foo = bar")
|
2017-04-04 18:10:28 +03:00
|
|
|
assert_equal :foo , lst.name
|
|
|
|
end
|
2017-09-10 13:33:32 +03:00
|
|
|
def test_const
|
2018-06-29 22:46:39 +03:00
|
|
|
lst = compile( "@foo = 5")
|
2017-09-10 13:33:32 +03:00
|
|
|
assert_equal IvarAssignment , lst.class
|
|
|
|
end
|
2018-07-20 13:43:37 +03:00
|
|
|
end
|
2019-10-04 00:36:49 +03:00
|
|
|
class TestAssignmentSolLocal < MiniTest::Test
|
2018-07-20 13:43:37 +03:00
|
|
|
include RubyTests
|
2018-07-20 18:13:58 +03:00
|
|
|
def setup
|
2019-10-04 00:36:49 +03:00
|
|
|
@lst = compile( "foo = bar").to_sol
|
2018-07-20 18:13:58 +03:00
|
|
|
end
|
2019-08-16 18:42:57 +03:00
|
|
|
def test_tos
|
|
|
|
assert_equal "foo = self.bar()" , @lst.to_s
|
|
|
|
end
|
2018-07-20 13:43:37 +03:00
|
|
|
def test_local
|
2019-10-04 00:36:49 +03:00
|
|
|
assert_equal Sol::LocalAssignment , @lst.class
|
2018-07-20 18:13:58 +03:00
|
|
|
end
|
|
|
|
def test_bar
|
2019-10-04 00:36:49 +03:00
|
|
|
assert_equal Sol::SendStatement , @lst.value.class
|
2018-07-20 13:43:37 +03:00
|
|
|
end
|
|
|
|
def test_local_name
|
2018-07-20 18:13:58 +03:00
|
|
|
assert_equal :foo , @lst.name
|
|
|
|
end
|
|
|
|
end
|
2019-10-04 00:36:49 +03:00
|
|
|
class TestAssignmentSolInst < MiniTest::Test
|
2018-07-20 18:13:58 +03:00
|
|
|
include RubyTests
|
|
|
|
def setup
|
2019-10-04 00:36:49 +03:00
|
|
|
@lst = compile( "@foo = bar").to_sol
|
2018-07-20 13:43:37 +03:00
|
|
|
end
|
2019-08-16 18:42:57 +03:00
|
|
|
def test_tos
|
|
|
|
assert_equal "@foo = self.bar()" , @lst.to_s
|
|
|
|
end
|
2018-07-20 13:43:37 +03:00
|
|
|
def test_instance
|
2019-10-04 00:36:49 +03:00
|
|
|
assert_equal Sol::IvarAssignment , @lst.class
|
2018-07-20 13:43:37 +03:00
|
|
|
end
|
|
|
|
def test_instance_name
|
2018-07-20 18:13:58 +03:00
|
|
|
assert_equal :foo , @lst.name
|
|
|
|
end
|
|
|
|
end
|
2019-10-04 00:36:49 +03:00
|
|
|
class TestAssignmentSolConst < MiniTest::Test
|
2018-07-20 18:13:58 +03:00
|
|
|
include RubyTests
|
|
|
|
def setup
|
2019-10-04 00:36:49 +03:00
|
|
|
@lst = compile( "foo = 5").to_sol
|
2018-07-20 13:43:37 +03:00
|
|
|
end
|
|
|
|
def test_const
|
2019-10-04 00:36:49 +03:00
|
|
|
assert_equal Sol::IntegerConstant , @lst.value.class
|
2018-07-20 13:43:37 +03:00
|
|
|
end
|
2017-04-02 12:59:07 +03:00
|
|
|
end
|
|
|
|
end
|