From 1ea26c432d5bed7349a515889870f6ed2cd945bc Mon Sep 17 00:00:00 2001 From: Jalyna Schroeder Date: Tue, 6 Aug 2019 11:00:17 +0200 Subject: [PATCH] Unfreeze string literals for ParseNode#inspect --- lib/haml/parser.rb | 2 +- test/parser_test.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/haml/parser.rb b/lib/haml/parser.rb index c5b339ba75..d0b23cf19d 100644 --- a/lib/haml/parser.rb +++ b/lib/haml/parser.rb @@ -202,7 +202,7 @@ def initialize(*args) end def inspect - %Q[(#{type} #{value.inspect}#{children.each_with_object('') {|c, s| s << "\n#{c.inspect.gsub!(/^/, ' ')}"}})] + %Q[(#{type} #{value.inspect}#{children.each_with_object(''.dup) {|c, s| s << "\n#{c.inspect.gsub!(/^/, ' ')}"}})].dup end end diff --git a/test/parser_test.rb b/test/parser_test.rb index 1a62490d10..972aa1f2b4 100644 --- a/test/parser_test.rb +++ b/test/parser_test.rb @@ -96,6 +96,15 @@ class ParserTest < Haml::TestCase end end + test "inspect for node with children returns text" do + text = "some revealed text" + cond = "[cond]" + + node = parse("/!#{cond} #{text}") + + assert_equal "(root nil\n (comment {:conditional=>\"[cond]\", :text=>\"some revealed text\", :revealed=>true, :parse=>false}))", node.inspect + end + test "revealed conditional comments are detected" do text = "some revealed text" cond = "[cond]"