From db594e16fd87f886f9ea10e7ffd915ebd13b39db Mon Sep 17 00:00:00 2001 From: Michael de Silva Date: Thu, 8 Sep 2011 16:23:01 +0300 Subject: [PATCH 1/2] tweak for a more enlightened Regexp koan --- koans/about_regular_expressions.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/koans/about_regular_expressions.rb b/koans/about_regular_expressions.rb index 8344911..790bea3 100644 --- a/koans/about_regular_expressions.rb +++ b/koans/about_regular_expressions.rb @@ -84,6 +84,8 @@ class AboutRegularExpressions < EdgeCase::Koan def test_shortcut_character_classes_are_negated_with_capitals assert_equal __, "the number is 42"[/\D+/] assert_equal __, "space: \t\n"[/\S+/] + # ... a programmer would most likely do + assert_equal __, "variable_1 = 42"[/[^a-zA-Z0-9_]+/] assert_equal __, "variable_1 = 42"[/\W+/] end From c160ee8b034582d1245dd4dd0cff89d7cb87fd56 Mon Sep 17 00:00:00 2001 From: Michael de Silva Date: Fri, 9 Sep 2011 00:16:21 +0300 Subject: [PATCH 2/2] few more enlightening tweaks --- koans/about_control_statements.rb | 10 +++++++++- koans/about_methods.rb | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/koans/about_control_statements.rb b/koans/about_control_statements.rb index f243ac8..71a7af0 100644 --- a/koans/about_control_statements.rb +++ b/koans/about_control_statements.rb @@ -59,12 +59,20 @@ class AboutControlStatements < EdgeCase::Koan def test_unless_statement result = :default_value - unless false + unless false # same as saying 'if !false', which evaluates as 'if true' result = :false_value end assert_equal __, result end + def test_unless_statement_evaluate_true + result = :default_value + unless true # same as saying 'if !true', which evaluates as 'if false' + result = :true_value + end + assert_equal __, result + end + def test_unless_statement_modifier result = :default_value result = :false_value unless false diff --git a/koans/about_methods.rb b/koans/about_methods.rb index a4df4b8..5fd7725 100644 --- a/koans/about_methods.rb +++ b/koans/about_methods.rb @@ -62,6 +62,7 @@ class AboutMethods < EdgeCase::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)