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

ruby_version_is "1.9" do
  describe "Math.lgamma" do
    it "returns an array of 2 elements" do
      lg = Math.lgamma(0)
      lg.should be_kind_of(Array)
      lg.size.should == 2
    end

    it "returns known values" do
      Math.lgamma(0).should  == [1.0/0, 1]
      Math.lgamma(-1).should == [1.0/0, 1]
      lg1 = Math.lgamma(0.5)
      lg1[0].should be_close(Math.log(Math.sqrt(Math::PI)), TOLERANCE)
      lg1[1].should == 1

      lg2 = Math.lgamma(6.0)
      lg2[0].should be_close(Math.log(120.0), TOLERANCE)
      lg2[1].should == 1
    end

    it "returns good numerical approximations" do
      lg1 = Math.lgamma(-0.5)
      lg1[0].should be_close(1.2655121, TOLERANCE)
      lg1[1].should == -1

      lg2 = Math.lgamma(-1.5)
      lg2[0].should be_close(0.8600470, TOLERANCE)
      lg2[1].should == 1
    end

    ruby_version_is ""..."1.9" do
      it "returns correct values given +/- infinity" do
        Math.lgamma( 1.0/0).should == [1.0/0, 1]
        Math.lgamma(-1.0/0).should == [1.0/0, 1]
      end
    end

    ruby_version_is "1.9" do
      it "returns correct values only given - infinity" do
        lambda { Math.lgamma( 1.0/0) }.should raise_error(Errno::EDOM)
        Math.lgamma(-1.0/0).should == [1.0/0, 1]
      end
    end

    it "returns correct value given NaN" do
      Math.lgamma(0.0/0)[0].nan?.should be_true
      Math.lgamma(0.0/0)[1].should == 1
    end
  end
end<commit_msg>Clean up guards, and reset the expectations to match the current MRI trunk behavior (r26303).<commit_after>require File.dirname(__FILE__) + '/../../spec_helper'

ruby_version_is "1.9" do
  describe "Math.lgamma" do
    it "returns an array of 2 elements" do
      lg = Math.lgamma(0)
      lg.should be_kind_of(Array)
      lg.size.should == 2
    end

    it "returns known values" do
      Math.lgamma(0).should  == [1.0/0, 1]
      Math.lgamma(-1).should == [1.0/0, 1]
      lg1 = Math.lgamma(0.5)
      lg1[0].should be_close(Math.log(Math.sqrt(Math::PI)), TOLERANCE)
      lg1[1].should == 1

      lg2 = Math.lgamma(6.0)
      lg2[0].should be_close(Math.log(120.0), TOLERANCE)
      lg2[1].should == 1
    end

    it "returns good numerical approximations" do
      lg1 = Math.lgamma(-0.5)
      lg1[0].should be_close(1.2655121, TOLERANCE)
      lg1[1].should == -1

      lg2 = Math.lgamma(-1.5)
      lg2[0].should be_close(0.8600470, TOLERANCE)
      lg2[1].should == 1
    end

    it "returns correct values given +/- infinity" do
      Math.lgamma( 1.0/0).should == [1.0/0, 1]
      Math.lgamma(-1.0/0).should == [1.0/0, 1]
    end

    it "returns correct value given NaN" do
      Math.lgamma(0.0/0)[0].nan?.should be_true
      Math.lgamma(0.0/0)[1].should == 1
    end
  end
end
{'fraction_non_alphanumeric': 0.15693299892511645, 'fraction_numerical': 0.07130060910068076, 'mean_word_length': 2.300236406619385, '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': '5414642', 'n_tokens_mistral': 1181, 'n_tokens_neox': 1073, 'n_words': 238}