diff options
Diffstat (limited to 'spec/ruby/language/constants_spec.rb')
-rw-r--r-- | spec/ruby/language/constants_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/ruby/language/constants_spec.rb b/spec/ruby/language/constants_spec.rb index 5b111f4e81..354cc4b9a3 100644 --- a/spec/ruby/language/constants_spec.rb +++ b/spec/ruby/language/constants_spec.rb @@ -713,3 +713,35 @@ describe "Module#public_constant marked constants" do end end end + +describe 'Allowed characters' do + it 'allows not ASCII characters in the middle of a name' do + mod = Module.new + mod.const_set("BBἍBB", 1) + + eval("mod::BBἍBB").should == 1 + end + + it 'does not allow not ASCII characters that cannot be upcased or lowercased at the beginning' do + -> do + Module.new.const_set("થBB", 1) + end.should raise_error(NameError, /wrong constant name/) + end + + ruby_version_is ""..."2.6" do + it 'does not allow not ASCII upcased characters at the beginning' do + -> do + Module.new.const_set("ἍBB", 1) + end.should raise_error(NameError, /wrong constant name/) + end + end + + ruby_version_is "2.6" do + it 'allows not ASCII upcased characters at the beginning' do + mod = Module.new + mod.const_set("ἍBB", 1) + + eval("mod::ἍBB").should == 1 + end + end +end |