parent
bd22bb259c
commit
d4c720a91b
Notes:
git
2023-08-24 03:19:56 +00:00
Merged-By: ioquatix <samuel@codeotaku.com>
8
cont.c
8
cont.c
@ -2118,7 +2118,7 @@ rb_fiber_storage_get(VALUE self)
|
|||||||
static int
|
static int
|
||||||
fiber_storage_validate_each(VALUE key, VALUE value, VALUE _argument)
|
fiber_storage_validate_each(VALUE key, VALUE value, VALUE _argument)
|
||||||
{
|
{
|
||||||
rb_check_id(&key);
|
Check_Type(key, T_SYMBOL);
|
||||||
|
|
||||||
return ST_CONTINUE;
|
return ST_CONTINUE;
|
||||||
}
|
}
|
||||||
@ -2190,8 +2190,7 @@ rb_fiber_storage_set(VALUE self, VALUE value)
|
|||||||
static VALUE
|
static VALUE
|
||||||
rb_fiber_storage_aref(VALUE class, VALUE key)
|
rb_fiber_storage_aref(VALUE class, VALUE key)
|
||||||
{
|
{
|
||||||
ID id = rb_check_id(&key);
|
Check_Type(key, T_SYMBOL);
|
||||||
if (!id) return Qnil;
|
|
||||||
|
|
||||||
VALUE storage = fiber_storage_get(fiber_current(), FALSE);
|
VALUE storage = fiber_storage_get(fiber_current(), FALSE);
|
||||||
if (storage == Qnil) return Qnil;
|
if (storage == Qnil) return Qnil;
|
||||||
@ -2212,8 +2211,7 @@ rb_fiber_storage_aref(VALUE class, VALUE key)
|
|||||||
static VALUE
|
static VALUE
|
||||||
rb_fiber_storage_aset(VALUE class, VALUE key, VALUE value)
|
rb_fiber_storage_aset(VALUE class, VALUE key, VALUE value)
|
||||||
{
|
{
|
||||||
ID id = rb_check_id(&key);
|
Check_Type(key, T_SYMBOL);
|
||||||
if (!id) return Qnil;
|
|
||||||
|
|
||||||
VALUE storage = fiber_storage_get(fiber_current(), value != Qnil);
|
VALUE storage = fiber_storage_get(fiber_current(), value != Qnil);
|
||||||
if (storage == Qnil) return Qnil;
|
if (storage == Qnil) return Qnil;
|
||||||
|
@ -74,6 +74,20 @@ describe "Fiber.[]" do
|
|||||||
Fiber.new { Fiber[:life] }.resume.should be_nil
|
Fiber.new { Fiber[:life] }.resume.should be_nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
ruby_version_is "3.2.3" do
|
||||||
|
it "can use dynamically defined keys" do
|
||||||
|
key = :"#{self.class.name}#.#{self.object_id}"
|
||||||
|
Fiber.new { Fiber[key] = 42; Fiber[key] }.resume.should == 42
|
||||||
|
end
|
||||||
|
|
||||||
|
it "can't use invalid keys" do
|
||||||
|
invalid_keys = [Object.new, "Foo", 12]
|
||||||
|
invalid_keys.each do |key|
|
||||||
|
-> { Fiber[key] }.should raise_error(TypeError)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "Fiber.[]=" do
|
describe "Fiber.[]=" do
|
||||||
|
@ -25,6 +25,8 @@ test_subtract(RBS::CliTest) running tests without Bundler
|
|||||||
test_subtract_several_subtrahends(RBS::CliTest) running tests without Bundler
|
test_subtract_several_subtrahends(RBS::CliTest) running tests without Bundler
|
||||||
test_subtract_write(RBS::CliTest) running tests without Bundler
|
test_subtract_write(RBS::CliTest) running tests without Bundler
|
||||||
|
|
||||||
|
test_aref(FiberSingletonTest) the method should not accept String keys
|
||||||
|
|
||||||
NetSingletonTest depending on external resources
|
NetSingletonTest depending on external resources
|
||||||
NetInstanceTest depending on external resources
|
NetInstanceTest depending on external resources
|
||||||
TestHTTPRequest depending on external resources
|
TestHTTPRequest depending on external resources
|
||||||
|
Loading…
x
Reference in New Issue
Block a user