diff options
Diffstat (limited to 'test/test.rb')
-rw-r--r-- | test/test.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/test.rb b/test/test.rb index 2a8eee2..5390de8 100644 --- a/test/test.rb +++ b/test/test.rb @@ -1,11 +1,30 @@ direc = File.dirname(__FILE__) +require 'rubygems' require 'bacon' require "#{direc}/../lib/method_source" require "#{direc}/test_helper" describe MethodSource do + describe "source_location (testing 1.8 implementation)" do + it 'should return correct source_location for a method' do + method(:hello).source_location.first.should =~ /test_helper/ + end + + it 'should not raise for immediate instance methods' do + [Symbol, Fixnum, TrueClass, FalseClass, NilClass].each do |immediate_class| + lambda { immediate_class.instance_method(:to_s).source_location }.should.not.raise + end + end + + it 'should not raise for immediate methods' do + [:a, 1, true, false, nil].each do |immediate| + lambda { immediate.method(:to_s).source_location }.should.not.raise + end + end + end + before do @hello_module_source = " def hello; :hello_module; end\n" @hello_singleton_source = "def $o.hello; :hello_singleton; end\n" |