Skip to content

Commit

Permalink
Add tests, including issue failing on main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
apiology committed Oct 14, 2024
1 parent 5eed247 commit 3d4456a
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions spec/type_checker/levels/strict_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,53 @@ def bar(baz)
expect(checker.problems.first.message).to include('Not enough arguments')
end

it 'reports solo missing kwarg' do
checker = type_checker(%(
class Foo
def bar(baz:)
end
end
Foo.new.bar
))
expect(checker.problems).to be_one
expect(checker.problems.first.message).to include('Missing keyword arguments')
end

it 'reports not enough kwargs' do
checker = type_checker(%(
class Foo
def bar(foo:, baz:)
end
end
Foo.new.bar(foo: 100)
))
expect(checker.problems).to be_one
expect(checker.problems.first.message).to include('Missing keyword argument')
expect(checker.problems.first.message).to include('baz')
end

it 'accepts passed kwargs' do
checker = type_checker(%(
class Foo
def bar(baz:)
end
end
Foo.new.bar(baz: 123)
))
expect(checker.problems).to be_empty
end

it 'accepts multiple passed kwargs' do
checker = type_checker(%(
class Foo
def bar(baz:, bing:)
end
end
Foo.new.bar(baz: 123, bing: 456)
))
expect(checker.problems).to be_empty
end

it 'requires strict return tags' do
checker = type_checker(%(
class Foo
Expand Down

0 comments on commit 3d4456a

Please sign in to comment.