2015-11-07 12:18:08 +02:00
|
|
|
require_relative "helper"
|
2014-06-26 17:52:15 +03:00
|
|
|
|
2015-07-18 15:28:57 +03:00
|
|
|
|
2014-06-26 17:52:15 +03:00
|
|
|
class TestBasic < MiniTest::Test
|
2015-11-07 12:18:08 +02:00
|
|
|
include ExpressionHelper
|
2015-10-06 00:27:13 +03:00
|
|
|
|
2015-10-10 10:02:28 +03:00
|
|
|
def setup
|
|
|
|
@root = :basic_type
|
2015-10-13 16:42:53 +03:00
|
|
|
@output = Register::RegisterValue
|
2015-07-18 15:28:57 +03:00
|
|
|
end
|
2014-07-01 15:57:13 +03:00
|
|
|
|
2014-06-26 17:52:15 +03:00
|
|
|
def test_number
|
|
|
|
@string_input = '42 '
|
2015-11-07 12:18:08 +02:00
|
|
|
assert_equal 42 , check.value
|
2014-06-26 17:52:15 +03:00
|
|
|
end
|
|
|
|
|
2014-07-01 15:57:13 +03:00
|
|
|
def test_true
|
2015-10-13 16:42:53 +03:00
|
|
|
@string_input = 'true'
|
2014-07-01 15:57:13 +03:00
|
|
|
check
|
|
|
|
end
|
|
|
|
def test_false
|
|
|
|
@string_input = 'false '
|
|
|
|
check
|
|
|
|
end
|
|
|
|
def test_nil
|
|
|
|
@string_input = 'nil '
|
|
|
|
check
|
|
|
|
end
|
|
|
|
|
2015-09-27 16:06:48 +03:00
|
|
|
def test_var
|
|
|
|
@string_input = 'int foo '
|
2015-10-10 10:02:28 +03:00
|
|
|
@root = :field_def
|
2015-10-13 16:42:53 +03:00
|
|
|
@output = AST::Node
|
2014-06-29 19:05:35 +03:00
|
|
|
check
|
2014-06-26 17:52:15 +03:00
|
|
|
end
|
|
|
|
|
2014-07-14 14:29:33 +03:00
|
|
|
def test_self
|
|
|
|
@string_input = 'self '
|
|
|
|
check
|
|
|
|
end
|
|
|
|
|
2015-11-07 12:18:08 +02:00
|
|
|
def test_space
|
|
|
|
@string_input = 'self '
|
|
|
|
check
|
|
|
|
end
|
|
|
|
|
2014-06-26 17:52:15 +03:00
|
|
|
def test_string
|
|
|
|
@string_input = "\"hello\""
|
2014-06-29 19:05:35 +03:00
|
|
|
check
|
2014-06-26 17:52:15 +03:00
|
|
|
end
|
|
|
|
|
2015-05-05 14:04:37 +03:00
|
|
|
end
|