diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-10-09 23:06:13 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-12-14 19:19:16 +0900 |
commit | f43c71abe07b4b2b0f8f9a69c567fcd0f38faef6 (patch) | |
tree | 5174f18c9bd83ed60537a44c455a1b3369f49c88 /test/ruby | |
parent | b1bd223085d7b97d8de8679894a81b7993c26b28 (diff) |
Implemented shareable_constant_value
It does shallow freeze only for now.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3681
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_parse.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index 1ed92d59a4..f12b61019b 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -1178,6 +1178,23 @@ x = __ENCODING__ assert_warning(/invalid value/) do assert_valid_syntax("# shareable_constant_value: invalid-option", verbose: true) end + a = Class.new.class_eval("#{<<~"begin;"}\n#{<<~'end;'}") + begin; + # shareable_constant_value: true + A = [] + end; + assert_predicate(a, :frozen?) + a, b = Class.new.class_eval("#{<<~"begin;"}\n#{<<~'end;'}") + begin; + # shareable_constant_value: false + class X # shareable_constant_value: true + A = [] + end + B = [] + [X::A, B] + end; + assert_predicate(a, :frozen?) + assert_not_predicate(b, :frozen?) end =begin |