Skip to content

Support required arguments with default values [fixes #2356] #2416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 8, 2019
Merged

Support required arguments with default values [fixes #2356] #2416

merged 2 commits into from
Aug 8, 2019

Conversation

modosc
Copy link
Contributor

@modosc modosc commented Aug 6, 2019

No description provided.

@modosc
Copy link
Contributor Author

modosc commented Aug 6, 2019

it looks like the failing specs are just order changes in the serialized hash:

-"{:required_with_default_arg=>1, :renamed=>\"x\"}"
+"{:renamed=>\"x\", :required_with_default_arg=>1}"

and they only happen on one version of ruby (although maybe they happen in others, given enough test runs). should i change those specs to deserialize so i can compare hash to hash or just not worry about it?

Copy link
Owner

@rmosolgo rmosolgo left a comment

Choose a reason for hiding this comment

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

Thanks for taking this on! Now that I see how this plays out in the tests, I think we'll benefit from this in GitHub too.

Regarding the failing test, I think it's because that run is with TESTING_INTERPRETER=1. With that env var, it uses the new interpreter runtime, which probably builds argument hashes in a different order.

I don't think the difference in behavior is significant. But to make the tests pass, how about ordering the keys in the hash before serializing it, for example:

sorted_keys = args.keys.sort 
sorted_args = {} 
sorted_keys.each  {|k| sorted_args[k] = args[k] }
sorted_args.inspect 

(Maybe there's a better way to sort the Hash -- but ya get the gist.)

What do you think of that?

assert_equal '{:required_with_default_arg=>2}', res["data"]["field"]
end

it 'respects non-null type' do
Copy link
Owner

Choose a reason for hiding this comment

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

Ok, I think I finally get why this is good!

@rmosolgo rmosolgo added this to the 1.9.10 milestone Aug 8, 2019
@modosc
Copy link
Contributor Author

modosc commented Aug 8, 2019

Regarding the failing test, I think it's because that run is with TESTING_INTERPRETER=1. With that env var, it uses the new interpreter runtime, which probably builds argument hashes in a different order.

ok, specs fixed and passing

@rmosolgo
Copy link
Owner

rmosolgo commented Aug 8, 2019

🤘

@rmosolgo rmosolgo merged commit 982a750 into rmosolgo:master Aug 8, 2019
@modosc modosc deleted the 2356-required-default-values branch August 11, 2019 22:03
@modosc
Copy link
Contributor Author

modosc commented Aug 12, 2019

thanks @rmosolgo , any idea when 1.9.10 will land?

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