<commit_before>require_relative '../spec_helper'
require_relative 'fixtures/yield'

# Note that these specs use blocks defined as { |*a| ... } to capture the
# arguments with which the block is invoked. This is slightly confusing
# because the outer Array is a consequence of |*a| but it is necessary to
# clearly distinguish some behaviors.

describe "The yield call" do
  before :each do
    @y = YieldSpecs::Yielder.new
  end

  describe "taking no arguments" do
    it "raises a LocalJumpError when the method is not passed a block" do
      lambda { @y.z }.should raise_error(LocalJumpError)
    end

    it "ignores assignment to the explicit block argument and calls the passed block" do
      @y.ze { 42 }.should == 42
    end
  end

  describe "taking a single argument" do
    describe "when no block is given" do
      it "raises a LocalJumpError" do
        lambda { @y.s(1) }.should raise_error(LocalJumpError)
      end<commit_msg>Set named block argument to nil when yielding to a block.<commit_after>require_relative '../spec_helper'
require_relative 'fixtures/yield'

# Note that these specs use blocks defined as { |*a| ... } to capture the
# arguments with which the block is invoked. This is slightly confusing
# because the outer Array is a consequence of |*a| but it is necessary to
# clearly distinguish some behaviors.

describe "The yield call" do
  before :each do
    @y = YieldSpecs::Yielder.new
  end

  describe "taking no arguments" do
    it "raises a LocalJumpError when the method is not passed a block" do
      lambda { @y.z }.should raise_error(LocalJumpError)
    end

    it "ignores assignment to the explicit block argument and calls the passed block" do
      @y.ze { 42 }.should == 42
    end

    it "passes nil as a named block" do
      @y.z() { |&block| block == nil }.should == true
    end
  end

  describe "taking a single argument" do
    describe "when no block is given" do
      it "raises a LocalJumpError" do
        lambda { @y.s(1) }.should raise_error(LocalJumpError)
      end
{'fraction_non_alphanumeric': 0.0780559646539028, 'fraction_numerical': 0.004909180166912126, 'mean_word_length': 3.184804928131417, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4855176', 'n_tokens_mistral': 615, 'n_tokens_neox': 586, 'n_words': 268}