Skip to content

Commit

Permalink
triangle 1.2.1: Shorten and clarify test descriptions
Browse files Browse the repository at this point in the history
The current [Test] names confused me when I was doing the exercise. It
was also difficult to see which tests failed, because of long test
descriptions combined with a small window with the test results.

This PR changes the
"Returns true if the triangle is equilateral false if any side is unequal"
style in favour of a pattern that follows
"equilateral triangle returns false if any side is unequal".

exercism/problem-specifications#1483

Note for the Crystal track:

Since the the following case group descriptions do not appear in the
test file (for example, as a `describe` or a `context`), test
descriptions may be considered to be missing some context. However, this
has always been the case, so this does not worsen the state of the
world, only keep it about as bad as it always has been.

https://github.com/exercism/problem-specifications/blob/master/exercises/triangle/canonical-data.json#L22
https://github.com/exercism/problem-specifications/blob/master/exercises/triangle/canonical-data.json#L71
https://github.com/exercism/problem-specifications/blob/master/exercises/triangle/canonical-data.json#L152
  • Loading branch information
Mehni authored and petertseng committed Nov 1, 2019
1 parent da41e2e commit 9706fdd
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions exercises/triangle/spec/triangle_spec.cr
Expand Up @@ -2,75 +2,75 @@ require "spec"
require "../src/*"

describe "Triangle" do
it "true if all sides are equal" do
it "all sides are equal" do
Triangle.new([2, 2, 2]).equilateral?.should eq(true)
end

pending "false if any side is unequal" do
pending "any side is unequal" do
Triangle.new([2, 3, 2]).equilateral?.should eq(false)
end

pending "false if no sides are equal" do
pending "no sides are equal" do
Triangle.new([5, 4, 6]).equilateral?.should eq(false)
end

pending "All zero sides are illegal, so the triangle is not equilateral" do
pending "all zero sides is not a triangle" do
Triangle.new([0, 0, 0]).equilateral?.should eq(false)
end

pending "sides may be floats" do
Triangle.new([0.5, 0.5, 0.5]).equilateral?.should eq(true)
end

pending "true if last two sides are equal" do
pending "last two sides are equal" do
Triangle.new([3, 4, 4]).isosceles?.should eq(true)
end

pending "true if first two sides are equal" do
pending "first two sides are equal" do
Triangle.new([4, 4, 3]).isosceles?.should eq(true)
end

pending "true if first and last sides are equal" do
pending "first and last sides are equal" do
Triangle.new([4, 3, 4]).isosceles?.should eq(true)
end

pending "equilateral triangles are also isosceles" do
Triangle.new([4, 4, 4]).isosceles?.should eq(true)
end

pending "false if no sides are equal" do
pending "no sides are equal" do
Triangle.new([2, 3, 4]).isosceles?.should eq(false)
end

pending "Sides that violate triangle inequality are not isosceles, even if two are equal (1)" do
pending "first triangle inequality violation" do
Triangle.new([1, 1, 3]).isosceles?.should eq(false)
end

pending "Sides that violate triangle inequality are not isosceles, even if two are equal (2)" do
pending "second triangle inequality violation" do
Triangle.new([1, 3, 1]).isosceles?.should eq(false)
end

pending "Sides that violate triangle inequality are not isosceles, even if two are equal (3)" do
pending "third triangle inequality violation" do
Triangle.new([3, 1, 1]).isosceles?.should eq(false)
end

pending "sides may be floats" do
Triangle.new([0.5, 0.4, 0.5]).isosceles?.should eq(true)
end

pending "true if no sides are equal" do
pending "no sides are equal" do
Triangle.new([5, 4, 6]).scalene?.should eq(true)
end

pending "false if all sides are equal" do
pending "all sides are equal" do
Triangle.new([4, 4, 4]).scalene?.should eq(false)
end

pending "false if two sides are equal" do
pending "two sides are equal" do
Triangle.new([4, 4, 3]).scalene?.should eq(false)
end

pending "Sides that violate triangle inequality are not scalene, even if they are all different" do
pending "may not violate triangle inequality" do
Triangle.new([7, 3, 2]).scalene?.should eq(false)
end

Expand Down

0 comments on commit 9706fdd

Please sign in to comment.