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

describe "BigDecimal#nonzero?" do

  it "returns self if self doesn't equal zero" do
    # documentation says, it returns true. (04/10/08)
    e2_plus = BigDecimal("2E40001")
    e3_minus = BigDecimal("3E-20001")
    infinity = BigDecimal("Infinity")
    infinity_minus = BigDecimal("-Infinity")
    nan = BigDecimal("NaN")
    infinity.nonzero?.should == infinity
    infinity_minus.nonzero?.should == infinity_minus
    nan.nonzero?.to_s.should == 'NaN'
    # NaN never equals, not even it self.
    e3_minus.nonzero?.should == e3_minus
    e2_plus.nonzero?.should == e2_plus
  end

  it "returns nil otherwise" do
    # documentation states, it should return false. (04/10/08)
    really_small_zero = BigDecimal("0E-200000000")
    really_big_zero = BigDecimal("0E200000000000")
    really_small_zero.nonzero?.should == nil
    really_big_zero.nonzero?.should == nil
    BigDecimal("0.000000000000000000000000").nonzero?.should == nil
  end

end<commit_msg>Fixed incorrect check for object equality in BigDecimal#nonzero? spec<commit_after>require File.dirname(__FILE__) + '/../../spec_helper'
require 'bigdecimal'

describe "BigDecimal#nonzero?" do

  it "returns self if self doesn't equal zero" do
    # documentation says, it returns true. (04/10/08)
    e2_plus = BigDecimal("2E40001")
    e3_minus = BigDecimal("3E-20001")
    infinity = BigDecimal("Infinity")
    infinity_minus = BigDecimal("-Infinity")
    nan = BigDecimal("NaN")
    infinity.nonzero?.should.equal?(infinity)
    infinity_minus.nonzero?.should.equal?(infinity_minus)
    nan.nonzero?.should.equal?(nan)
    e3_minus.nonzero?.should.equal?(e3_minus)
    e2_plus.nonzero?.should.equal?(e2_plus)
  end

  it "returns nil otherwise" do
    # documentation states, it should return false. (04/10/08)
    really_small_zero = BigDecimal("0E-200000000")
    really_big_zero = BigDecimal("0E200000000000")
    really_small_zero.nonzero?.should == nil
    really_big_zero.nonzero?.should == nil
    BigDecimal("0.000000000000000000000000").nonzero?.should == nil
  end

end
{'fraction_non_alphanumeric': 0.1246485473289597, 'fraction_numerical': 0.07310215557638237, 'mean_word_length': 4.132211538461538, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 6, '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': '7143263', 'n_tokens_mistral': 794, 'n_tokens_neox': 679, 'n_words': 145}