This commit is contained in:
Vitalii Elenhaupt 2017-11-01 13:10:34 +02:00
parent dcc0be892a
commit 6a81a648e3
No known key found for this signature in database
GPG key ID: 7558EF3A4056C706
8 changed files with 56 additions and 13 deletions

View file

@ -1,10 +1,10 @@
require "../spec_helper"
require "../../spec_helper"
module Ameba
module Ameba::AST
rule = DummyRule.new
source = Source.new ""
describe "AST Traverse" do
describe "Traverse" do
{% for name in NODE_VISITORS %}
describe "{{name}}" do
it "allow to visit {{name}} node" do

View file

@ -0,0 +1,39 @@
require "../../spec_helper"
module Ameba::AST
struct Test
include Util
end
subject = Test.new
describe Util do
describe "#literal?" do
[
Crystal::ArrayLiteral.new,
Crystal::BoolLiteral.new(false),
Crystal::CharLiteral.new('a'),
Crystal::HashLiteral.new,
Crystal::NamedTupleLiteral.new,
Crystal::NilLiteral.new,
Crystal::NumberLiteral.new(42),
Crystal::RegexLiteral.new(Crystal::NilLiteral.new),
Crystal::StringLiteral.new(""),
Crystal::SymbolLiteral.new(""),
Crystal::TupleLiteral.new([] of Crystal::ASTNode),
Crystal::RangeLiteral.new(
Crystal::NilLiteral.new,
Crystal::NilLiteral.new,
true),
].each do |literal|
it "returns true if node is #{literal}" do
subject.literal?(literal).should be_true
end
end
it "returns false if node is not a literal" do
subject.literal?(Crystal::Nop).should be_false
end
end
end
end