mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Address feedback, add tests
This commit is contained in:
parent
14a9ec3a75
commit
6b2ddcb1d9
3 changed files with 35 additions and 11 deletions
30
spec/ameba/ast/variabling/type_def_variable_spec.cr
Normal file
30
spec/ameba/ast/variabling/type_def_variable_spec.cr
Normal file
|
@ -0,0 +1,30 @@
|
|||
require "../../../spec_helper"
|
||||
|
||||
module Ameba::AST
|
||||
describe TypeDecVariable do
|
||||
var = Crystal::Var.new("foo")
|
||||
declared_type = Crystal::Path.new("String")
|
||||
type_dec = Crystal::TypeDeclaration.new(var, declared_type)
|
||||
|
||||
describe "#initialize" do
|
||||
it "creates a new type dec variable" do
|
||||
variable = TypeDecVariable.new(type_dec)
|
||||
variable.node.should_not be_nil
|
||||
end
|
||||
end
|
||||
|
||||
describe "#name" do
|
||||
it "returns var name" do
|
||||
variable = TypeDecVariable.new(type_dec)
|
||||
variable.name.should eq var.name
|
||||
end
|
||||
|
||||
it "raises if type declaration is incorrect" do
|
||||
type_dec = Crystal::TypeDeclaration.new(declared_type, declared_type)
|
||||
expect_raises(Exception, "unsupported var node type: Crystal::Path") do
|
||||
TypeDecVariable.new(type_dec).name
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue