1 require File.expand_path(File.dirname(__FILE__) + '/edgecase')
3 class AboutObjects < EdgeCase::Koan
4 def test_everything_is_an_object
5 assert_equal __, 1.is_a?(Object)
6 assert_equal __, 1.5.is_a?(Object)
7 assert_equal __, "string".is_a?(Object)
8 assert_equal __, nil.is_a?(Object)
9 assert_equal __, Object.is_a?(Object)
12 def test_objects_can_be_converted_to_strings
13 assert_equal __, 123.to_s
14 assert_equal __, nil.to_s
17 def test_objects_can_be_inspected
18 assert_equal __, 123.inspect
19 assert_equal __, nil.inspect
22 def test_every_object_has_an_id
24 assert_equal __, obj.object_id.class
27 def test_every_object_has_different_id
29 another_obj = Object.new
30 assert_equal __, obj.object_id != another_obj.object_id
33 def test_some_system_objects_always_have_the_same_id
34 assert_equal __, false.object_id
35 assert_equal __, true.object_id
36 assert_equal __, nil.object_id
39 def test_small_integers_have_fixed_ids
40 assert_equal __, 0.object_id
41 assert_equal __, 1.object_id
42 assert_equal __, 2.object_id
43 assert_equal __, 100.object_id
46 # What pattern do the object IDs for small integers follow?
49 def test_clone_creates_a_different_object
53 assert_equal __, obj != copy
54 assert_equal __, obj.object_id != copy.object_id