Skip to content

Commit

Permalink
dahlia: finished strings
Browse files Browse the repository at this point in the history
  • Loading branch information
dlbock committed Jul 9, 2011
1 parent 8ae7f15 commit 6b705d1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .path_progress
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0,1,2,3,4,5,6,6,6,6,7,7,7,7,8,8,9,9,9,11,12,13,14,14,14,14,16,17,18,18,19,19,19,19,20,20,20,20,21,21,22,22,23,23,24,12,24,25,26,26,28,28,29,30,32,32,34,33,35,36,36,36,36,37,38,39,39,40,42,43,43,44,45,45,45,46,47,48,49,51,52,53,54,55,56,56,57
0,1,2,3,4,5,6,6,6,6,7,7,7,7,8,8,9,9,9,11,12,13,14,14,14,14,16,17,18,18,19,19,19,19,20,20,20,20,21,21,22,22,23,23,24,12,24,25,26,26,28,28,29,30,32,32,34,33,35,36,36,36,36,37,38,39,39,40,42,43,43,44,45,45,45,46,47,48,49,51,52,53,54,55,56,56,57,57,57,57,58,59,59,60,60,60,61,61,61,62,62,63,64,65,66,67
28 changes: 14 additions & 14 deletions about_strings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,39 +119,39 @@ def test_single_quotes_sometimes_interpret_escape_characters
def test_double_quoted_strings_interpolate_variables
value = 123
string = "The value is #{value}"
assert_equal __, string
assert_equal "The value is 123", string
end

def test_single_quoted_strings_do_not_interpolate
value = 123
string = 'The value is #{value}'
assert_equal __, string
assert_equal 'The value is #{value}', string
end

def test_any_ruby_expression_may_be_interpolated
string = "The square root of 5 is #{Math.sqrt(5)}"
assert_equal __, string
assert_equal "The square root of 5 is #{Math.sqrt(5)}", string
end

def test_you_can_get_a_substring_from_a_string
string = "Bacon, lettuce and tomato"
assert_equal __, string[7,3]
assert_equal __, string[7..9]
assert_equal "let", string[7,3]
assert_equal "let", string[7..9]
end

def test_you_can_get_a_single_character_from_a_string
string = "Bacon, lettuce and tomato"
assert_equal __, string[1]
assert_equal 97, string[1]

# Surprised?
end

in_ruby_version("1.8") do
def test_in_ruby_1_8_single_characters_are_represented_by_integers
assert_equal __, ?a
assert_equal __, ?a == 97
assert_equal 97, ?a
assert_equal true, ?a == 97

assert_equal __, ?b == (?a + 1)
assert_equal true, ?b == (?a + 1)
end
end

Expand All @@ -165,13 +165,13 @@ def test_in_ruby_1_9_single_characters_are_represented_by_strings
def test_strings_can_be_split
string = "Sausage Egg Cheese"
words = string.split
assert_equal [__, __, __], words
assert_equal ['Sausage', 'Egg', 'Cheese'], words
end

def test_strings_can_be_split_with_different_patterns
string = "the:rain:in:spain"
words = string.split(/:/)
assert_equal [__, __, __, __], words
assert_equal ['the', 'rain', 'in', 'spain'], words

# NOTE: Patterns are formed from Regular Expressions. Ruby has a
# very powerful Regular Expression library. We will become
Expand All @@ -180,14 +180,14 @@ def test_strings_can_be_split_with_different_patterns

def test_strings_can_be_joined
words = ["Now", "is", "the", "time"]
assert_equal __, words.join(" ")
assert_equal "Now is the time", words.join(" ")
end

def test_strings_are_not_unique_objects
a = "a string"
b = "a string"

assert_equal __, a == b
assert_equal __, a.object_id == b.object_id
assert_equal true, a == b
assert_equal false, a.object_id == b.object_id
end
end

0 comments on commit 6b705d1

Please sign in to comment.