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

CI is failing in ruby-head 3.4.0dev(76e0ea28ea) with the Range#step changes #590

Closed
kachick opened this issue Aug 26, 2024 · 0 comments · Fixed by #591
Closed

CI is failing in ruby-head 3.4.0dev(76e0ea28ea) with the Range#step changes #590

kachick opened this issue Aug 26, 2024 · 0 comments · Fixed by #591
Labels
enhancement New feature or request

Comments

@kachick
Copy link
Owner

kachick commented Aug 26, 2024

Description

Extracted from #587 (comment)

https://github.com/ruby/ruby/blame/2e07c13049a887c22849e77648838f040b0759b0/NEWS.md#L46
ruby/ruby#7444
https://bugs.ruby-lang.org/issues/18368
ruby/ruby@d450f9d

===============================================================================
Error: test_range_elements(TestULIDUseCase): NoMethodError: undefined method '+' for an instance of ULID
/home/runner/work/ruby-ulid/ruby-ulid/test/core/test_ulid_usecase.rb:21:in 'Range#step'
/home/runner/work/ruby-ulid/ruby-ulid/test/core/test_ulid_usecase.rb:21:in 'Enumerator#each'
/home/runner/work/ruby-ulid/ruby-ulid/test/core/test_ulid_usecase.rb:21:in 'Enumerable#to_a'
/home/runner/work/ruby-ulid/ruby-ulid/test/core/test_ulid_usecase.rb:21:in 'TestULIDUseCase#test_range_elements'
===============================================================================
Finished in 0.31[9](https://github.com/kachick/ruby-ulid/actions/runs/10551862741/job/29229876886?pr=587#step:5:10)641326 seconds.
122 tests, 7764 assertions, 0 failures, 1 errors, 0 pendings, 0 omissions, 0 notifications
rake aborted!
Command failed with status (1)
<internal:array>:53:in 'Array#each'
<internal:array>:53:in 'Array#each'
<internal:array>:53:in 'Array#each'
Tasks: TOP => test_all => test_core

assert_equal([begin_ulid, ulid3, ulid5], include_end.step(2).to_a)

ruby-ulid/README.md

Lines 283 to 288 in 49d6be0

#### As element in Enumerable
`ULID#next` and `ULID#succ` returns next(successor) ULID.\
Especially `ULID#succ` makes it possible `Range[ULID]#each`.
NOTE: However basically `Range[ULID]#each` should not be used. Incrementing 128 bits IDs are not reasonable operation in most cases.

assert_equal([begin_ulid, ulid3, ulid5], include_end.step(2).to_a)
assert_equal([begin_ulid, ulid4], include_end.step(3).to_a)
assert_equal([begin_ulid, end_ulid], include_end.step(5).to_a)
assert_equal([begin_ulid, ulid3, ulid5], exclude_end.step(2).to_a)
assert_equal([begin_ulid, ulid4], exclude_end.step(3).to_a)
assert_equal([begin_ulid], exclude_end.step(5).to_a)

How

  • Drop supporting Range
  • Implement ULID#+
    • Then also need ULID#-?
    • It should ignore Time insntance. Because duration is only defined in rails(ActiveSupport::Duration)
    • Even if I define +, Last test case may raise error for boundary ULID? => Then need similar and more handlings as

      ruby-ulid/lib/ulid.rb

      Lines 452 to 465 in 49d6be0

      # @return [ULID, nil] when called on ULID as `7ZZZZZZZZZZZZZZZZZZZZZZZZZ`, returns `nil` instead of ULID
      def succ
      succ_int = @integer.succ
      if succ_int >= MAX_INTEGER
      if succ_int == MAX_INTEGER
      MAX
      else
      nil
      end
      else
      ULID.from_integer(succ_int)
      end
      end
      alias_method(:next, :succ)
@kachick kachick added the enhancement New feature or request label Aug 26, 2024
@kachick kachick added this to 🛸 Aug 26, 2024
@github-project-automation github-project-automation bot moved this to 🙋‍♂ in 🛸 Aug 26, 2024
@kachick kachick changed the title CI is failing in ruby-head 3.4.0-dev with the Range#step changes CI is failing in ruby-head 3.4.0dev(76e0ea28ea) with the Range#step changes Aug 26, 2024
@github-project-automation github-project-automation bot moved this from 🙋‍♂ to 🎉 in 🛸 Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants
@kachick and others