From 3d4456ac67a3bf42a37c4a89fdda13effd8d2b12 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 14 Oct 2024 09:34:36 -0400 Subject: [PATCH] Add tests, including issue failing on main branch --- spec/type_checker/levels/strict_spec.rb | 47 +++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/spec/type_checker/levels/strict_spec.rb b/spec/type_checker/levels/strict_spec.rb index 22bbd3631..c3ef2301f 100644 --- a/spec/type_checker/levels/strict_spec.rb +++ b/spec/type_checker/levels/strict_spec.rb @@ -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