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

Fix #210 Recreate Ruby's line breaks in Puts #211

Closed
wants to merge 1 commit into from

Conversation

Eneroth3
Copy link

I may have a fix for #210.

Without TestUp puts [1,2,3] outputs as:

1
2
3

Without TestUp it outputs as [1, 2, 3].

This fix restores the default Ruby behavior to puts for Arrays.

Not sure if there are other classes affected, or if there is a more generalized way to swap out to_s on the line line = arg.to_s to make the method always act as native Ruby puts.

I'm also not sure if this proposed fix has other consequences for TestUp and Minitest, or if there is a completely different way to address this architecturally in such way that we don't have to override puts.

Without TestUp `puts [1,2,3]` outputs as:
```
1
2
3
```
Without TestUp it outputs as `[1, 2, 3]`.

This fix restores the default Ruby behavior to puts for Arrays.
@Eneroth3 Eneroth3 force-pushed the bugfix/puts-linebreak branch from 7a49487 to caa3165 Compare August 25, 2023 09:36
write(line)
if line.empty? || !line.end_with?($/)
write($/)
for arg in args # Why not 'args.each do |arg|' ?
Copy link
Author

Choose a reason for hiding this comment

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

Also wondering if there's a reason for using for. each seems more common but I don't think there is any difference other than cosmetic here.

Copy link
Member

Choose a reason for hiding this comment

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

That probably stems back to when for was faster than each.

@thomthom
Copy link
Member

This fix restores the default Ruby behavior to puts for Arrays.

Actually, that's not Ruby's own default. That's SketchUp's version of it. I just checked with irb:

irb(main):002:0> puts [1,2,3]
1
2
3
=> nil

It's been bugging me that SU output data differently from Ruby. Wishing it was more consistent with Ruby. this is probably why TestUp behaves like that. (Stating to remember there might be a reason for this behaviour.)

I've been meaning to propose that we clean up SU's console to act more like Ruby's console output.

@thomthom
Copy link
Member

I'm also not sure if this proposed fix has other consequences for TestUp and Minitest, or if there is a completely different way to address this architecturally in such way that we don't have to override puts.

It could be. I might have corrected the console output via TestUp such that it played better with Minitest and its reporters. (My memory is a little fuzzy. But I think there was some issue I ran into with SU's non-standard formatting.)

@thomthom
Copy link
Member

thomthom commented Jan 9, 2024

We want to make SketchUp's output mirror Ruby's own output. It ensures that using other tools/gems from the Ruby ecosystem prints things equally. Closing this as we want to eventually take the TestUp monkey patching and integrating into SketchUp itself.

@thomthom thomthom closed this Jan 9, 2024
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