2014-06-26 16:52:15 +02:00
|
|
|
require_relative "virtual_helper"
|
|
|
|
|
|
|
|
class TestBasic < MiniTest::Test
|
|
|
|
# include the magic (setup and parse -> test method translation), see there
|
|
|
|
include VirtualHelper
|
2014-07-01 14:57:13 +02:00
|
|
|
|
2014-06-26 16:52:15 +02:00
|
|
|
def test_number
|
|
|
|
@string_input = '42 '
|
2014-06-26 17:39:02 +02:00
|
|
|
@output = [Virtual::IntegerConstant.new(42)]
|
2014-06-26 16:52:15 +02:00
|
|
|
check
|
|
|
|
end
|
|
|
|
|
2014-07-01 14:57:13 +02:00
|
|
|
def test_true
|
|
|
|
@string_input = 'true '
|
|
|
|
@output = [Virtual::TrueValue.new()]
|
|
|
|
check
|
|
|
|
end
|
|
|
|
def test_false
|
|
|
|
@string_input = 'false '
|
|
|
|
@output = [Virtual::FalseValue.new()]
|
|
|
|
check
|
|
|
|
end
|
|
|
|
def test_nil
|
|
|
|
@string_input = 'nil '
|
|
|
|
@output = [Virtual::NilValue.new()]
|
|
|
|
check
|
|
|
|
end
|
|
|
|
|
2014-06-26 16:52:15 +02:00
|
|
|
def test_name
|
|
|
|
@string_input = 'foo '
|
2014-07-10 16:14:38 +02:00
|
|
|
@output = [Virtual::FrameSend.new(:foo)]
|
2014-06-29 18:05:35 +02:00
|
|
|
check
|
2014-06-26 16:52:15 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_instance_variable
|
|
|
|
@string_input = '@foo_bar '
|
|
|
|
@parse_output = {:instance_variable=>{:name=>"foo_bar"}}
|
|
|
|
@output = Ast::VariableExpression.new(:foo_bar)
|
2014-06-29 18:05:35 +02:00
|
|
|
check
|
2014-06-26 16:52:15 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_module_name
|
|
|
|
@string_input = 'FooBar '
|
2014-07-13 13:12:43 +02:00
|
|
|
@output = [Boot::MetaClass.new(:FooBar)]
|
2014-06-29 18:05:35 +02:00
|
|
|
check
|
2014-06-26 16:52:15 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_string
|
|
|
|
@string_input = "\"hello\""
|
2014-07-12 20:59:17 +02:00
|
|
|
@output = [Virtual::StringConstant.new('hello')]
|
2014-06-29 18:05:35 +02:00
|
|
|
check
|
2014-06-26 16:52:15 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|