83ec07b46380ba0ffde45c1aae01d07764e8189f
[ruby_koans.git] / koans / array_test.rb
1 require 'test_helper'
2
3 class ArrayTest < EdgeCase::TestCase
4
5   def test_basic_arrays
6     food = [:peanut, :button, :and, :jelly]
7     assert_equal __, food[0]
8     assert_equal __, food.size
9   end
10
11   def test_array_access
12     food = [:peanut, :button, :and, :jelly]
13     assert_equal __, food.first
14     assert_equal __, food.last
15     assert_equal __, food[0]
16     assert_equal __, food[2]
17     assert_equal __, food[(food.size() - 1)]
18   end
19
20   def test_arrays_with_other_objects
21     food = [:peanut, :button, :and, :jelly, 1, nil]
22     assert_equal __, food.size
23     assert_equal __, food.last
24     assert_equal __, food[5]
25   end
26
27   def test_adding_to_an_array_with_shovel_shovel
28     food = [:peanut, :button, :and, :jelly]
29     food << 'sandwich'
30     assert_equal __, food.size
31     assert_equal __, food.first
32   end
33
34   def test_adding_to_an_array_with_push
35     food = [:peanut, :button, :and, :jelly]
36     food.push('sandwich')
37     assert_equal __, food.last
38   end
39
40   def test_adding_to_an_array_with_unshift
41     food = [:peanut, :button, :and, :jelly]
42     food.unshift('a')
43     assert_equal __, food.first
44   end
45
46 end
47