Test coverage increases
parent
99c25a8bcd
commit
68b7e511eb
|
@ -39,6 +39,16 @@ module CeleryScript
|
|||
e
|
||||
end
|
||||
|
||||
def check_leaf(node)
|
||||
allowed = corpus.values(node)
|
||||
actual = node.value.class
|
||||
ok_leaf = allowed.include?(actual)
|
||||
raise TypeCheckError, (BAD_LEAF % [ node.kind,
|
||||
node.parent.kind,
|
||||
allowed.inspect,
|
||||
actual.inspect]) unless ok_leaf
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def validate(node)
|
||||
|
@ -134,17 +144,6 @@ module CeleryScript
|
|||
raise TypeCheckError, (BAD_BODY % [prnt.kind, child.kind, ok.inspect])
|
||||
end
|
||||
|
||||
def check_leaf(node)
|
||||
allowed = corpus.values(node)
|
||||
actual = node.value.class
|
||||
unless allowed.include?(actual)
|
||||
raise TypeCheckError, (BAD_LEAF % [ node.kind,
|
||||
node.parent.kind,
|
||||
allowed.inspect,
|
||||
actual.inspect])
|
||||
end
|
||||
end
|
||||
|
||||
def malformed_node!(expectation)
|
||||
raise TypeCheckError, (MALFORMED % expectation)
|
||||
end
|
||||
|
|
|
@ -61,6 +61,14 @@ describe CeleryScript::Checker do
|
|||
hash[:body][0][:args][:location][:args][:x] = "supposed to be an Integer"
|
||||
result = checker.run
|
||||
expect(result.message).to eq("Expected leaf 'x' within 'coordinate' to"\
|
||||
" be one of: [Integer] but got String")
|
||||
" be one of: [Integer] but got String")
|
||||
end
|
||||
|
||||
it "finds a bad leaf" do
|
||||
parent = CeleryScript::AstNode.new(parent = nil, args: {}, kind: "nothing")
|
||||
expect {
|
||||
checker.check_leaf CeleryScript::AstLeaf.new(parent, 6, :location)
|
||||
}.to raise_error(CeleryScript::TypeCheckError)
|
||||
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue