From f937af5745cbc6edead0ad3911bf16e08f66a96f Mon Sep 17 00:00:00 2001 From: Christopher Aue Date: Fri, 28 Jul 2017 22:46:26 +0200 Subject: Extended Module#const_get to support class paths --- test/t/module.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/t/module.rb b/test/t/module.rb index 419b0bfd5..04fa8d102 100644 --- a/test/t/module.rb +++ b/test/t/module.rb @@ -268,6 +268,12 @@ assert('Module#const_get', '15.2.2.4.21') do end assert_equal 42, Test4ConstGet.const_get(:Const4Test4ConstGet) + assert_equal 42, Test4ConstGet.const_get("Const4Test4ConstGet") + assert_equal 42, Object.const_get("Test4ConstGet::Const4Test4ConstGet") + + assert_raise(TypeError){ Test4ConstGet.const_get(123) } + assert_raise(NameError){ Test4ConstGet.const_get(:I_DO_NOT_EXIST) } + assert_raise(NameError){ Test4ConstGet.const_get("I_DO_NOT_EXIST::ME_NEITHER") } end assert('Module#const_missing', '15.2.2.4.22') do @@ -280,7 +286,7 @@ assert('Module#const_missing', '15.2.2.4.22') do assert_equal 42, Test4ConstMissing.const_get(:ConstDoesntExist) end -assert('Module#const_get', '15.2.2.4.23') do +assert('Module#const_set', '15.2.2.4.23') do module Test4ConstSet Const4Test4ConstSet = 42 end -- cgit v1.2.3