update reader and implement singletons
This commit is contained in:
parent
94d1140686
commit
7045a4b256
@ -7,7 +7,7 @@ GIT
|
||||
|
||||
GIT
|
||||
remote: https://github.com/ruby-in-ruby/crystal-reader.git
|
||||
revision: 3a56ae1a8d96845bbb80f760626c8203d57cb1c3
|
||||
revision: bc8697c733113b19863df632b546c7eab2b429c0
|
||||
specs:
|
||||
crystal-reader (0.1.0)
|
||||
|
||||
|
@ -9,6 +9,22 @@ module Ast
|
||||
end
|
||||
end
|
||||
|
||||
class TrueExpression
|
||||
def compile frame
|
||||
Virtual::TrueValue.new
|
||||
end
|
||||
end
|
||||
class FalseExpression
|
||||
def compile frame
|
||||
Virtual::FalseValue.new
|
||||
end
|
||||
end
|
||||
class NilExpression
|
||||
def compile frame
|
||||
Virtual::NilValue.new
|
||||
end
|
||||
end
|
||||
|
||||
class NameExpression < Expression
|
||||
# attr_reader :name
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
module Virtual
|
||||
|
||||
class Constant < ::Virtual::Object
|
||||
|
||||
end
|
||||
|
||||
# another abstract "marker" class (so we can check for it)
|
||||
|
@ -1,6 +1,6 @@
|
||||
module Virtual
|
||||
class Mystery < Value
|
||||
def initilize
|
||||
def initialize
|
||||
end
|
||||
|
||||
def as type
|
||||
@ -8,4 +8,11 @@ module Virtual
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class TrueValue < Value
|
||||
end
|
||||
class FalseValue < Value
|
||||
end
|
||||
class NilValue < Value
|
||||
end
|
||||
end
|
||||
|
@ -6,6 +6,12 @@ module Virtual
|
||||
# Integer and (Object) References are the main derived classes, but float will come and ...
|
||||
# The Mystery Value has unknown type and has only casting methods. So it must be cast to be useful.
|
||||
class Value
|
||||
def == other
|
||||
other.class == self.class
|
||||
end
|
||||
def inspect
|
||||
self.class.name + ".new()"
|
||||
end
|
||||
def type
|
||||
self.class
|
||||
end
|
||||
|
@ -1,2 +1 @@
|
||||
require_relative "fragments/test_all"
|
||||
require_relative "test_intel"
|
||||
|
@ -3,13 +3,29 @@ require_relative "virtual_helper"
|
||||
class TestBasic < MiniTest::Test
|
||||
# include the magic (setup and parse -> test method translation), see there
|
||||
include VirtualHelper
|
||||
|
||||
|
||||
def test_number
|
||||
@string_input = '42 '
|
||||
@output = [Virtual::IntegerConstant.new(42)]
|
||||
check
|
||||
end
|
||||
|
||||
def test_true
|
||||
@string_input = 'true '
|
||||
@output = [Virtual::TrueValue.new()]
|
||||
check
|
||||
end
|
||||
def test_false
|
||||
@string_input = 'false '
|
||||
@output = [Virtual::FalseValue.new()]
|
||||
check
|
||||
end
|
||||
def test_nil
|
||||
@string_input = 'nil '
|
||||
@output = [Virtual::NilValue.new()]
|
||||
check
|
||||
end
|
||||
|
||||
def test_name
|
||||
@string_input = 'foo '
|
||||
@output = [nil]
|
||||
|
Loading…
Reference in New Issue
Block a user