1
exercism fetch crystal pascals-triangle

spec/pascals_triangle_spec.cr

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
require "spec"
require "../src/*"

describe "PascalsTriangle" do
  it "will return the first 0 row(s)" do
    PascalsTriangle.rows(0).should eq([] of Int32)
  end

  pending "will return the first 1 row(s)" do
    PascalsTriangle.rows(1).should eq([[1]])
  end

  pending "will return the first 2 row(s)" do
    PascalsTriangle.rows(2).should eq([[1], [1, 1]])
  end

  pending "will return the first 3 row(s)" do
    PascalsTriangle.rows(3).should eq([[1], [1, 1], [1, 2, 1]])
  end

  pending "will return the first 4 row(s)" do
    PascalsTriangle.rows(4).should eq([[1], [1, 1], [1, 2, 1], [1, 3, 3, 1]])
  end

  pending "will raise an Argument error for negative rows" do
    expect_raises do
      PascalsTriangle.rows(-1)
    end
  end
end