introducing expressions and constants
not everything statement anymore (as in ruby) basic statement tests working, rest havoc
This commit is contained in:
@ -5,31 +5,31 @@ module Vool
|
||||
|
||||
def test_self
|
||||
lst = RubyCompiler.compile( "self")
|
||||
assert_equal SelfStatement , lst.class
|
||||
assert_equal SelfExpression , lst.class
|
||||
end
|
||||
def test_nil
|
||||
lst = RubyCompiler.compile( "nil")
|
||||
assert_equal NilStatement , lst.class
|
||||
assert_equal NilConstant , lst.class
|
||||
end
|
||||
def test_false
|
||||
lst = RubyCompiler.compile( "false")
|
||||
assert_equal FalseStatement , lst.class
|
||||
assert_equal FalseConstant , lst.class
|
||||
end
|
||||
def test_true
|
||||
lst = RubyCompiler.compile( "true")
|
||||
assert_equal TrueStatement , lst.class
|
||||
assert_equal TrueConstant , lst.class
|
||||
end
|
||||
def test_integer
|
||||
lst = RubyCompiler.compile( "123")
|
||||
assert_equal IntegerStatement , lst.class
|
||||
assert_equal IntegerConstant , lst.class
|
||||
end
|
||||
def test_string
|
||||
lst = RubyCompiler.compile( "'string'")
|
||||
assert_equal StringStatement , lst.class , lst.inspect
|
||||
assert_equal StringConstant , lst.class , lst.inspect
|
||||
end
|
||||
def test_sym
|
||||
lst = RubyCompiler.compile( ":symbol")
|
||||
assert_equal SymbolStatement , lst.class , lst.inspect
|
||||
assert_equal SymbolConstant , lst.class , lst.inspect
|
||||
end
|
||||
def test_dstr
|
||||
assert_raises RuntimeError do
|
||||
|
@ -37,7 +37,7 @@ module Vool
|
||||
def test_compile_two_methods
|
||||
lst = RubyCompiler.compile( in_Test("false; true;") )
|
||||
assert_equal ScopeStatement , lst.body.class
|
||||
assert_equal TrueStatement , lst.body.statements[1].class
|
||||
assert_equal TrueConstant , lst.body.statements[1].class
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -16,7 +16,7 @@ module Vool
|
||||
end
|
||||
def test_if_basic_branches
|
||||
lst = RubyCompiler.compile( basic_if )
|
||||
assert_equal TrueStatement , lst.if_true.class
|
||||
assert_equal TrueConstant , lst.if_true.class
|
||||
assert_nil lst.if_false
|
||||
end
|
||||
|
||||
@ -29,12 +29,12 @@ module Vool
|
||||
end
|
||||
def test_if_double_cond
|
||||
lst = RubyCompiler.compile( double_if )
|
||||
assert_equal FalseStatement , lst.condition.class
|
||||
assert_equal FalseConstant , lst.condition.class
|
||||
end
|
||||
def test_if_double_branches
|
||||
lst = RubyCompiler.compile( double_if )
|
||||
assert_equal TrueStatement , lst.if_true.class
|
||||
assert_equal FalseStatement, lst.if_false.class
|
||||
assert_equal TrueConstant , lst.if_true.class
|
||||
assert_equal FalseConstant, lst.if_false.class
|
||||
end
|
||||
|
||||
def reverse_if
|
||||
@ -46,11 +46,11 @@ module Vool
|
||||
end
|
||||
def test_if_reverse_cond
|
||||
lst = RubyCompiler.compile( reverse_if )
|
||||
assert_equal FalseStatement , lst.condition.class
|
||||
assert_equal FalseConstant , lst.condition.class
|
||||
end
|
||||
def test_if_reverse_branches
|
||||
lst = RubyCompiler.compile( reverse_if )
|
||||
assert_equal TrueStatement , lst.if_true.class
|
||||
assert_equal TrueConstant , lst.if_true.class
|
||||
assert_nil lst.if_false
|
||||
end
|
||||
|
||||
@ -63,12 +63,12 @@ module Vool
|
||||
end
|
||||
def test_if_reverse_cond
|
||||
lst = RubyCompiler.compile( reverse_unless )
|
||||
assert_equal FalseStatement , lst.condition.class
|
||||
assert_equal FalseConstant , lst.condition.class
|
||||
end
|
||||
def test_if_reverse_branches
|
||||
lst = RubyCompiler.compile( reverse_unless )
|
||||
assert_nil lst.if_true
|
||||
assert_equal TrueStatement ,lst.if_false.class
|
||||
assert_equal TrueConstant ,lst.if_false.class
|
||||
end
|
||||
|
||||
def ternary
|
||||
@ -80,12 +80,12 @@ module Vool
|
||||
end
|
||||
def test_if_ternary_cond
|
||||
lst = RubyCompiler.compile( ternary )
|
||||
assert_equal FalseStatement , lst.condition.class
|
||||
assert_equal FalseConstant , lst.condition.class
|
||||
end
|
||||
def test_if_ternary_branches
|
||||
lst = RubyCompiler.compile( ternary )
|
||||
assert_equal TrueStatement , lst.if_true.class
|
||||
assert_equal FalseStatement, lst.if_false.class
|
||||
assert_equal TrueConstant , lst.if_true.class
|
||||
assert_equal FalseConstant, lst.if_false.class
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -13,7 +13,7 @@ module Vool
|
||||
end
|
||||
def test_simple_receiver
|
||||
lst = RubyCompiler.compile( "foo")
|
||||
assert_equal SelfStatement , lst.receiver.class
|
||||
assert_equal SelfExpression , lst.receiver.class
|
||||
end
|
||||
def test_simple_args
|
||||
lst = RubyCompiler.compile( "foo")
|
||||
@ -30,7 +30,7 @@ module Vool
|
||||
end
|
||||
def test_one_arg_receiver
|
||||
lst = RubyCompiler.compile( "bar(1)")
|
||||
assert_equal SelfStatement , lst.receiver.class
|
||||
assert_equal SelfExpression , lst.receiver.class
|
||||
end
|
||||
def test_one_arg_args
|
||||
lst = RubyCompiler.compile( "bar(1)")
|
||||
@ -39,7 +39,7 @@ module Vool
|
||||
|
||||
def test_super0_receiver
|
||||
lst = RubyCompiler.compile( "super")
|
||||
assert_equal SuperStatement , lst.receiver.class
|
||||
assert_equal SuperExpression , lst.receiver.class
|
||||
end
|
||||
def test_super0
|
||||
lst = RubyCompiler.compile( "super")
|
||||
@ -48,7 +48,7 @@ module Vool
|
||||
|
||||
def test_super_receiver
|
||||
lst = RubyCompiler.compile( "super(1)")
|
||||
assert_equal SuperStatement , lst.receiver.class
|
||||
assert_equal SuperExpression , lst.receiver.class
|
||||
end
|
||||
def test_super_args
|
||||
lst = RubyCompiler.compile( "super(1)")
|
||||
|
@ -16,7 +16,7 @@ module Vool
|
||||
end
|
||||
def test_while_basic_branches
|
||||
lst = RubyCompiler.compile( basic_while )
|
||||
assert_equal TrueStatement , lst.statements.class
|
||||
assert_equal TrueConstant , lst.statements.class
|
||||
end
|
||||
|
||||
def reverse_while
|
||||
@ -28,11 +28,11 @@ module Vool
|
||||
end
|
||||
def test_while_reverse_cond
|
||||
lst = RubyCompiler.compile( reverse_while )
|
||||
assert_equal FalseStatement , lst.condition.class
|
||||
assert_equal FalseConstant , lst.condition.class
|
||||
end
|
||||
def test_while_reverse_branches
|
||||
lst = RubyCompiler.compile( reverse_while )
|
||||
assert_equal TrueStatement , lst.statements.class
|
||||
assert_equal TrueConstant , lst.statements.class
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user