686
691
assert_equal([1,2,[3],4,5], r, "[ruby-core:19485]")
695
assert_equal([], proc {}.parameters)
696
assert_equal([], proc {||}.parameters)
697
assert_equal([[:opt, :a]], proc {|a|}.parameters)
698
assert_equal([[:opt, :a], [:opt, :b]], proc {|a, b|}.parameters)
699
assert_equal([[:opt, :a], [:block, :b]], proc {|a=:a, &b|}.parameters)
700
assert_equal([[:opt, :a], [:opt, :b]], proc {|a, b=:b|}.parameters)
701
assert_equal([[:rest, :a]], proc {|*a|}.parameters)
702
assert_equal([[:opt, :a], [:rest, :b], [:block, :c]], proc {|a, *b, &c|}.parameters)
703
assert_equal([[:opt, :a], [:rest, :b], [:opt, :c]], proc {|a, *b, c|}.parameters)
704
assert_equal([[:opt, :a], [:rest, :b], [:opt, :c], [:block, :d]], proc {|a, *b, c, &d|}.parameters)
705
assert_equal([[:opt, :a], [:opt, :b], [:rest, :c], [:opt, :d], [:block, :e]], proc {|a, b=:b, *c, d, &e|}.parameters)
706
assert_equal([[:opt, nil], [:block, :b]], proc {|(a), &b|}.parameters)
707
assert_equal([[:opt, :a], [:opt, :b], [:opt, :c], [:opt, :d], [:rest, :e], [:opt, :f], [:opt, :g], [:block, :h]], proc {|a,b,c=:c,d=:d,*e,f,g,&h|}.parameters)
709
assert_equal([[:req]], method(:putc).parameters)
710
assert_equal([[:rest]], method(:p).parameters)
716
def pmo1(a = :a, &b) end
717
def pmo2(a, b = :b) end
719
def pmo4(a, *b, &c) end
720
def pmo5(a, *b, c) end
721
def pmo6(a, *b, c, &d) end
722
def pmo7(a, b = :b, *c, d, &e) end
723
def pma1((a), &b) end
726
def test_bound_parameters
727
assert_equal([], method(:pm0).to_proc.parameters)
728
assert_equal([[:req, :a]], method(:pm1).to_proc.parameters)
729
assert_equal([[:req, :a], [:req, :b]], method(:pm2).to_proc.parameters)
730
assert_equal([[:opt, :a], [:block, :b]], method(:pmo1).to_proc.parameters)
731
assert_equal([[:req, :a], [:opt, :b]], method(:pmo2).to_proc.parameters)
732
assert_equal([[:rest, :a]], method(:pmo3).to_proc.parameters)
733
assert_equal([[:req, :a], [:rest, :b], [:block, :c]], method(:pmo4).to_proc.parameters)
734
assert_equal([[:req, :a], [:rest, :b], [:req, :c]], method(:pmo5).to_proc.parameters)
735
assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], method(:pmo6).to_proc.parameters)
736
assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], method(:pmo7).to_proc.parameters)
737
assert_equal([[:req], [:block, :b]], method(:pma1).to_proc.parameters)
739
assert_equal([], "".method(:upcase).to_proc.parameters)
740
assert_equal([[:rest]], "".method(:gsub).to_proc.parameters)
741
assert_equal([[:rest]], proc {}.curry.parameters)
690
745
assert_match(/^#<Proc:0x\h+@#{ Regexp.quote(__FILE__) }:\d+>$/, proc {}.to_s)
691
746
assert_match(/^#<Proc:0x\h+@#{ Regexp.quote(__FILE__) }:\d+ \(lambda\)>$/, lambda {}.to_s)
695
750
assert(x.to_s.tainted?)
698
def source_location_test
753
@@line_of_source_location_test = __LINE__ + 1
754
def source_location_test a=1,
702
758
def test_source_location
703
759
file, lineno = method(:source_location_test).source_location
704
760
assert_match(/^#{ Regexp.quote(__FILE__) }$/, file)
705
assert_equal(source_location_test - 1, lineno)
761
assert_equal(@@line_of_source_location_test, lineno, 'Bug #2427')
764
@@line_of_attr_reader_source_location_test = __LINE__ + 3
765
@@line_of_attr_writer_source_location_test = __LINE__ + 3
766
@@line_of_attr_accessor_source_location_test = __LINE__ + 3
767
attr_reader :attr_reader_source_location_test
768
attr_writer :attr_writer_source_location_test
769
attr_accessor :attr_accessor_source_location_test
771
def test_attr_source_location
772
file, lineno = method(:attr_reader_source_location_test).source_location
773
assert_match(/^#{ Regexp.quote(__FILE__) }$/, file)
774
assert_equal(@@line_of_attr_reader_source_location_test, lineno)
776
file, lineno = method(:attr_writer_source_location_test=).source_location
777
assert_match(/^#{ Regexp.quote(__FILE__) }$/, file)
778
assert_equal(@@line_of_attr_writer_source_location_test, lineno)
780
file, lineno = method(:attr_accessor_source_location_test).source_location
781
assert_match(/^#{ Regexp.quote(__FILE__) }$/, file)
782
assert_equal(@@line_of_attr_accessor_source_location_test, lineno)
784
file, lineno = method(:attr_accessor_source_location_test=).source_location
785
assert_match(/^#{ Regexp.quote(__FILE__) }$/, file)
786
assert_equal(@@line_of_attr_accessor_source_location_test, lineno)
708
789
def test_splat_without_respond_to