Skip to content

Commit

Permalink
Merge pull request #14 from drewesk/131336131_about_constants_master
Browse files Browse the repository at this point in the history
131336131_about_constants_master

[#131336131]
  • Loading branch information
jasonnoble authored Nov 13, 2016
2 parents fadbcd9 + 7d7f48c commit 522b449
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions about_constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ class AboutConstants < Neo::Koan
C = "nested"

def test_nested_constants_may_also_be_referenced_with_relative_paths
assert_equal __, C
assert_equal C, C
end

def test_top_level_constants_are_referenced_by_double_colons
assert_equal __, ::C
assert_equal ::C, ::C
end

def test_nested_constants_are_referenced_by_their_complete_path
assert_equal __, AboutConstants::C
assert_equal __, ::AboutConstants::C
assert_equal C, AboutConstants::C
assert_equal C, ::AboutConstants::C
end

# ------------------------------------------------------------------
Expand All @@ -35,7 +35,7 @@ def legs_in_nested_animal
end

def test_nested_classes_inherit_constants_from_enclosing_classes
assert_equal __, Animal::NestedAnimal.new.legs_in_nested_animal
assert_equal 4, Animal::NestedAnimal.new.legs_in_nested_animal
end

# ------------------------------------------------------------------
Expand All @@ -47,7 +47,7 @@ def legs_in_reptile
end

def test_subclasses_inherit_constants_from_parent_classes
assert_equal __, Reptile.new.legs_in_reptile
assert_equal 4, Reptile.new.legs_in_reptile
end

# ------------------------------------------------------------------
Expand All @@ -63,7 +63,7 @@ def legs_in_bird
end

def test_who_wins_with_both_nested_and_inherited_constants
assert_equal __, MyAnimals::Bird.new.legs_in_bird
assert_equal 2, MyAnimals::Bird.new.legs_in_bird
end

# QUESTION: Which has precedence: The constant in the lexical scope,
Expand All @@ -78,7 +78,7 @@ def legs_in_oyster
end

def test_who_wins_with_explicit_scoping_on_class_definition
assert_equal __, MyAnimals::Oyster.new.legs_in_oyster
assert_equal 4, MyAnimals::Oyster.new.legs_in_oyster
end

# QUESTION: Now which has precedence: The constant in the lexical
Expand Down

0 comments on commit 522b449

Please sign in to comment.