Class: Mumukit::Inspection::Expectation::V0
Constant Summary
collapse
- INSPECTIONS =
%w(HasBinding HasTypeDeclaration HasTypeSignature HasVariable HasArity HasDirectRecursion
HasComposition HasComprehension HasForeach HasIf HasGuards HasConditional HasLambda HasRepeat HasWhile
HasUsage)
Instance Attribute Summary
#binding, #inspection
Instance Method Summary
collapse
#check!, guess_type, #initialize, parse, #to_h, #translate
Instance Method Details
#as_v2 ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/mumukit/inspection/expectation.rb', line 50
def as_v2
if has? 'Binding' then as_v2_declare ''
elsif has? 'TypeDeclaration' then as_v2_declare 'TypeAlias'
elsif has? 'TypeSignature' then as_v2_declare 'TypeSignature'
elsif has? 'Variable' then as_v2_declare 'Variable'
elsif has? 'Arity' then as_v2_declare "ComputationWithArity#{inspection.target.value}"
elsif has? 'DirectRecursion' then as_v2_declare "Recursively"
elsif has? 'Usage'
V2.new binding, new_inspection('Uses', Mumukit::Inspection::Target.named(inspection.target.value))
else as_v2_use
end
end
|
#as_v2_declare(simple_type) ⇒ Object
71
72
73
|
# File 'lib/mumukit/inspection/expectation.rb', line 71
def as_v2_declare(simple_type)
V2.new '*', new_inspection("Declares#{simple_type}", Mumukit::Inspection::Target.named(binding))
end
|
#as_v2_use ⇒ Object
67
68
69
|
# File 'lib/mumukit/inspection/expectation.rb', line 67
def as_v2_use
V2.new binding, new_inspection(inspection.type.gsub('Has', 'Uses'), nil)
end
|
#binding? ⇒ Boolean
42
43
44
|
# File 'lib/mumukit/inspection/expectation.rb', line 42
def binding?
binding.present?
end
|
#has?(simple_type) ⇒ Boolean
63
64
65
|
# File 'lib/mumukit/inspection/expectation.rb', line 63
def has?(simple_type)
inspection.type == "Has#{simple_type}"
end
|
#inspection? ⇒ Boolean
46
47
48
|
# File 'lib/mumukit/inspection/expectation.rb', line 46
def inspection?
inspection.present? && INSPECTIONS.include?(inspection.type)
end
|
#new_inspection(type, target) ⇒ Object
75
76
77
|
# File 'lib/mumukit/inspection/expectation.rb', line 75
def new_inspection(type, target)
Mumukit::Inspection.new(type, target, inspection.negated?)
end
|