Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
Commit ef755e19 authored by Ary Borenszweig's avatar Ary Borenszweig
Browse files

Added StringLiteral#chomp in macros

parent a525575a
Branches
Tags 0.4.4
No related merge requests found
...@@ -278,6 +278,10 @@ describe "MacroExpander" do ...@@ -278,6 +278,10 @@ describe "MacroExpander" do
it "executes string [Range] exclusive" do it "executes string [Range] exclusive" do
assert_macro "", %({{"hello"[1...-2]}}), [] of ASTNode, %("el") assert_macro "", %({{"hello"[1...-2]}}), [] of ASTNode, %("el")
end end
it "executes string chomp" do
assert_macro "", %({{"hello\n".chomp}}), [] of ASTNode, %("hello")
end
end end
describe "array methods" do describe "array methods" do
......
...@@ -729,6 +729,8 @@ module Crystal ...@@ -729,6 +729,8 @@ module Crystal
end end
when "capitalize" when "capitalize"
interpret_argless_method(method, args) { StringLiteral.new(@value.capitalize) } interpret_argless_method(method, args) { StringLiteral.new(@value.capitalize) }
when "chomp"
interpret_argless_method(method, args) { StringLiteral.new(@value.chomp) }
when "downcase" when "downcase"
interpret_argless_method(method, args) { StringLiteral.new(@value.downcase) } interpret_argless_method(method, args) { StringLiteral.new(@value.downcase) }
when "empty?" when "empty?"
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment