From 63e82ae675a034a688a903357b2e23f23bf65433 Mon Sep 17 00:00:00 2001 From: Danish Khan Date: Mon, 14 Mar 2011 16:38:09 -0700 Subject: [PATCH] working.. --- koans/about_regular_expressions.rb | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/koans/about_regular_expressions.rb b/koans/about_regular_expressions.rb index 83449112c..2720f5525 100644 --- a/koans/about_regular_expressions.rb +++ b/koans/about_regular_expressions.rb @@ -3,32 +3,32 @@ class AboutRegularExpressions < EdgeCase::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: # @@ -44,27 +44,27 @@ def test_asterisk_means_zero_or_more # ------------------------------------------------------------------ def test_the_left_most_match_wins - assert_equal __, "abbccc az"[/az*/] + assert_equal "a", "abbccc az"[/az*/] end # ------------------------------------------------------------------ def test_character_classes_give_options_for_a_character animals = ["cat", "bat", "rat", "zat"] - assert_equal __, animals.select { |a| a[/[cbr]at/] } + assert_equal ["cat", "bat", "rat"], animals.select { |a| a[/[cbr]at/] } end def test_slash_d_is_a_shortcut_for_a_digit_character_class - assert_equal __, "the number is 42"[/[0123456789]+/] - assert_equal __, "the number is 42"[/\d+/] + assert_equal "42", "the number is 42"[/[0123456789]+/] + assert_equal "42", "the number is 42"[/\d+/] end def test_character_classes_can_include_ranges - assert_equal __, "the number is 42"[/[0-9]+/] + assert_equal "42", "the number is 42"[/[0-9]+/] end def test_slash_s_is_a_shortcut_for_a_whitespace_character_class - assert_equal __, "space: \t\n"[/\s+/] + assert_equal " \t\n", "space: \t\n"[/\s+/] end def test_slash_w_is_a_shortcut_for_a_word_character_class