2017-04-02 18:13:14 +02:00
|
|
|
require_relative "helper"
|
2017-04-02 08:44:56 +02:00
|
|
|
|
2018-07-19 13:46:51 +02:00
|
|
|
module Ruby
|
2018-07-07 16:57:46 +02:00
|
|
|
class TestBasicValuesX < MiniTest::Test
|
2018-06-29 21:46:39 +02:00
|
|
|
include RubyTests
|
2017-04-02 08:44:56 +02:00
|
|
|
|
2017-04-02 11:57:05 +02:00
|
|
|
def test_self
|
2018-06-29 21:46:39 +02:00
|
|
|
lst = compile( "self")
|
2018-03-15 06:54:14 +01:00
|
|
|
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
|
2018-06-29 21:46:39 +02:00
|
|
|
lst = compile( "nil")
|
2018-03-15 06:54:14 +01:00
|
|
|
assert_equal NilConstant , lst.class
|
2017-04-02 08:44:56 +02:00
|
|
|
end
|
|
|
|
def test_false
|
2018-06-29 21:46:39 +02:00
|
|
|
lst = compile( "false")
|
2018-03-15 06:54:14 +01:00
|
|
|
assert_equal FalseConstant , lst.class
|
2017-04-02 08:44:56 +02:00
|
|
|
end
|
|
|
|
def test_true
|
2018-06-29 21:46:39 +02:00
|
|
|
lst = compile( "true")
|
2018-03-15 06:54:14 +01:00
|
|
|
assert_equal TrueConstant , lst.class
|
2017-04-02 08:44:56 +02:00
|
|
|
end
|
|
|
|
def test_integer
|
2018-06-29 21:46:39 +02:00
|
|
|
lst = compile( "123")
|
2018-03-15 06:54:14 +01:00
|
|
|
assert_equal IntegerConstant , lst.class
|
2017-04-02 08:44:56 +02:00
|
|
|
end
|
|
|
|
def test_string
|
2018-06-29 21:46:39 +02:00
|
|
|
lst = compile( "'string'")
|
2018-03-15 06:54:14 +01:00
|
|
|
assert_equal StringConstant , lst.class , lst.inspect
|
2017-04-02 08:44:56 +02:00
|
|
|
end
|
2017-04-02 09:43:22 +02:00
|
|
|
def test_sym
|
2018-06-29 21:46:39 +02:00
|
|
|
lst = compile( ":symbol")
|
2018-03-15 06:54:14 +01:00
|
|
|
assert_equal SymbolConstant , lst.class , lst.inspect
|
2017-04-02 09:43:22 +02:00
|
|
|
end
|
|
|
|
def test_dstr
|
|
|
|
assert_raises RuntimeError do
|
2018-06-29 21:46:39 +02:00
|
|
|
compile( '"dstr#{self}"')
|
2017-04-02 09:43:22 +02:00
|
|
|
end
|
|
|
|
end
|
2017-04-02 12:24:09 +02:00
|
|
|
|
|
|
|
def test_scope
|
2018-06-29 21:46:39 +02:00
|
|
|
lst = compile( "begin ; 1 ; end")
|
2017-04-02 12:24:09 +02:00
|
|
|
assert_equal ScopeStatement , lst.class , lst.inspect
|
|
|
|
end
|
|
|
|
def test_scope_contents
|
2018-06-29 21:46:39 +02:00
|
|
|
lst = compile( "begin ; 1 ; end")
|
2017-04-02 12:24:09 +02:00
|
|
|
assert_equal 1 , lst.statements.first.value
|
|
|
|
end
|
2017-04-02 08:44:56 +02:00
|
|
|
end
|
2018-07-07 16:57:46 +02:00
|
|
|
class TestBasicTypesX < MiniTest::Test
|
2018-06-29 21:46:39 +02:00
|
|
|
include RubyTests
|
|
|
|
|
2017-04-19 19:59:13 +02:00
|
|
|
def setup
|
2018-07-01 13:12:42 +02:00
|
|
|
Parfait.boot!
|
2017-04-19 19:59:13 +02:00
|
|
|
end
|
2018-06-29 21:46:39 +02:00
|
|
|
def compile_ct( input )
|
|
|
|
lst = compile( input )
|
2017-04-19 19:59:13 +02:00
|
|
|
lst.ct_type
|
|
|
|
end
|
|
|
|
def test_integer
|
2018-06-29 21:46:39 +02:00
|
|
|
assert_equal "Integer_Type" , compile_ct( "123").name
|
2017-04-19 19:59:13 +02:00
|
|
|
end
|
|
|
|
def test_string
|
2018-06-29 21:46:39 +02:00
|
|
|
assert_equal "Word_Type" , compile_ct( "'string'").name
|
2017-04-19 19:59:13 +02:00
|
|
|
end
|
|
|
|
def test_sym
|
2018-06-29 21:46:39 +02:00
|
|
|
assert_equal "Word_Type" , compile_ct( ":symbol").name
|
2017-04-19 19:59:13 +02:00
|
|
|
end
|
|
|
|
# classes fot these are not implemented in parfait yet
|
2018-05-17 08:49:01 +02:00
|
|
|
def pest_nil
|
2018-06-29 21:46:39 +02:00
|
|
|
assert_equal "Nil_Type" , compile_ct( "nil").name
|
2018-05-17 08:49:01 +02:00
|
|
|
end
|
|
|
|
def pest_false
|
2018-06-29 21:46:39 +02:00
|
|
|
assert_equal "False_Type" , compile_ct( "false").name
|
2018-05-17 08:49:01 +02:00
|
|
|
end
|
|
|
|
def pest_true
|
2018-06-29 21:46:39 +02:00
|
|
|
assert_equal "True_Type" , compile_ct( "true").name
|
2018-05-17 08:49:01 +02:00
|
|
|
end
|
2017-04-19 19:59:13 +02:00
|
|
|
end
|
2017-04-02 08:44:56 +02:00
|
|
|
end
|