-
Notifications
You must be signed in to change notification settings - Fork 23
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
Doesn't highlight error for missing constant when const_missing is redefined for class #34
Comments
Can you please write down the executable code and exactly what you expect? class Foo
$orig = self.method(:const_missing)
def self.const_missing(name)
$orig.call(name)
end
end
Foo::Bar Current:
Maybe what you expect:
or
The former can be achieved with error_highlight. But (I was aware of a similar problem, but had not written about it before, so I have created #35.) |
If you go in Ruby repository and at the top of the klass = Test::Unit::TestCase
def klass.const_missing(name)
super
end you will see failing tests. |
Sorry, I don't understand the context at all. Why do you need to run the test of error_highlight along with your hack for test-unit gem? Are you proposing to introduce your hack into the test-unit gem? |
Yeah it's a bit confusing, I'll explain. The changes I'm making are not to the test-unit gem, but to ruby's internal testing framework that is used when running ruby's test-suite ( |
I don't know why you try to change In fact, error_highlight does not work well when On another note, I don't think it's a good idea to define |
I was just messing around with this, and got it working. in return nil unless loc
if NameError === obj
while locs.any? && /in `const_missing'/ =~ loc.to_s
locs.shift
loc = locs.first
end
end Kind of hacky, but gets the job done 😄 As for not changing |
Your patch is what I said as 2-1 in #35. Its problem is that the line number shown by the backtrace and the snippet shown by error_highlight are discrepant. class Foo
def self.const_missing(_)
super
end
Bar
end
Note that there is no |
I'm working on new feature for ruby's test/unit tool and I define
Test::Unit::TestCase.const_missing
. It does some stuff then calls old const_missing like the following (pseudo code):This broke error_highlight tests for missing constant, it wasn't highlighting anymore. I'm not sure if this is fixable or not.
The text was updated successfully, but these errors were encountered: