mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
AST node source code
This commit is contained in:
parent
adfe654733
commit
a9421ee79b
2 changed files with 49 additions and 0 deletions
|
@ -45,5 +45,31 @@ module Ameba::AST
|
|||
subject.string_literal?(Crystal::Nop.new).should be_false
|
||||
end
|
||||
end
|
||||
|
||||
describe "#node_source" do
|
||||
it "returns original source of the node" do
|
||||
s = %(
|
||||
a = 1
|
||||
)
|
||||
node = Crystal::Parser.new(s).parse
|
||||
source = subject.node_source node, s.split("\n")
|
||||
source.should eq ["a = 1"]
|
||||
end
|
||||
|
||||
it "returns original source of multiline node" do
|
||||
s = %(
|
||||
if ()
|
||||
:ok
|
||||
end
|
||||
)
|
||||
node = Crystal::Parser.new(s).parse
|
||||
source = subject.node_source node, s.split("\n")
|
||||
source.should eq([
|
||||
"if ()",
|
||||
" :ok",
|
||||
" end",
|
||||
])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue