spec/lib/algebra/formula_spec.rb in dydx-0.0.6 vs spec/lib/algebra/formula_spec.rb in dydx-0.0.7

- old
+ new

@@ -7,17 +7,17 @@ let(:division) { (:x / :y) } let(:exponentiation){ (:x ^ :y) } describe 'Calculate' do context 'With Fixnum' do let(:formula) { (:x + :y) } - it{ expect(formula + 0).to eq(formula + 0) } - it{ expect(formula - 0).to eq(formula - 0) } - it{ expect((formula * 0).to_s).to eq('0') } - it{ expect((formula * 1).to_s).to eq(formula.to_s) } + it{ expect(formula + 0).to eq(formula) } + it{ expect(formula - 0).to eq(formula) } + it{ expect(formula * 0).to eq(0) } + it{ expect(formula * 1).to eq(formula) } it{ expect{(formula / 0).to_s}.to raise_error(ZeroDivisionError) } it{ expect(formula / 1).to eq(formula) } - it{ expect((formula ^ 0).to_s).to eq('1') } + it{ expect(formula ^ 0).to eq(1) } end end describe '#to_s' do it{ expect(addition.to_s).to eq('( x + y )') } @@ -27,29 +27,29 @@ it{ expect(exponentiation.to_s).to eq('( x ^ y )') } it{ expect( (addition * multiplication).to_s ).to eq('( ( x + y ) * ( x * y ) )') } end describe '#differentiate' do - it{ expect(addition.d(:x).to_s).to eq('1') } - it{ expect(addition.d(:y).to_s).to eq('1') } - it{ expect(addition.d(:z).to_s).to eq('0') } + it{ expect(addition.d(:x)).to eq(1) } + it{ expect(addition.d(:y)).to eq(1) } + it{ expect(addition.d(:z)).to eq(0) } - it{ expect(subtraction.d(:x).to_s).to eq('1') } - it{ expect(subtraction.d(:y).to_s).to eq('( - 1 )') } - it{ expect(subtraction.d(:z).to_s).to eq('0') } + it{ expect(subtraction.d(:x)).to eq(1) } + it{ expect(subtraction.d(:y)).to eq('( - 1 )') } + it{ expect(subtraction.d(:z)).to eq(0) } it{ expect(multiplication.d(:x)).to eq(:y) } it{ expect(multiplication.d(:y)).to eq(:x) } - it{ expect(multiplication.d(:z).to_s).to eq('0') } + it{ expect(multiplication.d(:z)).to eq(0) } - it{ expect(division.d(:x).to_s).to eq("( 1 / y )") } - it{ expect(division.d(:y).to_s).to eq('( - ( x / ( y ^ 2 ) ) )') } - it{ expect(division.d(:z).to_s).to eq('0') } + it{ expect(division.d(:x)).to eq(1/:y) } + it{ expect(division.d(:y)).to eq('( - ( x / ( y ^ 2 ) ) )') } + it{ expect(division.d(:z)).to eq(0) } it{ expect(exponentiation.d(:x).to_s).to eq('( y * ( x ^ ( y - 1 ) ) )') } - it{ expect(exponentiation.d(:y).to_s).to eq('( ( x ^ y ) * log( x ) )') } - it{ expect(exponentiation.d(:z).to_s).to eq('0') } + it{ expect(exponentiation.d(:y)).to eq((:x ^ :y) * log(:x)) } + it{ expect(exponentiation.d(:z)).to eq(0) } end describe '#include?' do it{ expect(addition.include?(:x)).to be_true } it{ expect(addition.include?(:z)).to be_false } @@ -57,6 +57,6 @@ describe '#openable?' do it{ expect((1 + :x).openable?(_(1))).to be_true } it{ expect((1 + :x).openable?(:z)).to be_false } end -end \ No newline at end of file +end