mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
39f275edf7
GitHub: fix #18 It must be 0. Reported by Mirko Budszuhn. Thanks!!! https://github.com/ruby/rexml/commit/b48f3afa3b
38 lines
820 B
Ruby
38 lines
820 B
Ruby
# frozen_string_literal: false
|
|
|
|
require "test/unit"
|
|
require "rexml/document"
|
|
require "rexml/functions"
|
|
|
|
module REXMLTests
|
|
class TestFunctionsNumber < Test::Unit::TestCase
|
|
def setup
|
|
REXML::Functions.context = nil
|
|
end
|
|
|
|
def test_true
|
|
assert_equal(1, REXML::Functions.number(true))
|
|
end
|
|
|
|
def test_false
|
|
assert_equal(0, REXML::Functions.number(false))
|
|
end
|
|
|
|
def test_numeric
|
|
assert_equal(29, REXML::Functions.number(29))
|
|
end
|
|
|
|
def test_string_integer
|
|
assert_equal(100, REXML::Functions.number("100"))
|
|
end
|
|
|
|
def test_string_float
|
|
assert_equal(-9.13, REXML::Functions.number("-9.13"))
|
|
end
|
|
|
|
def test_node_set
|
|
root = REXML::Document.new("<root>100</root>").root
|
|
assert_equal(100, REXML::Functions.number([root]))
|
|
end
|
|
end
|
|
end
|