Class: TestArray

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/quiz1/t/solutions/Moses Hohman/test_util.rb

Instance Method Summary collapse

Instance Method Details

#test_collect_peelObject



24
25
26
27
28
# File 'lib/quiz1/t/solutions/Moses Hohman/test_util.rb', line 24

def test_collect_peel
	a1 = [1,3,5]
	a2 = [2,4,6]
	assert_equal([3,7,11], [a1, a2].collect_peel { |a,b| a+b })
end

#test_peel_all_arrays_same_lengthObject



6
7
8
9
10
11
12
13
# File 'lib/quiz1/t/solutions/Moses Hohman/test_util.rb', line 6

def test_peel_all_arrays_same_length
	tuples = []
	a1 = [1,3,5]
	a2 = [2,4,6]
	a3 = [1,4,9]
	[a1, a2, a3].peel { |x,y,z| tuples << [x,y,z] }
	assert_equal([[1,2,1],[3,4,4],[5,6,9]], tuples)
end

#test_peel_one_array_shorterObject



15
16
17
18
19
20
21
22
# File 'lib/quiz1/t/solutions/Moses Hohman/test_util.rb', line 15

def test_peel_one_array_shorter
	tuples = []
	a1 = [1,3,5]
	a2 = [2,4]
	a3 = [1,4,9]
	[a1, a2, a3].peel { |x,y,z| tuples << [x,y,z] }
	assert_equal([[1,2,1],[3,4,4]], tuples)
end