Skip to content

Conversation

eileencodes
Copy link
Member

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 eileencodes force-pushed the add-more-cvar-tests branch from 6840782 to 5680bbc Compare March 10, 2021 13:04
@eileencodes
Copy link
Member 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 eileencodes force-pushed the add-more-cvar-tests branch from 5680bbc to 512f57f Compare March 10, 2021 13:18
@eileencodes
Copy link
Member 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants