Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/rexml/functions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,8 @@ def substring( string, start, length=nil )
ruby_string[ruby_start,ruby_length]
end

# UNTESTED
def string_length( string )
string(string).length
def string_length( object=@context[:node] )
string(object).length
end

def normalize_space( object=@context[:node] )
Expand Down
6 changes: 6 additions & 0 deletions test/functions/test_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ def test_string_length
assert_equal 3, set.size, "nodes with names length > 3"
end

def test_string_length_without_argument
doc = Document.new("<root><item>123</item><item>1234</item><item>12345</item></root>")
set = doc.elements.to_a("//item[string-length()=4]")
assert_equal ["1234"], set.collect(&:text)
end

# Test provided by Mike Stok
def test_contains
source = <<-EOF
Expand Down