Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/syntax_tree/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def format(q)
q.text(value)
else
q.text(q.quote)
q.text(value[1] == "\"" ? "\\\"" : value[1])
q.text(value[1] == q.quote ? "\\#{q.quote}" : value[1])
q.text(q.quote)
end
end
Expand Down
8 changes: 8 additions & 0 deletions test/plugin/single_quotes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ def test_empty_string_literal
assert_format("''\n", "\"\"")
end

def test_character_literal_with_double_quote
assert_format("'\"'\n", "?\"")
end

def test_character_literal_with_singlee_quote
assert_format("'\\''\n", "?'")
end

def test_string_literal
assert_format("'string'\n", "\"string\"")
end
Expand Down