From d140ef2435c195176b2a95058fcf303d8510a858 Mon Sep 17 00:00:00 2001 From: Markus Schirp Date: Fri, 10 Aug 2012 20:44:45 +0200 Subject: [PATCH] Embedding node into block under constant * Creates exactly the same ast as the ruby parser would do. --- lib/mutant/context/constant.rb | 3 ++- spec/unit/mutant/context/constant/root_spec.rb | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/mutant/context/constant.rb b/lib/mutant/context/constant.rb index cd5019ba..29bbdf3d 100644 --- a/lib/mutant/context/constant.rb +++ b/lib/mutant/context/constant.rb @@ -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 diff --git a/spec/unit/mutant/context/constant/root_spec.rb b/spec/unit/mutant/context/constant/root_spec.rb index e931a434..1c01b38e 100644 --- a/spec/unit/mutant/context/constant/root_spec.rb +++ b/spec/unit/mutant/context/constant/root_spec.rb @@ -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