Sha256: 0f0e02bd1fa97f773e447c5ef37db31959303082c66e4b7239098a431cb505b6
Contents?: true
Size: 790 Bytes
Versions: 27
Compression:
Stored size: 790 Bytes
Contents
require 'test_helper' # This tests our Integer calculations extension class Integer::CalculationsTest < Minitest::Test test 'Integer should be extended with #factorial' do assert 1.respond_to?(:factorial) end test 'Integer#factorial should behave correctly' do assert_equal 1, 0.factorial assert_equal 24, 4.factorial assert_raises(RuntimeError) { -1.factorial } end test 'Integer should be extended with #choose' do assert 1.respond_to?(:choose) end test 'Integer#choose should behave correctly' do pascal_row = [1, 5, 10, 10, 5, 1] pascal_row.each_with_index do |target, index| assert_equal target, 5.choose(index) end assert_raises(ArgumentError) { 10.choose(11) } assert_raises(ArgumentError) { 10.choose(-1) } end end
Version data entries
27 entries across 27 versions & 1 rubygems