Skip to content

Commit dceb305

Browse files
committed
about_blocks
1 parent 264f9d3 commit dceb305

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

.path_progress

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
0,1,2,5,6
22
,8,9,10,13,15,16
33
,18,18,19,20,20,21,22,23,24,32,33,35,35,37,39,40,41,42,42,42,43,44,46,49,50,51,52,55,56,59,60,60,61,63,64,65,67
4-
,70,71,73,74,75,75,76,77,78,79,81,81,82,84,84,85,85,87,88,90,91,93,94,96,98,99,99,100,101,103,104,106,107,107,108,109,111,111,114,115,116,116,116,117,119,121,122,123,124,125,127,128,130,130,131,132,134,135,139,141,143,145,146,149,150,151,153,151,153,153,153,154,154,154,155,158,159,159,160,163,166,166,167,167,168
4+
,70,71,73,74,75,75,76,77,78,79,81,81,82,84,84,85,85,87,88,90,91,93,94,96,98,99,99,100,101,103,104,106,107,107,108,109,111,111,114,115,116,116,116,117,119,121,122,123,124,125,127,128,130,130,131,132,134,135,139,141,143,145,146,149,150,151,153,151,153,153,153,154,154,154,155,158,159,159,160,163,166,166,167,167,168,172,173,176,177

about_blocks.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ def method_with_block
88

99
def test_methods_can_take_blocks
1010
yielded_result = method_with_block { 1 + 2 }
11-
assert_equal __, yielded_result
11+
assert_equal 3, yielded_result
1212
end
1313

1414
def test_blocks_can_be_defined_with_do_end_too
1515
yielded_result = method_with_block do 1 + 2 end
16-
assert_equal __, yielded_result
16+
assert_equal 3, yielded_result
1717
end
1818

1919
# ------------------------------------------------------------------
@@ -24,7 +24,7 @@ def method_with_block_arguments
2424

2525
def test_blocks_can_take_arguments
2626
result = method_with_block_arguments do |argument|
27-
assert_equal __, argument
27+
assert_equal 'Jim', argument
2828
end
2929
end
3030

@@ -40,7 +40,7 @@ def many_yields
4040
def test_methods_can_call_yield_many_times
4141
result = []
4242
many_yields { |item| result << item }
43-
assert_equal __, result
43+
assert_equal [:peanut, :butter, :and, :jelly], result
4444
end
4545

4646
# ------------------------------------------------------------------
@@ -54,30 +54,30 @@ def yield_tester
5454
end
5555

5656
def test_methods_can_see_if_they_have_been_called_with_a_block
57-
assert_equal __, yield_tester { :with_block }
58-
assert_equal __, yield_tester
57+
assert_equal :with_block, yield_tester { :with_block }
58+
assert_equal :no_block, yield_tester
5959
end
6060

6161
# ------------------------------------------------------------------
6262

6363
def test_block_can_affect_variables_in_the_code_where_they_are_created
6464
value = :initial_value
6565
method_with_block { value = :modified_in_a_block }
66-
assert_equal __, value
66+
assert_equal :modified_in_a_block, value
6767
end
6868

6969
def test_blocks_can_be_assigned_to_variables_and_called_explicitly
7070
add_one = lambda { |n| n + 1 }
71-
assert_equal __, add_one.call(10)
71+
assert_equal 11, add_one.call(10)
7272

7373
# Alternative calling sequence
74-
assert_equal __, add_one[10]
74+
assert_equal 11, add_one[10]
7575
end
7676

7777
def test_stand_alone_blocks_can_be_passed_to_methods_expecting_blocks
7878
make_upper = lambda { |n| n.upcase }
7979
result = method_with_block_arguments(&make_upper)
80-
assert_equal __, result
80+
assert_equal 'JIM', result
8181
end
8282

8383
# ------------------------------------------------------------------
@@ -87,10 +87,10 @@ def method_with_explicit_block(&block)
8787
end
8888

8989
def test_methods_can_take_an_explicit_block_argument
90-
assert_equal __, method_with_explicit_block { |n| n * 2 }
90+
assert_equal 20, method_with_explicit_block { |n| n * 2 }
9191

9292
add_one = lambda { |n| n + 1 }
93-
assert_equal __, method_with_explicit_block(&add_one)
93+
assert_equal 11, method_with_explicit_block(&add_one)
9494
end
9595

9696
end

0 commit comments

Comments
 (0)