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

describe :numeric_arg, :shared => true do
  before(:each) do
    @numbers = [
      20,             # Integer
      398.72,         # Float
      Rational(3, 4), # Rational
      99999999**99, # Bignum
      Float::MAX * 2, # Infinity
    ] 
  end

  it "returns 0 if positive" do
    @numbers.each do |number| 
      number.send(@method).should == 0
    end
  end  

  # Unsure what this should do; fix after seeing resolution of bug report
  ruby_bug "#1715", "1.9" do
    it "returns 0 if self is NaN" do
      nan_value.send(@method).should == 0 
    end
  end

  it "returns Pi if negative" do
    @numbers.each do |number| 
      # NaN can't be negated
      next if number.to_f.nan?
      (0-number).send(@method).should == Math::PI
    end
  end  

  it "raises an ArgumentError if given any arguments" do
   @numbers.each do |number| 
     lambda { number.send(@method, number) }.should raise_error(ArgumentError)
   end
  end
end  <commit_msg>Numeric#arg|phase: Returns NaN if self is NaN; 1.8 is buggy.<commit_after>require File.dirname(__FILE__) + '/../../../spec_helper'

describe :numeric_arg, :shared => true do
  before(:each) do
    @numbers = [
      20,             # Integer
      398.72,         # Float
      Rational(3, 4), # Rational
      99999999**99, # Bignum
      Float::MAX * 2, # Infinity
    ] 
  end

  it "returns 0 if positive" do
    @numbers.each do |number| 
      number.send(@method).should == 0
    end
  end  

  ruby_bug "#1715", "1.8.6.369" do
    it "returns NaN if self is NaN" do
      (-nan_value).send(@method).nan?.should be_true
      nan_value.send(@method).nan?.should be_true
    end
  end

  it "returns Pi if negative" do
    @numbers.each do |number| 
      (0-number).send(@method).should == Math::PI
    end
  end  

  it "raises an ArgumentError if given any arguments" do
   @numbers.each do |number| 
     lambda { number.send(@method, number) }.should raise_error(ArgumentError)
   end
  end
end  
{'fraction_non_alphanumeric': 0.1234628627643876, 'fraction_numerical': 0.03246433841613379, 'mean_word_length': 2.3564356435643563, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 2, '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': '6933936', 'n_tokens_mistral': 733, 'n_tokens_neox': 655, 'n_words': 202}