Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7fa8d9fdbfc0
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: dfe417e7655d
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Jan 4, 2016

  1. Copy the full SHA
    85f3a80 View commit details
  2. Copy the full SHA
    dfe417e View commit details
8 changes: 8 additions & 0 deletions spec/ruby/core/string/unpack/u_spec.rb
Original file line number Diff line number Diff line change
@@ -8,6 +8,14 @@
it_behaves_like :string_unpack_basic, 'U'
it_behaves_like :string_unpack_no_platform, 'U'
it_behaves_like :string_unpack_unicode, 'U'

it "raises ArgumentError on a malformed byte sequence" do
lambda { "\xE3".unpack('U') }.should raise_error(ArgumentError)
end

it "raises ArgumentError on a malformed byte sequence and doesn't continue when used with the * modifier" do
lambda { "\xE3".unpack('U*') }.should raise_error(ArgumentError)
end
end

describe "String#unpack with format 'u'" do
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
import org.jruby.truffle.format.nodes.PackNode;
import org.jruby.truffle.format.nodes.SourceNode;
import org.jruby.truffle.format.runtime.MissingValue;
import org.jruby.truffle.format.runtime.exceptions.FormatException;
import org.jruby.truffle.runtime.RubyContext;

import java.nio.ByteBuffer;
@@ -81,7 +82,7 @@ public Object read(VirtualFrame frame, byte[] source) {
}

if (index + length > sourceLength) {
return MissingValue.INSTANCE;
throw new FormatException(String.format("malformed UTF-8 character (expected %d bytes, given %d bytes)", length, sourceLength - index));
}

for (int n = 1; n < length; n++) {
Original file line number Diff line number Diff line change
@@ -2205,6 +2205,8 @@ public DynamicObject unpackUncached(
private RuntimeException handleException(PackException exception) {
try {
throw exception;
} catch (FormatException e) {
return new RaiseException(getContext().getCoreLibrary().argumentError(e.getMessage(), this));
} catch (TooFewArgumentsException e) {
return new RaiseException(getContext().getCoreLibrary().argumentError("too few arguments", this));
} catch (NoImplicitConversionException e) {