spec/lib/algebra/formula_spec.rb in dydx-0.0.4 vs spec/lib/algebra/formula_spec.rb in dydx-0.0.5

- old
+ new

@@ -7,12 +7,12 @@ let(:division) { (:x / :y) } let(:exponentiation){ (:x ^ :y) } describe 'Calculate' do context 'With Fixnum' do let(:formula) { (:x + :y) } - it{ expect((formula + 0).to_s).to eq(formula.to_s) } - it{ expect((formula - 0).to_s).to eq(formula.to_s) } + 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_s}.to raise_error(ZeroDivisionError) } it{ expect(formula / 1).to eq(formula) } it{ expect((formula ^ 0).to_s).to eq('1') } @@ -32,26 +32,31 @@ 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(subtraction.d(:x).to_s).to eq('1') } - it{ expect(subtraction.d(:y).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(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(division.d(:x).to_s).to eq("( y ^ -1 )") } - it{ expect(division.d(:y).to_s).to eq('( ( - x ) / ( y ^ 2 ) )') } + 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(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') } end describe '#include?' do it{ expect(addition.include?(:x)).to be_true } it{ expect(addition.include?(:z)).to be_false } + end + + 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