16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'test/array/test_array.rb', line 16
def test_rephrase_index
test = [ :a, :b, :c, :d]
0.upto(3) do | i |
i_inv = test.rephrase_index(i)
i_neg = test.rephrase_index(i, :neg)
i_pos = test.rephrase_index(i, :pos)
i_last = test.rephrase_index(i, :detect_last)
assert_not_equal i, i_inv
assert_not_equal i, i_neg
assert_equal i_neg, i_inv
assert_equal i, i_pos
assert_equal test[i], test[i_inv]
assert_equal test[i], test[i_pos]
assert_equal test[i], test[i_neg]
assert_equal test[i], test[i_last]
end
-4.upto(-1) do | i |
i_inv = test.rephrase_index(i)
i_neg = test.rephrase_index(i, :neg)
i_pos = test.rephrase_index(i, :pos)
i_last = test.rephrase_index(i, :detect_last)
assert_not_equal i, i_inv
assert_not_equal i, i_pos
assert_equal i_pos, i_inv
assert_equal i, i_neg
assert_equal test[i], test[i_inv]
assert_equal test[i], test[i_pos]
assert_equal test[i], test[i_neg]
assert_equal test[i], test[i_last]
end
[4, 5, -5, -6].each do |i|
i_inv = test.rephrase_index(i)
i_neg = test.rephrase_index(i, :neg)
i_pos = test.rephrase_index(i, :pos)
i_last = test.rephrase_index(i, :detect_last)
assert_equal i, i_neg
assert_equal i, i_pos
assert_equal i, i_neg
assert_equal test[i], test[i_inv]
assert_equal test[i], test[i_pos]
assert_equal test[i], test[i_neg]
assert_equal test[i], test[i_last]
end
end
|