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

describe "Rational#** when passed [Rational]" do
  conflicts_with :Prime do
    it "converts self to a Float and returns it raised to the passed argument" do
      (Rational(3, 4) ** Rational(4, 3)).should be_close(0.681420222312052, TOLERANCE)
      (Rational(3, 4) ** Rational(-4, 3)).should be_close(1.46752322173095, TOLERANCE)
      (Rational(3, 4) ** Rational(4, -3)).should be_close(1.46752322173095, TOLERANCE)

      (Rational(3, 4) ** Rational(0, 3)).should eql(1.0)
      (Rational(-3, 4) ** Rational(0, 3)).should eql(1.0)
      (Rational(3, -4) ** Rational(0, 3)).should eql(1.0)
      (Rational(3, 4) ** Rational(0, -3)).should eql(1.0)

      (Rational(bignum_value, 4) ** Rational(0, 3)).should eql(1.0)
      (Rational(3, -bignum_value) ** Rational(0, 3)).should eql(1.0)
      (Rational(3, 4) ** Rational(0, bignum_value)).should eql(1.0)
      (Rational(3, 4) ** Rational(0, -bignum_value)).should eql(1.0)
    end

    it "returns NaN when self is negative and the passed argument is not 0" do
      (Rational(-3, 4) ** Rational(-4, 3)).nan?.should be_true<commit_msg>Rational#** returns a Rational if possible on 1.9.<commit_after>require File.dirname(__FILE__) + '/../../spec_helper'
require 'rational'

describe "Rational#** when passed [Rational]" do
  conflicts_with :Prime do
    ruby_version_is ""..."1.9" do
      it "converts self to a Float and returns it raised to the passed argument" do
        (Rational(3, 4) ** Rational(4, 3)).should be_close(0.681420222312052, TOLERANCE)
        (Rational(3, 4) ** Rational(-4, 3)).should be_close(1.46752322173095, TOLERANCE)
        (Rational(3, 4) ** Rational(4, -3)).should be_close(1.46752322173095, TOLERANCE)

        (Rational(3, 4) ** Rational(0, 3)).should eql(1.0)
        (Rational(-3, 4) ** Rational(0, 3)).should eql(1.0)
        (Rational(3, -4) ** Rational(0, 3)).should eql(1.0)
        (Rational(3, 4) ** Rational(0, -3)).should eql(1.0)

        (Rational(bignum_value, 4) ** Rational(0, 3)).should eql(1.0)
        (Rational(3, -bignum_value) ** Rational(0, 3)).should eql(1.0)
        (Rational(3, 4) ** Rational(0, bignum_value)).should eql(1.0)
        (Rational(3, 4) ** Rational(0, -bignum_value)).should eql(1.0)
      end
    end

    ruby_version_is "1.9" do
      it "returns self raised to the argument as a Rational if possible" do

        (Rational(3, 4) ** Rational(0, 3)).should == Rational(1, 1)
        (Rational(-3, 4) ** Rational(0, 3)).should == Rational(1, 1)
        (Rational(3, -4) ** Rational(0, 3)).should == Rational(1, 1)
        (Rational(3, 4) ** Rational(0, -3)).should == Rational(1, 1)

        (Rational(bignum_value, 4) ** Rational(0, 3)).should == Rational(1, 1)
        (Rational(3, -bignum_value) ** Rational(0, 3)).should == Rational(1, 1)
        (Rational(3, 4) ** Rational(0, bignum_value)).should == Rational(1, 1)
        (Rational(3, 4) ** Rational(0, -bignum_value)).should == Rational(1, 1)
      end

      it "returns self raised to the argument as a Float if necessary" do
        (Rational(3, 4) ** Rational(4, 3)).should be_close(0.681420222312052, TOLERANCE)
        (Rational(3, 4) ** Rational(-4, 3)).should be_close(1.46752322173095, TOLERANCE)
        (Rational(3, 4) ** Rational(4, -3)).should be_close(1.46752322173095, TOLERANCE)
      end
    end
    
    it "returns NaN when self is negative and the passed argument is not 0" do
      (Rational(-3, 4) ** Rational(-4, 3)).nan?.should be_true
{'fraction_non_alphanumeric': 0.17487266553480477, 'fraction_numerical': 0.09111488398415393, 'mean_word_length': 3.305724725943971, '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': '4605451', 'n_tokens_mistral': 1509, 'n_tokens_neox': 1354, 'n_words': 324}