turboladen/tailor

Tests fail under Ruby 2.0.0-p0 but bin/tailor works OK

Closed this issue · 5 comments

Not sure why this is yet, but I'm getting these two failures when rake spec under 2.0.0-p0:

expected #<Fixnum:5> => 2
     got #<Fixnum:3> => 1

Compared using equal?, which compares object identity,
but expected and actual are not the same object. Use
`expect(actual).to eq(expected)` if you don't care about
object identity in this example.


./spec/functional/horizontal_spacing/braces_spec.rb:228:in `block (4 levels) in <top (required)>'


expected #<Fixnum:145> => 72
     got #<Fixnum:147> => 73

Compared using equal?, which compares object identity,
but expected and actual are not the same object. Use
`expect(actual).to eq(expected)` if you don't care about
object identity in this example.


./spec/functional/horizontal_spacing/braces_spec.rb:231:in `block (4 levels) in <top (required)>'

If I run bin/tailor against a file with the same content that those tests run against, it reports the errors properly.

Looks like the fix for https://bugs.ruby-lang.org/issues/6211 finally got merged into a distro with 2.0.0-p0. Tailor should now use embexpr_end.

In my mind the method 'rbrace_update' does not need to keep track embedded expressions, ok?

Something like this -> https://github.com/leandronsp/tailor/commit/654d58d535cc97d9db5dd92b41d6f349766b2e25

Yeah, for Ruby 2.0.0, you're right on @leandronsp--thanks; I'm working on this now.

For 1.9.3 though, when tailor encounters what should be lexed (from Ripper) as an embexpr_end, it actually gets lexed as a rbrace, which tailor interprets as the matching/closing brace for the previous lbrace. If, however, there was no previous lbrace (i.e. in the case a embexpr_beg was encountered), due to how tailor tracks problems internally, it would remove whatever the last problem was from its list of problems. Thus, tailor unfortunately needs to be able to work around the bug in Ripper to be able to distinguish between rbrace and embexpr_end, and in order to do so, it must track what the initiating open brace type was. ... unless you have a better idea--I'm open to suggestions!

It'd be nice to be able to drop support for 1.9.3 due to this Ripper bug, but I'm guessing that that's what most are using right now.

Sure, tailor needs to keep working on 1.9.3.
Maybe the ruby core team would fix the Ripper for 1.9.x?

@leandronsp that was my hope when I logged the issue 11 months ago. :-/ I'd love to see that happen; I don't know why it wasn't put into 1.9.3 last year.