Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
with
28 additions
and
0 deletions.
-
+6
−0
lib/simple_types.rb
-
+22
−0
spec/simple_types_spec.rb
|
@@ -9,6 +9,12 @@ def subtype_of?(subtype, supertype) |
|
|
subtype.members.key?(field) && subtype_of?(subtype.members[field], type) |
|
|
end |
|
|
end |
|
|
if subtype.is_a?(Type::Function) && supertype.is_a?(Type::Function) |
|
|
return ( |
|
|
subtype_of?(supertype.from, subtype.from) && |
|
|
subtype_of?(subtype.to, supertype.to) |
|
|
) |
|
|
end |
|
|
false |
|
|
end |
|
|
|
|
|
|
@@ -51,6 +51,28 @@ |
|
|
end |
|
|
end |
|
|
|
|
|
describe 'SA-ARROW' do |
|
|
specify do |
|
|
expect('Bool -> Bool').to be_subtype_of('Bool -> Bool') |
|
|
end |
|
|
|
|
|
specify do |
|
|
expect('Bool -> Bool').to be_subtype_of('Bool -> Top') |
|
|
end |
|
|
|
|
|
specify do |
|
|
expect('Top -> Bool').to be_subtype_of('Bool -> Bool') |
|
|
end |
|
|
|
|
|
specify do |
|
|
expect('Bool -> Top').not_to be_subtype_of('Bool -> Bool') |
|
|
end |
|
|
|
|
|
specify do |
|
|
expect('Bool -> Bool').not_to be_subtype_of('Top -> Bool') |
|
|
end |
|
|
end |
|
|
|
|
|
def expr(text) |
|
|
Parser.parse(text) |
|
|
end |
|
|
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.