Skip to content

Literal::TypeError tweaks and fix for type check in Enum#345

Open
stevegeek wants to merge 4 commits into
mainfrom
type_error_tweaks
Open

Literal::TypeError tweaks and fix for type check in Enum#345
stevegeek wants to merge 4 commits into
mainfrom
type_error_tweaks

Conversation

@stevegeek

Copy link
Copy Markdown
Collaborator

TypeError#deconstruct_keys prob should return all keys when passed nil like Hash say

It is probably not useful to implicitly convert Context to hash so can remove extra to_hash alias (unless we think we might need it)

Enum __after_defined__ still using old TypeError class method so update it to use Literal.check

@stevegeek stevegeek requested a review from joeldrapper December 5, 2025 00:08
Comment thread test/type_error.test.rb
Comment on lines +32 to +34
test "can be pattern matched" do
Age.new(17)
rescue Literal::TypeError => error

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another way you could do this is

error = assert_raises(Literal::TypeError) do
  Age.new(17)
end

And then you can continue to make assertions about the error variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants