diff options
Diffstat (limited to 'spec/ruby/language')
-rw-r--r-- | spec/ruby/language/constants_spec.rb | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/spec/ruby/language/constants_spec.rb b/spec/ruby/language/constants_spec.rb index bc76c60d20..8586e46158 100644 --- a/spec/ruby/language/constants_spec.rb +++ b/spec/ruby/language/constants_spec.rb @@ -135,18 +135,34 @@ describe "Literal (A::X) constant resolution" do ConstantSpecs::ClassB::CS_CONST109.should == :const109_2 end - it "evaluates the right hand side before evaluating a constant path" do - mod = Module.new + ruby_version_is "3.2" do + it "evaluates left-to-right" do + mod = Module.new - mod.module_eval <<-EOC - ConstantSpecsRHS::B = begin - module ConstantSpecsRHS; end + mod.module_eval <<-EOC + order = [] + ConstantSpecsRHS = Module.new + (order << :lhs; ConstantSpecsRHS)::B = (order << :rhs) + EOC - "hello" - end - EOC + mod::ConstantSpecsRHS::B.should == [:lhs, :rhs] + end + end + + ruby_version_is ""..."3.2" do + it "evaluates the right hand side before evaluating a constant path" do + mod = Module.new - mod::ConstantSpecsRHS::B.should == 'hello' + mod.module_eval <<-EOC + ConstantSpecsRHS::B = begin + module ConstantSpecsRHS; end + + "hello" + end + EOC + + mod::ConstantSpecsRHS::B.should == 'hello' + end end end |