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

Add cvar overtaken tests #4251

Merged
merged 1 commit into from
Mar 10, 2021
Merged

Conversation

eileencodes
Copy link
Contributor

While working on another project we noticed that there were no tests for
the cvar overtaken exception when using classes. This change adds a test
for cvar overtaken with classes and moves the cvar overtaken test for
modules into the new file.

Co-authored-by: Aaron Patterson tenderlove@ruby-lang.org

cc/ @tenderlove

@jeremyevans
Copy link
Contributor

I think the new tests look good. However, I think this should go in test/ruby/test_variable.rb, as that is where the other class variable tests are. I think another reasonable alternative would be to split test/ruby/test_variable.rb into separate files per variable type, but that's significantly more work. I don't think we should add a new file named test/ruby/test_cvar.rb that only tests the overtaken behavior.

@simi
Copy link
Contributor

simi commented Mar 9, 2021

🤔 https://github.com/ruby/spec/blob/master/language/class_variable_spec.rb could be also interesting point to add this kind of test.

@eileencodes
Copy link
Contributor Author

eileencodes commented Mar 10, 2021

I moved the new tests into test_variable.rb @jeremyevans 👍🏻

Edit: Actually they aren't passing in this file. Looking now.

While working on another project we noticed that there were no tests for
the cvar overtaken exception when using classes. This change adds a test
for cvar overtaken with classes and moves the cvar overtaken test for
modules into the new file.

Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
@eileencodes
Copy link
Contributor Author

Ok got the test fixed. Failing test is unrelated.

Failure: test_use_gemdeps(GemSingletonTest):
  Call trace does not match with given method type: #<struct RBS::Test::CallTrace method_name=:use_gemdeps, method_call=#<RBS::Test::ArgumentsReturn:0x00007f7b2bf30220 @arguments=["-"], @exit_value=nil, @exit_type=:return>, block_calls=[], block_given=false>.
  <["[Moduleuse_gemdeps] ReturnTypeError: expected `Array[Gem::Specification]` but returns `nil`"]> was expected to be empty.
/home/runner/work/ruby/ruby/src/gems/src/rbs/test/stdlib/test_helper.rb:263:in `assert_send_type'
test/stdlib/rubygems/Gem_test.rb:566:in `test_use_gemdeps'
     563:   def test_use_gemdeps
     564:     assert_send_type  "() -> nil",
     565:                       Gem, :use_gemdeps
  => 566:     assert_send_type  "(String) -> Array[Gem::Specification]",
     567:                       Gem, :use_gemdeps, "-"
     568:   end
     569: 

@tenderlove tenderlove merged commit cbc7c1c into ruby:master Mar 10, 2021
@eileencodes eileencodes deleted the add-more-cvar-tests branch March 10, 2021 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants