Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
Commit 7b319103 authored by Konstantin Makarchev's avatar Konstantin Makarchev
Browse files

fix for #147, add macro identify

parent 305111bd
Branches
Tags
No related merge requests found
......@@ -261,6 +261,11 @@ describe "MacroExpander" do
assert_macro "", %({{[1, 2, 3].empty?}}), [] of ASTNode, "false"
end
it "executes identify" do
assert_macro "", %({{"A::B".identify}}), [] of ASTNode, "\"A__B\""
assert_macro "", %({{"A".identify}}), [] of ASTNode, "\"A\""
end
it "executes join" do
assert_macro "", %({{[1, 2, 3].join ", "}}), [] of ASTNode, %("1, 2, 3")
end
......
......@@ -557,6 +557,8 @@ module Crystal
interpret_argless_method(method, args) { StringLiteral.new(@value.downcase) }
when "empty?"
interpret_argless_method(method, args) { BoolLiteral.new(@value.empty?) }
when "identify"
interpret_argless_method(method, args) { StringLiteral.new(@value.tr(":", "_")) }
when "length"
interpret_argless_method(method, args) { NumberLiteral.new(@value.length, :i32) }
when "lines"
......
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