2017-04-02 18:13:14 +02:00
|
|
|
require_relative "helper"
|
2017-04-02 08:44:56 +02:00
|
|
|
|
|
|
|
module Vool
|
|
|
|
class TestBasicValues < MiniTest::Test
|
|
|
|
|
2017-04-02 11:57:05 +02:00
|
|
|
def test_self
|
2017-04-06 14:36:41 +02:00
|
|
|
lst = RubyCompiler.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
|
2017-04-06 14:36:41 +02:00
|
|
|
lst = RubyCompiler.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
|
2017-04-06 14:36:41 +02:00
|
|
|
lst = RubyCompiler.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
|
2017-04-06 14:36:41 +02:00
|
|
|
lst = RubyCompiler.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
|
2017-04-06 14:36:41 +02:00
|
|
|
lst = RubyCompiler.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
|
2017-04-06 14:36:41 +02:00
|
|
|
lst = RubyCompiler.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
|
2017-04-06 14:36:41 +02:00
|
|
|
lst = RubyCompiler.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
|
2017-04-06 14:36:41 +02:00
|
|
|
RubyCompiler.compile( '"dstr#{self}"')
|
2017-04-02 09:43:22 +02:00
|
|
|
end
|
|
|
|
end
|
2017-04-02 12:24:09 +02:00
|
|
|
|
|
|
|
def test_scope
|
2017-04-06 14:36:41 +02:00
|
|
|
lst = RubyCompiler.compile( "begin ; 1 ; end")
|
2017-04-02 12:24:09 +02:00
|
|
|
assert_equal ScopeStatement , lst.class , lst.inspect
|
|
|
|
end
|
|
|
|
def test_scope_contents
|
2017-04-06 14:36:41 +02:00
|
|
|
lst = RubyCompiler.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
|
2017-04-19 19:59:13 +02:00
|
|
|
class TestBasicTypes < MiniTest::Test
|
|
|
|
def setup
|
|
|
|
Risc.machine.boot
|
|
|
|
end
|
|
|
|
def compile( input )
|
|
|
|
lst = RubyCompiler.compile( input )
|
|
|
|
lst.ct_type
|
|
|
|
end
|
|
|
|
def test_integer
|
|
|
|
assert_equal "Integer_Type" , compile( "123").name
|
|
|
|
end
|
|
|
|
def test_string
|
|
|
|
assert_equal "Word_Type" , compile( "'string'").name
|
|
|
|
end
|
|
|
|
def test_sym
|
|
|
|
assert_equal "Word_Type" , compile( ":symbol").name
|
|
|
|
end
|
|
|
|
# classes fot these are not implemented in parfait yet
|
|
|
|
# def pest_nil
|
|
|
|
# assert_equal "Nil_Type" , compile( "nil").name
|
|
|
|
# end
|
|
|
|
# def pest_false
|
|
|
|
# assert_equal "False_Type" , compile( "false").name
|
|
|
|
# end
|
|
|
|
# def pest_true
|
|
|
|
# assert_equal "True_Type" , compile( "true").name
|
|
|
|
# end
|
|
|
|
end
|
2017-04-02 08:44:56 +02:00
|
|
|
end
|