Project

General

Profile

Feature #5219 ยป pack.c.warn_on_unknown_directive.patch

drbrain (Eric Hodel), 03/27/2012 09:09 AM

View differences:

pack.c (working copy)
break;
default:
rb_warning("unknown pack directive '%c' in '%s'",
type, RSTRING_PTR(fmt));
break;
}
}
......
break;
default:
rb_warning("unknown unpack directive '%c' in '%s'",
type, RSTRING_PTR(fmt));
break;
}
}
test/ruby/test_pack.rb (working copy)
assert_nil("".unpack("i") {|x| result = x}, bug4059)
assert_equal(:ok, result)
end
def test_pack_garbage
assert_silent do
assert_equal "\000", [0].pack("*U")
end
verbose = $VERBOSE
$VERBOSE = true
_, err = capture_io do
assert_equal "\000", [0].pack("*U")
end
assert_match %r%unknown pack directive '\*' in '\*U'$%, err
ensure
$VERBOSE = verbose
end
def test_unpack_garbage
assert_silent do
assert_equal [0], "\000".unpack("*U")
end
verbose = $VERBOSE
$VERBOSE = true
_, err = capture_io do
assert_equal [0], "\000".unpack("*U")
end
assert_match %r%unknown unpack directive '\*' in '\*U'$%, err
ensure
$VERBOSE = verbose
end
end
    (1-1/1)