Project

General

Profile

Feature #4086 ยป add_contain_method.diff

rogerdpack (Roger Pack), 06/02/2011 03:55 AM

View differences:

enum.c (working copy)
/*
* call-seq:
* enum.include?(obj) -> true or false
* enum.contain?(obj) -> true or false
* enum.member?(obj) -> true or false
*
* Returns <code>true</code> if any member of <i>enum</i> equals
......
rb_define_method(rb_mEnumerable, "minmax_by", enum_minmax_by, 0);
rb_define_method(rb_mEnumerable, "member?", enum_member, 1);
rb_define_method(rb_mEnumerable, "include?", enum_member, 1);
rb_define_method(rb_mEnumerable, "contain?", enum_member, 1);
rb_define_method(rb_mEnumerable, "each_with_index", enum_each_with_index, -1);
rb_define_method(rb_mEnumerable, "reverse_each", enum_reverse_each, -1);
rb_define_method(rb_mEnumerable, "each_entry", enum_each_entry, -1);
string.c (working copy)
/*
* call-seq:
* str.include? other_str -> true or false
* str.contain? other_str -> true or false
*
* Returns <code>true</code> if <i>str</i> contains the given string or
* character.
......
rb_define_method(rb_cString, "ord", rb_str_ord, 0);
rb_define_method(rb_cString, "include?", rb_str_include, 1);
rb_define_method(rb_cString, "contain?", rb_str_include, 1);
rb_define_method(rb_cString, "start_with?", rb_str_start_with, -1);
rb_define_method(rb_cString, "end_with?", rb_str_end_with, -1);
test/ruby/test_array.rb (working copy)
assert(!a.include?('ca'))
assert(!a.include?([1,2]))
end
def test_contain?
a = @cls[ 'cat' ]
assert(a.contain?('cat'))
end
def test_index
a = @cls[ 'cat', 99, /a/, 99, @cls[ 1, 2, 3] ]
test/ruby/test_enum.rb (working copy)
assert_equal(24, @obj.inject(2) {|z, x| z * x })
assert_equal(24, @obj.inject(2, :*) {|z, x| z * x })
end
def test_contain
assert(@obj.include?(3))
assert(@obj.contain?(3))
end
def test_partition
assert_equal([[1, 3, 1], [2, 2]], @obj.partition {|x| x % 2 == 1 })
test/ruby/test_string.rb (working copy)
assert(!S("foobar").include?(S("baz")))
assert(!S("foobar").include?(?z))
end
def test_contain?
assert( S("foobar").contain?(?f))
assert( S("foobar").contain?(S("foo")))
assert(!S("foobar").contain?(S("baz")))
assert(!S("foobar").contain?(?z))
end
def test_index
assert_equal(0, S("hello").index(?h))
    (1-1/1)