valid.rb
| 1 |
#
|
|---|---|
| 2 |
# Problem: with Ruby 1.8.8, Builder replaces all text with asterisks. Demo:
|
| 3 |
#
|
| 4 |
require 'rubygems'
|
| 5 |
require 'builder'
|
| 6 |
x = Builder::XmlMarkup.new |
| 7 |
x.a 'a'
|
| 8 |
puts x.target! |
| 9 |
|
| 10 |
#
|
| 11 |
# Root cause is a validity check in Fixnum::xchr, defined in builder/xchar.rb.
|
| 12 |
# This code has been extracted and simplified into a small test case.
|
| 13 |
#
|
| 14 |
n = 97
|
| 15 |
VALID = [ 97 ] |
| 16 |
|
| 17 |
# Works in 1.8.7, 1.8.8, 1.9.1, and 1.9.2
|
| 18 |
case n when *[ 97 ] |
| 19 |
puts 'valid'
|
| 20 |
else
|
| 21 |
puts 'INVALID'
|
| 22 |
end
|
| 23 |
|
| 24 |
# Works in 1.8.7, 1.9.1, and 1.9.2; FAILS in 1.8.8
|
| 25 |
case n when *VALID |
| 26 |
puts 'valid'
|
| 27 |
else
|
| 28 |
puts 'INVALID'
|
| 29 |
end
|