Embedding node into block under constant

* Creates exactly the same ast as the ruby parser would do.
This commit is contained in:
Markus Schirp 2012-08-10 20:44:45 +02:00
parent e238890f2c
commit d140ef2435
2 changed files with 6 additions and 3 deletions

View file

@ -35,7 +35,8 @@ module Mutant
#
def root(node)
root = root_ast
root.body = @scope_class.new(1, root.name, node)
block = Rubinius::AST::Block.new(1, [node])
root.body = @scope_class.new(1, root.name, block)
Rubinius::AST::Script.new(root)
end

View file

@ -16,7 +16,9 @@ describe Mutant::Context::Constant, '#root' do
scope.should be_kind_of(Rubinius::AST::ModuleScope)
end
it 'should place the ast under scope' do
scope_body.should be(node)
it 'should place the ast under scope inside of block' do
scope_body.should be_a(Rubinius::AST::Block)
scope_body.array.should eql([node])
scope_body.array.first.should be(node)
end
end