summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2010-11-11 15:51:21 +0100
committerBrice Figureau <brice-puppet@daysofwonder.com>2010-11-11 15:51:21 +0100
commit9604f1c4cd5a368da08c6f3219b44908a9b9921c (patch)
treeaaf9e1d52bcf1be6d23078809436b25c68f50011 /spec
parentcc5224c1912f2e95663c14ca803700070130fb69 (diff)
downloadpuppet-9604f1c4cd5a368da08c6f3219b44908a9b9921c.tar.gz
puppet-9604f1c4cd5a368da08c6f3219b44908a9b9921c.tar.xz
puppet-9604f1c4cd5a368da08c6f3219b44908a9b9921c.zip
Fix #5252 - line number mis-attribution during parsing
It is a resurgence of #2366 that appeared because of the commit 8971d8. Before this commit, for associating documentation comments, we were preferring line numbers coming from the parser currently reducing rule, instead of the current lexer line number (which can be in advance of several tokens due to the nature of LALR parsers). We now merge the ast line number before fetching the comment from the lexer. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'spec')
-rwxr-xr-xspec/unit/parser/parser_spec.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/spec/unit/parser/parser_spec.rb b/spec/unit/parser/parser_spec.rb
index f73e07a5c..07e2d220b 100755
--- a/spec/unit/parser/parser_spec.rb
+++ b/spec/unit/parser/parser_spec.rb
@@ -269,16 +269,23 @@ describe Puppet::Parser do
it "should prefer provided options over AST context" do
@class.expects(:new).with { |opts| opts[:file] == "/bar" }
- @parser.expects(:ast_context).returns :file => "/foo"
+ @lexer.expects(:file).returns "/foo"
@parser.ast(@class, :file => "/bar")
end
it "should include docs when the AST class uses them" do
@class.expects(:use_docs).returns true
@class.stubs(:new)
- @parser.expects(:ast_context).with(true).returns({})
+ @parser.expects(:ast_context).with{ |a| a[0] == true }.returns({})
@parser.ast(@class, :file => "/bar")
end
+
+ it "should get docs from lexer using the correct AST line number" do
+ @class.expects(:use_docs).returns true
+ @class.stubs(:new).with{ |a| a[:doc] == "doc" }
+ @lexer.expects(:getcomment).with(12).returns "doc"
+ @parser.ast(@class, :file => "/bar", :line => 12)
+ end
end
describe "when creating a node" do