Skip to content

JRuby 9.4 appears to re-order array parallel assigns #7988

@luke-hill

Description

@luke-hill

Environment Information

Provide at least:

Actual Behavior

  • When running tests on ruby 2.5+ there is a scenario performing a long test. Said scenario will then do a parallel assign of iVars on initialize.

For ruby 2.5+ the following is observed

0> event
=> #<Cucumber::Core::Events::TestStepFinished:0x000055602c739358 @test_step=#<Cucumber::Core::Test::Step: features/test.feature:4>, @result=#<Cucumber::Core::Test::Result::Passed:0x000055602c739510 @duration=#<Cucumber::Core::Test::Result::Duration:0x000055602c739538 @nanoseconds=1016>>>

0> event.attributes
=> [#<Cucumber::Core::Test::Step: features/test.feature:4>, #<Cucumber::Core::Test::Result::Passed:0x000055602c739510 @duration=#<Cucumber::Core::Test::Result::Duration:0x000055602c739538 @nanoseconds=1016>>]

However these 2 values in the array are reversed in JRuby 9.4.4

0> event
=> #<Cucumber::Core::Events::TestStepFinished:0x7f426ddd @result=#<Cucumber::Core::Test::Result::Passed:0x3a209918 @duration=#<Cucumber::Core::Test::Result::Duration:0x2cae5fa7 @nanoseconds=45101>>, @test_step=#<Cucumber::Core::Test::Step: features/test.feature:4>>

0> event.attributes
=> [#<Cucumber::Core::Test::Result::Passed:0x3a209918 @duration=#<Cucumber::Core::Test::Result::Duration:0x2cae5fa7 @nanoseconds=45101>>, #<Cucumber::Core::Test::Step: features/test.feature:4>]
  • Provide an executable Ruby script or a link to an example repository.

Expected Behavior

Should be identical

NB: The portion of the code that generates these is quite metaprogram heavy

Class.new(Event) do
          attr_reader(*events)

          define_method(:initialize) do |*attributes|
            events.zip(attributes) do |name, value|
              instance_variable_set("@#{name}".to_sym, value)
            end
          end

          def attributes
            instance_variables.map { |var| instance_variable_get(var) }
          end

.... # more stuff

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions