Class: Mulang::Expectation::V0
Constant Summary
collapse
- INSPECTIONS =
%w(HasBinding HasTypeDeclaration HasTypeSignature HasVariable HasArity HasDirectRecursion
HasComposition HasComprehension HasForeach HasIf HasGuards HasConditional HasLambda HasRepeat HasWhile
HasUsage HasAnonymousVariable HasNot HasForall HasFindall)
Instance Attribute Summary
Attributes inherited from Standard
#binding, #inspection
Instance Method Summary
collapse
Methods inherited from Standard
#check!, #custom?, #initialize, parse, #standard?, #to_h, #translate, valid?
Instance Method Details
#as_v2 ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/mulang/expectation/standard.rb', line 53
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'
Mulang::Expectation::V2.new binding, new_inspection('Uses', Mulang::Inspection::Target.named(inspection.target.value))
else as_v2_use
end
end
|
#as_v2_declare(simple_type) ⇒ Object
#as_v2_use ⇒ Object
70
71
72
|
# File 'lib/mulang/expectation/standard.rb', line 70
def as_v2_use
Mulang::Expectation::V2.new binding, new_inspection(inspection.type.gsub('Has', 'Uses'), nil)
end
|
#binding? ⇒ Boolean
45
46
47
|
# File 'lib/mulang/expectation/standard.rb', line 45
def binding?
binding.present?
end
|
#has?(simple_type) ⇒ Boolean
66
67
68
|
# File 'lib/mulang/expectation/standard.rb', line 66
def has?(simple_type)
inspection.type == "Has#{simple_type}"
end
|
#inspection? ⇒ Boolean
49
50
51
|
# File 'lib/mulang/expectation/standard.rb', line 49
def inspection?
inspection.present? && INSPECTIONS.include?(inspection.type)
end
|
#new_inspection(type, target) ⇒ Object
78
79
80
|
# File 'lib/mulang/expectation/standard.rb', line 78
def new_inspection(type, target)
Mulang::Inspection.new(type, target, negated: inspection.negated?)
end
|