From 99308a541da30bb87ebf8acc670713f4aac1e211 Mon Sep 17 00:00:00 2001 From: Adam Mohammed Date: Tue, 21 Mar 2023 12:52:31 -0400 Subject: [PATCH] moar progress --- koans/.path_progress | 2 +- koans/about_constants.rb | 16 +++++------ koans/about_hashes.rb | 46 +++++++++++++++--------------- koans/about_keyword_arguments.rb | 12 ++++---- koans/about_methods.rb | 40 +++++++++++++------------- koans/about_regular_expressions.rb | 18 ++++++------ 6 files changed, 67 insertions(+), 67 deletions(-) diff --git a/koans/.path_progress b/koans/.path_progress index b5e1061..e385d30 100644 --- a/koans/.path_progress +++ b/koans/.path_progress @@ -1 +1 @@ -0,1,2,3,4,5,6,6,6,9,10,11,12,13,14,14,14,15,15,15,15,15,15,15,15,16,16,16,16,17,19,21,22,23,25,25,26,26,28,28,29,30,31,31,31,32,34,36,39,40,39,41,42,42,43,44,44,45,46,47,48,49,50,51,52,52,52,52,52,52,52,53,52,53,53,53,54,54,55,56,57,58,59,59,60,60,62,62,63,64,65,66,66,67,68,68,68,69,70,70,70,70,71,71,72,73,73,73,73,73,73,73,74,75,76,77,78,77,78,79,80 \ No newline at end of file +0,1,2,3,4,5,6,6,6,9,10,11,12,13,14,14,14,15,15,15,15,15,15,15,15,16,16,16,16,17,19,21,22,23,25,25,26,26,28,28,29,30,31,31,31,32,34,36,39,40,39,41,42,42,43,44,44,45,46,47,48,49,50,51,52,52,52,52,52,52,52,53,52,53,53,53,54,54,55,56,57,58,59,59,60,60,62,62,63,64,65,66,66,67,68,68,68,69,70,70,70,70,71,71,72,73,73,73,73,73,73,73,74,75,76,77,78,77,78,79,80,80,82,83,84,85,85,85,85,85,85,85,86,86,87,87,90,91,92,93,94,95,97,97,98,99,100,101,101,102,103,105,107,108,108,109,110,111,112,113,114,114 \ No newline at end of file diff --git a/koans/about_constants.rb b/koans/about_constants.rb index 68ae078..472792a 100644 --- a/koans/about_constants.rb +++ b/koans/about_constants.rb @@ -7,16 +7,16 @@ class AboutConstants < Neo::Koan C = "nested" def test_nested_constants_may_also_be_referenced_with_relative_paths - assert_equal __, C + assert_equal "nested", C end def test_top_level_constants_are_referenced_by_double_colons - assert_equal __, ::C + assert_equal "top level", ::C end def test_nested_constants_are_referenced_by_their_complete_path - assert_equal __, AboutConstants::C - assert_equal __, ::AboutConstants::C + assert_equal "nested", AboutConstants::C + assert_equal "nested", ::AboutConstants::C end # ------------------------------------------------------------------ @@ -35,7 +35,7 @@ class AboutConstants < Neo::Koan end def test_nested_classes_inherit_constants_from_enclosing_classes - assert_equal __, Animal::NestedAnimal.new.legs_in_nested_animal + assert_equal 4, Animal::NestedAnimal.new.legs_in_nested_animal end # ------------------------------------------------------------------ @@ -47,7 +47,7 @@ class AboutConstants < Neo::Koan end def test_subclasses_inherit_constants_from_parent_classes - assert_equal __, Reptile.new.legs_in_reptile + assert_equal 4, Reptile.new.legs_in_reptile end # ------------------------------------------------------------------ @@ -63,7 +63,7 @@ class AboutConstants < Neo::Koan end def test_who_wins_with_both_nested_and_inherited_constants - assert_equal __, MyAnimals::Bird.new.legs_in_bird + assert_equal 2, MyAnimals::Bird.new.legs_in_bird end # QUESTION: Which has precedence: The constant in the lexical scope, @@ -78,7 +78,7 @@ class AboutConstants < Neo::Koan end def test_who_wins_with_explicit_scoping_on_class_definition - assert_equal __, MyAnimals::Oyster.new.legs_in_oyster + assert_equal 4, MyAnimals::Oyster.new.legs_in_oyster end # QUESTION: Now which has precedence: The constant in the lexical diff --git a/koans/about_hashes.rb b/koans/about_hashes.rb index 689946a..3f88c04 100644 --- a/koans/about_hashes.rb +++ b/koans/about_hashes.rb @@ -47,47 +47,47 @@ class AboutHashes < Neo::Koan hash1 = { :one => "uno", :two => "dos" } hash2 = { :two => "dos", :one => "uno" } - assert_equal __, hash1 == hash2 + assert_equal true, hash1 == hash2 end def test_hash_keys hash = { :one => "uno", :two => "dos" } - assert_equal __, hash.keys.size - assert_equal __, hash.keys.include?(:one) - assert_equal __, hash.keys.include?(:two) - assert_equal __, hash.keys.class + assert_equal 2, hash.keys.size + assert_equal true, hash.keys.include?(:one) + assert_equal true, hash.keys.include?(:two) + assert_equal Array, hash.keys.class end def test_hash_values hash = { :one => "uno", :two => "dos" } - assert_equal __, hash.values.size - assert_equal __, hash.values.include?("uno") - assert_equal __, hash.values.include?("dos") - assert_equal __, hash.values.class + assert_equal 2, hash.values.size + assert_equal true, hash.values.include?("uno") + assert_equal true, hash.values.include?("dos") + assert_equal Array, hash.values.class end def test_combining_hashes hash = { "jim" => 53, "amy" => 20, "dan" => 23 } new_hash = hash.merge({ "jim" => 54, "jenny" => 26 }) - assert_equal __, hash != new_hash + assert_equal true, hash != new_hash - expected = { "jim" => __, "amy" => 20, "dan" => 23, "jenny" => __ } - assert_equal __, expected == new_hash + expected = { "jim" => 54, "amy" => 20, "dan" => 23, "jenny" => 26 } + assert_equal true, expected == new_hash end def test_default_value hash1 = Hash.new hash1[:one] = 1 - assert_equal __, hash1[:one] - assert_equal __, hash1[:two] + assert_equal 1, hash1[:one] + assert_equal nil, hash1[:two] hash2 = Hash.new("dos") hash2[:one] = 1 - assert_equal __, hash2[:one] - assert_equal __, hash2[:two] + assert_equal 1, hash2[:one] + assert_equal "dos", hash2[:two] end def test_default_value_is_the_same_object @@ -96,11 +96,11 @@ class AboutHashes < Neo::Koan hash[:one] << "uno" hash[:two] << "dos" - assert_equal __, hash[:one] - assert_equal __, hash[:two] - assert_equal __, hash[:three] + assert_equal ["uno", "dos"], hash[:one] + assert_equal ["uno", "dos"], hash[:two] + assert_equal ["uno", "dos"], hash[:three] - assert_equal __, hash[:one].object_id == hash[:two].object_id + assert_equal true, hash[:one].object_id == hash[:two].object_id end def test_default_value_with_block @@ -109,8 +109,8 @@ class AboutHashes < Neo::Koan hash[:one] << "uno" hash[:two] << "dos" - assert_equal __, hash[:one] - assert_equal __, hash[:two] - assert_equal __, hash[:three] + assert_equal ["uno"], hash[:one] + assert_equal ["dos"], hash[:two] + assert_equal [], hash[:three] end end diff --git a/koans/about_keyword_arguments.rb b/koans/about_keyword_arguments.rb index 740d0c0..f882b09 100644 --- a/koans/about_keyword_arguments.rb +++ b/koans/about_keyword_arguments.rb @@ -7,10 +7,10 @@ class AboutKeywordArguments < Neo::Koan end def test_keyword_arguments - assert_equal __, method_with_keyword_arguments.class - assert_equal __, method_with_keyword_arguments - assert_equal __, method_with_keyword_arguments(one: 'one') - assert_equal __, method_with_keyword_arguments(two: 2) + assert_equal Array, method_with_keyword_arguments.class + assert_equal [1, "two"], method_with_keyword_arguments + assert_equal ['one', 'two'], method_with_keyword_arguments(one: 'one') + assert_equal [1, 2], method_with_keyword_arguments(two: 2) end def method_with_keyword_arguments_with_mandatory_argument(one, two: 2, three: 3) @@ -18,10 +18,10 @@ class AboutKeywordArguments < Neo::Koan end def test_keyword_arguments_with_wrong_number_of_arguments - exception = assert_raise (___) do + exception = assert_raise (ArgumentError) do method_with_keyword_arguments_with_mandatory_argument end - assert_match(/__/, exception.message) + assert_match(/wrong number of arguments/, exception.message) end # THINK ABOUT IT: diff --git a/koans/about_methods.rb b/koans/about_methods.rb index 54d7da3..6a5aa3a 100644 --- a/koans/about_methods.rb +++ b/koans/about_methods.rb @@ -7,18 +7,18 @@ end class AboutMethods < Neo::Koan def test_calling_global_methods - assert_equal __, my_global_method(2,3) + assert_equal 5, my_global_method(2,3) end def test_calling_global_methods_without_parentheses result = my_global_method 2, 3 - assert_equal __, result + assert_equal 5, result end # (NOTE: We are Using eval below because the example code is # considered to be syntactically invalid). def test_sometimes_missing_parentheses_are_ambiguous - eval "assert_equal 5, my_global_method 2, 3" # ENABLE CHECK + eval "assert_equal 5, my_global_method(2, 3)" # ENABLE CHECK # # Ruby doesn't know if you mean: # @@ -33,15 +33,15 @@ class AboutMethods < Neo::Koan # NOTE: wrong number of arguments is not a SYNTAX error, but a # runtime error. def test_calling_global_methods_with_wrong_number_of_arguments - exception = assert_raise(___) do + exception = assert_raise(ArgumentError) do my_global_method end - assert_match(/__/, exception.message) + assert_match(/wrong number of arguments/, exception.message) - exception = assert_raise(___) do + exception = assert_raise(ArgumentError) do my_global_method(1,2,3) end - assert_match(/__/, exception.message) + assert_match(/wrong number of arguments/, exception.message) end # ------------------------------------------------------------------ @@ -51,8 +51,8 @@ class AboutMethods < Neo::Koan end def test_calling_with_default_values - assert_equal [1, __], method_with_defaults(1) - assert_equal [1, __], method_with_defaults(1, 2) + assert_equal [1, :default_value], method_with_defaults(1) + assert_equal [1, 2], method_with_defaults(1, 2) end # ------------------------------------------------------------------ @@ -62,10 +62,10 @@ class AboutMethods < Neo::Koan end def test_calling_with_variable_arguments - assert_equal __, method_with_var_args.class - assert_equal __, method_with_var_args - assert_equal __, method_with_var_args(:one) - assert_equal __, method_with_var_args(:one, :two) + assert_equal Array, method_with_var_args.class + assert_equal [], method_with_var_args + assert_equal [:one], method_with_var_args(:one) + assert_equal [:one, :two], method_with_var_args(:one, :two) end # ------------------------------------------------------------------ @@ -77,7 +77,7 @@ class AboutMethods < Neo::Koan end def test_method_with_explicit_return - assert_equal __, method_with_explicit_return + assert_equal :return_value, method_with_explicit_return end # ------------------------------------------------------------------ @@ -88,7 +88,7 @@ class AboutMethods < Neo::Koan end def test_method_without_explicit_return - assert_equal __, method_without_explicit_return + assert_equal :return_value, method_without_explicit_return end # ------------------------------------------------------------------ @@ -98,11 +98,11 @@ class AboutMethods < Neo::Koan end def test_calling_methods_in_same_class - assert_equal __, my_method_in_the_same_class(3,4) + assert_equal 12, my_method_in_the_same_class(3,4) end def test_calling_methods_in_same_class_with_explicit_receiver - assert_equal __, self.my_method_in_the_same_class(3,4) + assert_equal 12, self.my_method_in_the_same_class(3,4) end # ------------------------------------------------------------------ @@ -113,7 +113,7 @@ class AboutMethods < Neo::Koan private :my_private_method def test_calling_private_methods_without_receiver - assert_equal __, my_private_method + assert_equal "a secret", my_private_method end if before_ruby_version("2.7") # https://github.com/edgecase/ruby_koans/issues/12 @@ -141,12 +141,12 @@ class AboutMethods < Neo::Koan def test_calling_methods_in_other_objects_require_explicit_receiver rover = Dog.new - assert_equal __, rover.name + assert_equal "Fido", rover.name end def test_calling_private_methods_in_other_objects rover = Dog.new - assert_raise(___) do + assert_raise(NoMethodError) do rover.tail end end diff --git a/koans/about_regular_expressions.rb b/koans/about_regular_expressions.rb index b1b47a2..b42efd5 100644 --- a/koans/about_regular_expressions.rb +++ b/koans/about_regular_expressions.rb @@ -3,32 +3,32 @@ require File.expand_path(File.dirname(__FILE__) + '/neo') class AboutRegularExpressions < Neo::Koan def test_a_pattern_is_a_regular_expression - assert_equal __, /pattern/.class + assert_equal Regexp, /pattern/.class end def test_a_regexp_can_search_a_string_for_matching_content - assert_equal __, "some matching content"[/match/] + assert_equal 'match', "some matching content"[/match/] end def test_a_failed_match_returns_nil - assert_equal __, "some matching content"[/missing/] + assert_equal nil, "some matching content"[/missing/] end # ------------------------------------------------------------------ def test_question_mark_means_optional - assert_equal __, "abbcccddddeeeee"[/ab?/] - assert_equal __, "abbcccddddeeeee"[/az?/] + assert_equal 'ab', "abbcccddddeeeee"[/ab?/] + assert_equal 'a', "abbcccddddeeeee"[/az?/] end def test_plus_means_one_or_more - assert_equal __, "abbcccddddeeeee"[/bc+/] + assert_equal 'bccc', "abbcccddddeeeee"[/bc+/] end def test_asterisk_means_zero_or_more - assert_equal __, "abbcccddddeeeee"[/ab*/] - assert_equal __, "abbcccddddeeeee"[/az*/] - assert_equal __, "abbcccddddeeeee"[/z*/] + assert_equal 'abb', "abbcccddddeeeee"[/ab*/] + assert_equal 'a', "abbcccddddeeeee"[/az*/] + assert_equal '', "abbcccddddeeeee"[/z*/] # THINK ABOUT IT: #