<commit_before>require File.dirname(__FILE__) + '/../spec_helper'
require File.dirname(__FILE__) + '/fixtures/ensure'

describe "An ensure block inside a begin block" do
  it "is executed when an exception is raised in it's correspoding begin block" do
    begin
      executed = []
      
      lambda {
        begin
          executed << :begin
          raise "An exception occured!"
        ensure
          executed << :ensure
        end
      }.should raise_error(RuntimeError)
      
      executed.should eql([:begin, :ensure])
    end
  end

  it "is executed when an exception is raised and rescued in it's correspoding begin block" do
    begin
      executed = []
      
      begin
        executed << :begin
        raise "An exception occured!"
      rescue
        executed << :rescue
      ensure
        executed << :ensure
      end
      
      executed.should eql([:begin, :rescue, :ensure])
    end
  end

  it "is executed even when a symbol is thrown in it's correspoding begin block" do
    begin
      executed = []
      
      catch(:symbol) do
        begin
          executed << :begin
          throw(:symbol)
        rescue
          executed << :rescue
        ensure
          executed << :ensure
        end
      end
      
      executed.should eql([:begin, :ensure])
    end<commit_msg>Typos, grr!<commit_after>require File.dirname(__FILE__) + '/../spec_helper'
require File.dirname(__FILE__) + '/fixtures/ensure'

describe "An ensure block inside a begin block" do
  it "is executed when an exception is raised in it's corresponding begin block" do
    begin
      executed = []
      
      lambda {
        begin
          executed << :begin
          raise "An exception occured!"
        ensure
          executed << :ensure
        end
      }.should raise_error(RuntimeError)
      
      executed.should eql([:begin, :ensure])
    end
  end

  it "is executed when an exception is raised and rescued in it's corresponding begin block" do
    begin
      executed = []
      
      begin
        executed << :begin
        raise "An exception occured!"
      rescue
        executed << :rescue
      ensure
        executed << :ensure
      end
      
      executed.should eql([:begin, :rescue, :ensure])
    end
  end

  it "is executed even when a symbol is thrown in it's corresponding begin block" do
    begin
      executed = []
      
      catch(:symbol) do
        begin
          executed << :begin
          throw(:symbol)
        rescue
          executed << :rescue
        ensure
          executed << :ensure
        end
      end
      
      executed.should eql([:begin, :ensure])
    end
{'fraction_non_alphanumeric': 0.08217112702600829, 'fraction_numerical': 0.0, 'mean_word_length': 1.8054968287526427, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '894618', 'n_tokens_mistral': 706, 'n_tokens_neox': 721, 'n_words': 246}