moving to a new repo

This commit is contained in:
Joe O'Brien
2009-01-26 11:56:38 -05:00
parent 55fd4afa0f
commit 4e78262965
37 changed files with 2693 additions and 0 deletions

46
about_nil.rb Normal file
View File

@@ -0,0 +1,46 @@
require 'edgecase'
class AboutNil < EdgeCase::Koan
def test_nil_is_an_object
assert nil.is_a?(Object), "Unlike NULL in other languages"
end
def test_you_dont_get_null_pointer_errors_when_calling_methods_on_nil
#
# What is the Exception that is thrown when you call a method that
# does not exist?
#
# Hint: launch irb and try the code in the block below.
#
# Don't be confused by the code below yet. It's using blocks
# which are explained later on in about_blocks.rb. For now,
# think about it like running nil.some_method_nil_doesnt_know_about
# in a sandbox and catching the error class into the exception
# variable.
#
exception = assert_raise(___) do
nil.some_method_nil_doesnt_know_about
end
#
# What is the error message itself? What substring or pattern could
# you test against in order to have a good idea what the string is?
#
assert_match /__/, exception.message
end
def test_nil_has_a_few_methods_defined_on_it
assert_equal __, nil.nil?
assert_equal __, nil.to_s
assert_equal __, nil.inspect
# THINK ABOUT IT:
#
# Is it better to use
# obj.nil?
# or
# obj == nil
# Why?
end
end