spec/evaluator_spec.rb in dentaku-0.2.13 vs spec/evaluator_spec.rb in dentaku-0.2.14
- old
+ new
@@ -6,11 +6,11 @@
describe 'rule scanning' do
it 'should find a matching rule' do
rule = [Dentaku::TokenMatcher.new(:numeric, nil)]
stream = [Dentaku::Token.new(:numeric, 1), Dentaku::Token.new(:operator, :add), Dentaku::Token.new(:numeric, 1)]
- position, match = evaluator.find_rule_match(rule, stream)
+ position, _match = evaluator.find_rule_match(rule, stream)
position.should eq(0)
end
end
describe 'evaluating' do
@@ -42,9 +42,14 @@
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
+
+ it 'supports unary percentage' do
+ evaluator.evaluate(token_stream(50, :mod)).should eq(0.5)
+ evaluator.evaluate(token_stream(50, :mod, :multiply, 100)).should eq(50)
end
describe 'maths' do
it 'should perform addition' do
evaluator.evaluate(token_stream(1, :add, 1)).should eq(2)