rubyx/test/ruby/test_basic_values.rb

81 lines
1.9 KiB
Ruby
Raw Normal View History

require_relative "helper"
2017-04-02 08:44:56 +02:00
module Ruby
2018-07-19 15:30:36 +02:00
class TestBasicValues < MiniTest::Test
include RubyTests
2017-04-02 08:44:56 +02:00
2017-04-02 11:57:05 +02:00
def test_self
lst = compile( "self")
assert_equal SelfExpression , lst.class
2017-04-02 11:57:05 +02:00
end
2017-04-02 08:44:56 +02:00
def test_nil
lst = compile( "nil")
assert_equal NilConstant , lst.class
2017-04-02 08:44:56 +02:00
end
def test_false
lst = compile( "false")
assert_equal FalseConstant , lst.class
2017-04-02 08:44:56 +02:00
end
def test_true
lst = compile( "true")
assert_equal TrueConstant , lst.class
2017-04-02 08:44:56 +02:00
end
def test_integer
lst = compile( "123")
assert_equal IntegerConstant , lst.class
2017-04-02 08:44:56 +02:00
end
def test_string
lst = compile( "'string'")
assert_equal StringConstant , lst.class , lst.inspect
2017-04-02 08:44:56 +02:00
end
def test_sym
lst = compile( ":symbol")
assert_equal SymbolConstant , lst.class , lst.inspect
end
def test_dstr
assert_raises RuntimeError do
compile( '"dstr#{self}"')
end
end
def test_scope
lst = compile( "begin ; 1 ; end")
assert_equal ScopeStatement , lst.class , lst.inspect
end
def test_scope_contents
lst = compile( "begin ; 1 ; end")
assert_equal 1 , lst.statements.first.value
end
2017-04-02 08:44:56 +02:00
end
2018-07-19 15:30:36 +02:00
class TestBasicTypes < MiniTest::Test
include RubyTests
def setup
Parfait.boot!
end
def compile_ct( input )
lst = compile( input )
2018-07-19 15:30:36 +02:00
lst.ct_type.class_name
end
def test_integer
2018-07-19 15:30:36 +02:00
assert_equal :Integer , compile_ct( "123")
end
def test_string
2018-07-19 15:30:36 +02:00
assert_equal :Word , compile_ct( "'string'")
end
def test_sym
2018-07-19 15:30:36 +02:00
assert_equal :Word , compile_ct( ":symbol")
end
# classes fot these are not implemented in parfait yet
def pest_nil
2018-07-19 15:30:36 +02:00
assert_equal :Nil , compile_ct( "nil")
end
def pest_false
2018-07-19 15:30:36 +02:00
assert_equal :False , compile_ct( "false")
end
def pest_true
2018-07-19 15:30:36 +02:00
assert_equal :True , compile_ct( "true")
end
end
2017-04-02 08:44:56 +02:00
end