spec/evaluator_spec.rb in dentaku-0.2.12 vs spec/evaluator_spec.rb in dentaku-0.2.13

- old
+ new

@@ -39,16 +39,22 @@ expected = token_stream(2, :multiply, 5) evaluator.evaluate_step(stream, 0, 5, :evaluate_group).should eq(expected) end + it 'supports unary minus' do + evaluator.evaluate(token_stream(:subtract, 1)).should eq(-1) + evaluator.evaluate(token_stream(1, :subtract, :subtract, 1)).should eq(2) + end + describe 'maths' do it 'should perform addition' do evaluator.evaluate(token_stream(1, :add, 1)).should eq(2) end it 'should respect order of precedence' do evaluator.evaluate(token_stream(1, :add, 1, :multiply, 5)).should eq(6) + evaluator.evaluate(token_stream(2, :add, 10, :mod, 2)).should eq(2) end it 'should respect explicit grouping' do evaluator.evaluate(token_stream(:open, 1, :add, 1, :close, :multiply, 5)).should eq(10) end