Skip to content

Commit

Permalink
Added some tests to check for global functions (both direct and inclu…
Browse files Browse the repository at this point in the history
…ded).

git-svn-id: svn+ssh://rubyforge.org/var/svn/builder/trunk@101 b15df707-ad1a-0410-81b8-e991873a3486
  • Loading branch information
jimweirich committed Mar 1, 2007
1 parent 6877e5e commit cd457b6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES
Expand Up @@ -10,6 +10,7 @@
targetted and untargetted private methods.
* Removed legacy capture of @self in XmlBase (@self was used back when
we used instance eval).
* Added additional tests for global functions (both direct and included).

== Version 2.1.0

Expand Down
25 changes: 25 additions & 0 deletions test/testblankslate.rb
Expand Up @@ -54,6 +54,17 @@ def another_late_addition
end
end

# Introduce some late methods by inclusion.
module GlobalModule
def global_inclusion
42
end
end
include GlobalModule

def direct_global
43
end

######################################################################
# Test case for blank slate.
Expand Down Expand Up @@ -111,6 +122,11 @@ def test_methods_added_late_to_object_remain_undefined
assert_equal 4321, nil.another_late_addition
assert_raise(NoMethodError) { @bs.another_late_addition }
end

def test_methods_added_late_to_global_remain_undefined
assert_equal 42, global_inclusion
assert_raise(NoMethodError) { @bs.global_inclusion }
end

def test_preload_method_added
assert Kernel.k_added_names.include?(:late_addition)
Expand Down Expand Up @@ -153,5 +169,14 @@ def test_revealing_unknown_hidden_method_is_an_error
end
end
end

def test_global_includes_still_work
assert_nothing_raised do
assert_equal 42, global_inclusion
assert_equal 42, Object.new.global_inclusion
assert_equal 42, "magic number".global_inclusion
assert_equal 43, direct_global
end
end
end

0 comments on commit cd457b6

Please sign in to comment.