Updated koans from source.
authorJim Weirich <jim.weirich@gmail.com>
Mon, 13 Sep 2010 01:33:11 +0000 (21:33 -0400)
committerJim Weirich <jim.weirich@gmail.com>
Mon, 13 Sep 2010 01:33:11 +0000 (21:33 -0400)
koans/about_dice_project.rb
koans/about_iteration.rb
koans/about_regular_expressions.rb
koans/about_sandwich_code.rb
koans/about_scoring_project.rb
koans/about_triangle_project.rb
koans/about_triangle_project_2.rb

index 28066c5..a01236a 100644 (file)
@@ -7,7 +7,7 @@ class DiceSet
   end
 end
 
-class AboutDiceSet < EdgeCase::Koan
+class AboutDiceProject < EdgeCase::Koan
   def test_can_create_a_dice_set
     dice = DiceSet.new
     assert_not_nil dice
index 83b5a28..1b64cbe 100644 (file)
@@ -78,13 +78,26 @@ class AboutIteration < EdgeCase::Koan
     assert_equal __, result
 
     # Files act like a collection of lines
-    upcase_lines = File.open("example_file.txt") do |file|
-      file.map { |line| line.strip.upcase }
+    File.open("example_file.txt") do |file|
+      upcase_lines = file.map { |line| line.strip.upcase }
+      assert_equal __, upcase_lines
     end
-    assert_equal __, upcase_lines
 
     # NOTE: You can create your own collections that work with each,
     # map, select, etc.
   end
 
+  # Bonus Question:  In the previous koan, we saw the construct:
+  #
+  #   File.open(filename) do |file|
+  #     # code to read 'file'
+  #   end
+  #
+  # Why did we do it that way instead of the following?
+  #
+  #   file = File.open(filename)
+  #   # code to read 'file'
+  #
+  # When you get to the "AboutSandwichCode" koan, recheck your answer.
+
 end
index 941b5e6..c35d757 100644 (file)
@@ -141,7 +141,7 @@ class AboutRegularExpressions < EdgeCase::Koan
 
   # THINK ABOUT IT:
   #
-  # Explain the difference between a character class ([]) and alternation (|).
+  # Explain the difference between a character class ([...]) and alternation (|).
 
   # ------------------------------------------------------------------
 
index 689e901..614a374 100644 (file)
@@ -1,6 +1,6 @@
 require File.expand_path(File.dirname(__FILE__) + '/edgecase')
 
-class AboutUsingBlocks < EdgeCase::Koan
+class AboutSandwichCode < EdgeCase::Koan
 
   def count_lines(file_name)
     file = open(file_name)
@@ -86,7 +86,7 @@ class AboutUsingBlocks < EdgeCase::Koan
   def test_finding_lines2
     assert_equal __, find_line2("example_file.txt")
   end
-  
+
   # ------------------------------------------------------------------
 
   def count_lines3(file_name)
index 2e9c207..3c8e027 100644 (file)
@@ -7,7 +7,7 @@ require File.expand_path(File.dirname(__FILE__) + '/edgecase')
 # A greed roll is scored as follows:
 #
 # * A set of three ones is 1000 points
-#   
+#
 # * A set of three numbers (other than ones) is worth 100 times the
 #   number. (e.g. three fives is 500 points).
 #
@@ -33,7 +33,7 @@ def score(dice)
   # You need to write this method
 end
 
-class AboutScoringAssignment < EdgeCase::Koan
+class AboutScoringProject < EdgeCase::Koan
   def test_score_of_an_empty_list_is_zero
     assert_equal 0, score([])
   end
index 085113b..da23bbd 100644 (file)
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/edgecase')
 # You need to write the triangle method in the file 'triangle.rb'
 require 'triangle.rb'
 
-class AboutTriangleAssignment < EdgeCase::Koan
+class AboutTriangleProject < EdgeCase::Koan
   def test_equilateral_triangles_have_equal_sides
     assert_equal :equilateral, triangle(2, 2, 2)
     assert_equal :equilateral, triangle(10, 10, 10)
@@ -22,4 +22,4 @@ class AboutTriangleAssignment < EdgeCase::Koan
     assert_equal :scalene, triangle(5, 4, 2)
   end
 end
-  
+
index f9f3976..c48c3cb 100644 (file)
@@ -3,14 +3,14 @@ require File.expand_path(File.dirname(__FILE__) + '/edgecase')
 # You need to write the triangle method in the file 'triangle.rb'
 require 'triangle.rb'
 
-class AboutTriangleAssignment2 < EdgeCase::Koan
+class AboutTriangleProject2 < EdgeCase::Koan
   # The first assignment did not talk about how to handle errors.
   # Let's handle that part now.
   def test_illegal_triangles_throw_exceptions
     assert_raise(TriangleError) do triangle(0, 0, 0) end
     assert_raise(TriangleError) do triangle(3, 4, -5) end
     assert_raise(TriangleError) do triangle(1, 1, 3) end
-    assert_raise(TriangleError) do triangle(2, 4, 2) end 
+    assert_raise(TriangleError) do triangle(2, 4, 2) end
  end
 end
-  
+