Project

General

Profile

Bug #2555 ยป valid.rb

rubys (Sam Ruby), 01/05/2010 03:01 AM

 
#
# Problem: with Ruby 1.8.8, Builder replaces all text with asterisks. Demo:
#
require 'rubygems'
require 'builder'
x = Builder::XmlMarkup.new
x.a 'a'
puts x.target!

#
# Root cause is a validity check in Fixnum::xchr, defined in builder/xchar.rb.
# This code has been extracted and simplified into a small test case.
#
n = 97
VALID = [ 97 ]

# Works in 1.8.7, 1.8.8, 1.9.1, and 1.9.2
case n when *[ 97 ]
puts 'valid'
else
puts 'INVALID'
end

# Works in 1.8.7, 1.9.1, and 1.9.2; FAILS in 1.8.8
case n when *VALID
puts 'valid'
else
puts 'INVALID'
end
    (1-1/1)