Skip to content

Commit

Permalink
Unfreeze string literals for ParseNode#inspect
Browse files Browse the repository at this point in the history
  • Loading branch information
Jalyna Schroeder committed Aug 6, 2019
1 parent a054e2a commit bc88181
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/haml/parser.rb
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions test/parser_test.rb
Expand Up @@ -96,6 +96,14 @@ 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]"
Expand Down

0 comments on commit bc88181

Please sign in to comment.