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, #translate!, valid?
Instance Method Details
#as_v2 ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/mulang/expectation/standard.rb', line 57
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
74
75
76
|
# File 'lib/mulang/expectation/standard.rb', line 74
def as_v2_use
Mulang::Expectation::V2.new binding, new_inspection(inspection.type.gsub(/^Has/, 'Uses'), nil)
end
|
#binding? ⇒ Boolean
49
50
51
|
# File 'lib/mulang/expectation/standard.rb', line 49
def binding?
binding.present?
end
|
#has?(simple_type) ⇒ Boolean
70
71
72
|
# File 'lib/mulang/expectation/standard.rb', line 70
def has?(simple_type)
inspection.type == "Has#{simple_type}"
end
|
#inspection? ⇒ Boolean
53
54
55
|
# File 'lib/mulang/expectation/standard.rb', line 53
def inspection?
inspection.present? && INSPECTIONS.include?(inspection.type)
end
|
#new_inspection(type, target) ⇒ Object
82
83
84
|
# File 'lib/mulang/expectation/standard.rb', line 82
def new_inspection(type, target)
Mulang::Inspection.new(type, target, negated: inspection.negated?)
end
|