Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unfreeze string literals for ParseNode#inspect #1016

Merged
merged 1 commit into from Aug 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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