diff options
author | Benoit Daloze <eregontp@gmail.com> | 2019-05-28 22:41:48 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2019-05-28 22:41:48 +0200 |
commit | a66bc2c01194a9c017c874a30db5b3b6bd95e966 (patch) | |
tree | 598d6375b44fd86f90c3477c73086f6fcf08d76c /spec/ruby/optional/capi/kernel_spec.rb | |
parent | d070523e7be4b95914adeef9a10401fba7718c5a (diff) | |
download | ruby-a66bc2c01194a9c017c874a30db5b3b6bd95e966.tar.gz |
Update to ruby/spec@9a501a8
Diffstat (limited to 'spec/ruby/optional/capi/kernel_spec.rb')
-rw-r--r-- | spec/ruby/optional/capi/kernel_spec.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/ruby/optional/capi/kernel_spec.rb b/spec/ruby/optional/capi/kernel_spec.rb index ab6c2bceef..3fb2c8ed2d 100644 --- a/spec/ruby/optional/capi/kernel_spec.rb +++ b/spec/ruby/optional/capi/kernel_spec.rb @@ -292,6 +292,22 @@ describe "C-API Kernel function" do end end + describe "rb_eval_string_protect" do + it "will evaluate the given string" do + proof = [] + res = @s.rb_eval_string_protect('1 + 7', proof) + proof.should == [23, 8] + end + + it "will allow cleanup code to be run when an exception is raised" do + proof = [] + lambda do + @s.rb_eval_string_protect('raise RuntimeError', proof) + end.should raise_error(RuntimeError) + proof.should == [23, nil] + end + end + describe "rb_rescue" do before :each do @proc = lambda { |x| x } |