Skip to content

Commit

Permalink
Improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
project-eutopia committed Nov 23, 2018
1 parent efa385b commit a5189c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion spec/keisan/default_functions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@
describe "continue" do
it "skips to the next iteration of the loop" do
calculator = Keisan::Calculator.new
expect(calculator.evaluate("x = 0; sum = 0; while(x < 10, x += 1; if (x % 2 == 0, continue); sum += x**2); sum")).to eq(
expect(calculator.simplify("x = 0; sum = 0; while(x < 10, x += 1; if (x % 2 == 0, continue); sum += x**2); sum").value).to eq(
1 + 3**2 + 5**2 + 7**2 + 9**2
)
end
Expand Down
6 changes: 6 additions & 0 deletions spec/keisan/functions/while_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@
expect(calculator.evaluate("[1,2,3].includes(2)")).to eq true
expect(calculator.evaluate("[1,2,3].includes(4)")).to eq false
end

it "must have boolean in condition expression" do
calculator = Keisan::Calculator.new
calculator.evaluate("x = 0")
expect{calculator.evaluate("while(!x, x = x + 1)")}.to raise_error(Keisan::Exceptions::InvalidFunctionError)
end
end

0 comments on commit a5189c9

Please sign in to comment.