Permalink
Browse files

implemented koans

#25 test_non_parallel_assignment
#26 test_parallel_assignments
#27 test_parallel_assignments_with_extra_values
#28 test_parallel_assignments_with_splat_operator
#29 test_parallel_assignments_with_too_few_variables
#30 test_parallel_assignments_with_subarrays
#31 test_parallel_assignment_with_one_variable
#32 test_swapping_with_parallel_assignment
  • Loading branch information...
1 parent 2a54f40 commit 040e23d604732a1580aaa66beb0190ae598d31ca @mrosecrans committed Jun 17, 2011
Showing with 14 additions and 14 deletions.
  1. +14 −14 koans/about_array_assignment.rb
@@ -3,49 +3,49 @@
class AboutArrayAssignment < EdgeCase::Koan
def test_non_parallel_assignment
names = ["John", "Smith"]
- assert_equal __, names
+ assert_equal ["John", "Smith"], names
end
def test_parallel_assignments
first_name, last_name = ["John", "Smith"]
- assert_equal __, first_name
- assert_equal __, last_name
+ assert_equal "John", first_name
+ assert_equal "Smith", last_name
end
def test_parallel_assignments_with_extra_values
first_name, last_name = ["John", "Smith", "III"]
- assert_equal __, first_name
- assert_equal __, last_name
+ assert_equal "John", first_name
+ assert_equal "Smith", last_name
end
def test_parallel_assignments_with_splat_operator
first_name, *last_name = ["John", "Smith", "III"]
- assert_equal __, first_name
- assert_equal __, last_name
+ assert_equal "John", first_name
+ assert_equal ["Smith", "III"], last_name
end
def test_parallel_assignments_with_too_few_variables
first_name, last_name = ["Cher"]
- assert_equal __, first_name
- assert_equal __, last_name
+ assert_equal "Cher", first_name
+ assert_equal nil, last_name
end
def test_parallel_assignments_with_subarrays
first_name, last_name = [["Willie", "Rae"], "Johnson"]
- assert_equal __, first_name
- assert_equal __, last_name
+ assert_equal ["Willie","Rae"], first_name
+ assert_equal "Johnson", last_name
end
def test_parallel_assignment_with_one_variable
first_name, = ["John", "Smith"]
- assert_equal __, first_name
+ assert_equal "John", first_name
end
def test_swapping_with_parallel_assignment
first_name = "Roy"
last_name = "Rob"
first_name, last_name = last_name, first_name
- assert_equal __, first_name
- assert_equal __, last_name
+ assert_equal "Rob", first_name
+ assert_equal "Roy", last_name
end
end

0 comments on commit 040e23d

Please sign in to comment.