Skip to content
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

Clarify tests about parsing aliases #568

Merged
merged 3 commits into from
Aug 8, 2022
Merged

Clarify tests about parsing aliases #568

merged 3 commits into from
Aug 8, 2022

Conversation

amomchilov
Copy link
Contributor

Split from #567.

These tests don't really have actually anything special to do with recursion. The behaviour being asserted is about how any kind of alias works.

@tenderlove
Copy link
Member

These tests don't really have actually anything special to do with recursion.

This isn't 100% true. The test implicitly asserted that Psych.dump([].tap { |x| x << x }) would emit an alias. We know that an alias was emitted because we explicitly did not allow loading aliases and an exception was raised.

Can you make sure that we assert that Psych.dump([].tap { |x| x << x }) will use aliases?

@amomchilov
Copy link
Contributor Author

Can you make sure that we assert that Psych.dump([].tap { |x| x << x }) will use aliases?

Good point. I added tests that ensures this, explicitly, not just for arrays, but also for hashes and object.

--- &1
- :a: b
- foo
- *1
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should hard-code the expected YAML. We may want to change the emitted aliases in the future, and now this test couples the implementation with the exact alias name. IOW I want to test that aliases were used, but I don't care what the aliases were.

Not to mention, we may change indentation in the future etc, so I don't want the test to be coupled to the formatting either.

Copy link
Contributor Author

@amomchilov amomchilov Jul 27, 2022

Choose a reason for hiding this comment

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

Done, what do you think? b9ab190

@amomchilov amomchilov requested a review from tenderlove July 27, 2022 19:25
@tenderlove tenderlove merged commit c12823a into ruby:master Aug 8, 2022
@amomchilov amomchilov deleted the clarify-tests-about-alias-parsing branch September 2, 2024 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants