summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2022-12-01 17:26:45 +0900
committerNobuyoshi Nakada <[email protected]>2022-12-02 00:56:52 +0900
commita14a1a5626a4d8e661a3e606f8f92b8c455b9a04 ()
treeddef361869df97d4c71e0a6540fe471af2aaa306
parent06a0c580161db7084e8276fcd9fbb5d25bde4a03 (diff)
[Feature #19163] Data object should be frozen
Notes: Merged: https://.com/ruby/ruby/pull/6843
-rw-r--r--struct.c12
-rw-r--r--test/ruby/test_data.rb8
2 files changed, 19 insertions, 1 deletions
@@ -1818,9 +1818,19 @@ rb_data_initialize_m(int argc, const VALUE *argv, VALUE self)
if (arg.unknown_keywords != Qnil) {
rb_exc_raise(rb_keyword_error_new("unknown", arg.unknown_keywords));
}
return Qnil;
}
/*
* call-seq:
* inspect -> string
@@ -2180,7 +2190,7 @@ InitVM_Struct(void)
#endif
rb_define_method(rb_cData, "initialize", rb_data_initialize_m, -1);
- rb_define_method(rb_cData, "initialize_copy", rb_struct_init_copy, 1);
rb_define_method(rb_cData, "==", rb_data_equal, 1);
rb_define_method(rb_cData, "eql?", rb_data_eql, 1);
@@ -62,6 +62,7 @@ class TestData < Test::Unit::TestCase
assert_equal(1, test.foo)
assert_equal(2, test.bar)
assert_equal(test, klass.new(1, 2))
# Keywords
test_kw = klass.new(foo: 1, bar: 2)
@@ -169,4 +170,11 @@ class TestData < Test::Unit::TestCase
assert_equal([], test.members)
assert_equal({}, test.to_h)
end
end