Skip to content

Commit 581120f

Browse files
committed
Merge pull request franzejr#1 from rafaelsales/master
Add expected outputs when running files.
2 parents 39ddf05 + 2c2ef46 commit 581120f

30 files changed

+147
-0
lines changed

associative_arrays.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@
33

44
p aa.assoc("Someone")
55
p aa.assoc("Bla")
6+
7+
# Result:
8+
# ["Someone", "1"]
9+
# ["Bla", "2"]

autovivification.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33

44
deep[:a][:b][:c][:d] = 42
55
p deep
6+
7+
# Result:
8+
# {:a=>{:b=>{:c=>{:d=>42}}}}

blocks_can_take_blocks.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@
66
end
77

88
object.show_var_and_block { :block }
9+
10+
# Result:
11+
# [:var, #<Proc:0x007ffd6c038128@./blocks_can_take_blocks.rb:8>]

bubbling_up_thread_errors.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@
77
loop do
88
sleep
99
end
10+
11+
# Result:
12+
# ./bubbling_up_thread_errors.rb:4:in `block in <main>': Ops, we cannot continue (RuntimeError)

case_on_ranges.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@
99
when 65..Float::INFINITY
1010
p 'You are too old'
1111
end
12+
13+
# Result:
14+
# 55
15+
# "You are at the right age"

count_all_objects.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
11
require 'pp'
22

33
pp ObjectSpace.count_objects
4+
5+
# Result:
6+
# {:TOTAL=>30163,
7+
# :FREE=>1007,
8+
# :T_OBJECT=>39,
9+
# :T_CLASS=>534,
10+
# :T_MODULE=>24,
11+
# :T_FLOAT=>4,
12+
# :T_STRING=>9290,
13+
# :T_REGEXP=>70,
14+
# :T_ARRAY=>2231,
15+
# :T_HASH=>53,
16+
# :T_STRUCT=>1,
17+
# :T_BIGNUM=>2,
18+
# :T_FILE=>14,
19+
# :T_DATA=>966,
20+
# :T_MATCH=>1,
21+
# :T_COMPLEX=>1,
22+
# :T_NODE=>15896,
23+
# :T_ICLASS=>30}

cycle.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
ring = %w[one two three].cycle
22

33
p ring.take(5)
4+
5+
# Result:
6+
# ["one", "two", "three", "one", "two"]

easiest_database_pstore.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,10 @@
2020
p 'People %p' % db['people2']
2121
p 'Money %p' % db['money2']
2222
end
23+
24+
# Result:
25+
# "People \"Someone\""
26+
# "Money 400"
27+
# "SECOND PERSON"
28+
# "People \"Someone2\""
29+
# "Money 300"

easiest_database_pstore_yaml.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,10 @@
2020
p 'People %p' % db['people2']
2121
p 'Money %p' % db['money2']
2222
end
23+
24+
# Result:
25+
# "People \"Someone\""
26+
# "Money 400"
27+
# "SECOND PERSON"
28+
# "People \"Someone2\""
29+
# "Money 300"

enable_ruby_warnings.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ def var
99

1010
p WarnMe.new.var
1111

12+
13+
# Result:
14+
# ./enable_ruby_warnings.rb:5: warning: instance variable @var not initialized
15+
# 42

0 commit comments

Comments
 (0)