examples/general/calc_iter2/spec/calculator_spec.rb in rley-0.5.06 vs examples/general/calc_iter2/spec/calculator_spec.rb in rley-0.5.07

- old
+ new

@@ -166,13 +166,23 @@ expect_expr('2*(1/(1+3))').to eq(0.5) end # Some special functions it 'should evaluate square root of expressions' do + expect_expr('sqrt(0)').to eq(0) + expect_expr('sqrt(1)').to eq(1) expect_expr('sqrt(1 + 1)').to eq(Math.sqrt(2)) - end + expect_expr('sqrt(5 * 5)').to eq(5) + end + it 'should evaluate cubic root of expressions' do + expect_expr('cbrt(0)').to eq(0) + expect_expr('cbrt(1)').to eq(1) + expect_expr('cbrt(1 + 1)').to eq(Math.cbrt(2)) + expect_expr('cbrt(5 * 5 * 5)').to eq(5) + end + it 'should evaluate exponential of expressions' do expect_expr('exp(-1)').to eq(1/Math::E) expect_expr('exp(0)').to eq(1) expect_expr('exp(1)').to eq(Math::E) expect_expr('exp(2)').to be_within(0.0000000001).of(Math::E * Math::E) @@ -181,10 +191,17 @@ it 'should evaluate natural logarithm of expressions' do expect_expr('ln(1/E)').to eq(-1) expect_expr('ln(1)').to eq(0) expect_expr('ln(E)').to eq(1) expect_expr('ln(E * E)').to eq(2) - end + end + + it 'should evaluate the logarithm base 10 of expressions' do + expect_expr('log(1/10)').to eq(-1) + expect_expr('log(1)').to eq(0) + expect_expr('log(10)').to eq(1) + expect_expr('log(10 * 10 * 10)').to eq(3) + end # Trigonometric functions it 'should compute the sinus of an expression' do expect_expr('sin(0)').to eq(0)