Skip to content

Commit

Permalink
Showing 22 changed files with 12 additions and 192 deletions.
21 changes: 0 additions & 21 deletions spec/truffle/tags/core/string/unpack/a_tags.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,2 @@
fails:String#unpack with format 'A' calls #to_str to coerce the directives string
fails:String#unpack with format 'A' returns an empty string if the input is empty
fails:String#unpack with format 'A' returns empty strings for repeated formats if the input is empty
fails:String#unpack with format 'A' returns an empty string and does not decode any bytes when the count modifier is zero
fails:String#unpack with format 'A' implicitly has a count of one when no count is specified
fails:String#unpack with format 'A' decodes the number of bytes specified by the count modifier
fails:String#unpack with format 'A' decodes the number of bytes specified by the count modifier including whitespace bytes
fails:String#unpack with format 'A' decodes past whitespace bytes when passed the '*' modifier
fails:String#unpack with format 'A' decodes the number of bytes specified by the count modifier including NULL bytes
fails:String#unpack with format 'A' decodes past NULL bytes when passed the '*' modifier
fails:String#unpack with format 'A' removes trailing space and NULL bytes from the decoded string
fails:String#unpack with format 'A' does not remove whitespace other than space
fails:String#unpack with format 'a' calls #to_str to coerce the directives string
fails:String#unpack with format 'a' returns an empty string if the input is empty
fails:String#unpack with format 'a' returns empty strings for repeated formats if the input is empty
fails:String#unpack with format 'a' returns an empty string and does not decode any bytes when the count modifier is zero
fails:String#unpack with format 'a' implicitly has a count of one when no count is specified
fails:String#unpack with format 'a' decodes the number of bytes specified by the count modifier
fails:String#unpack with format 'a' decodes the number of bytes specified by the count modifier including whitespace bytes
fails:String#unpack with format 'a' decodes past whitespace bytes when passed the '*' modifier
fails:String#unpack with format 'a' decodes the number of bytes specified by the count modifier including NULL bytes
fails:String#unpack with format 'a' decodes past NULL bytes when passed the '*' modifier
fails:String#unpack with format 'a' does not remove trailing whitespace or NULL bytes from the decoded string
1 change: 0 additions & 1 deletion spec/truffle/tags/core/string/unpack/at_tags.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
fails:String#unpack with format '@' calls #to_str to coerce the directives string
fails:String#unpack with format '@' positions the read index one beyond the last readable byte in the String
20 changes: 0 additions & 20 deletions spec/truffle/tags/core/string/unpack/b_tags.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,2 @@
fails:String#unpack with format 'B' calls #to_str to coerce the directives string
fails:String#unpack with format 'B' decodes one bit from each byte for each format character starting with the most significant bit
fails:String#unpack with format 'B' decodes only the number of bits in the string when passed a count
fails:String#unpack with format 'B' decodes multiple differing bit counts from a single string
fails:String#unpack with format 'B' decodes a directive with a '*' modifier after a directive with a count modifier
fails:String#unpack with format 'B' decodes a directive with a count modifier after a directive with a '*' modifier
fails:String#unpack with format 'B' decodes the number of bits specified by the count modifier
fails:String#unpack with format 'B' decodes all the bits when passed the '*' modifier
fails:String#unpack with format 'B' adds an empty string for each element requested beyond the end of the String
fails:String#unpack with format 'B' ignores NULL bytes between directives
fails:String#unpack with format 'B' ignores spaces between directives
fails:String#unpack with format 'b' calls #to_str to coerce the directives string
fails:String#unpack with format 'b' decodes one bit from each byte for each format character starting with the least significant bit
fails:String#unpack with format 'b' decodes only the number of bits in the string when passed a count
fails:String#unpack with format 'b' decodes multiple differing bit counts from a single string
fails:String#unpack with format 'b' decodes a directive with a '*' modifier after a directive with a count modifier
fails:String#unpack with format 'b' decodes a directive with a count modifier after a directive with a '*' modifier
fails:String#unpack with format 'b' decodes the number of bits specified by the count modifier
fails:String#unpack with format 'b' decodes all the bits when passed the '*' modifier
fails:String#unpack with format 'b' adds an empty string for each element requested beyond the end of the String
fails:String#unpack with format 'b' ignores NULL bytes between directives
fails:String#unpack with format 'b' ignores spaces between directives
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/string/unpack/c_tags.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
fails:String#unpack with format 'C' calls #to_str to coerce the directives string
fails:String#unpack with format 'C' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'c' calls #to_str to coerce the directives string
fails:String#unpack with format 'c' adds nil for each element requested beyond the end of the String
4 changes: 0 additions & 4 deletions spec/truffle/tags/core/string/unpack/d_tags.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
fails:String#unpack with format 'D' ignores whitespace in the format string
fails:String#unpack with format 'D' calls #to_str to coerce the directives string
fails:String#unpack with format 'D' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'd' ignores whitespace in the format string
fails:String#unpack with format 'd' calls #to_str to coerce the directives string
fails:String#unpack with format 'd' adds nil for each element requested beyond the end of the String
4 changes: 0 additions & 4 deletions spec/truffle/tags/core/string/unpack/e_tags.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
fails:String#unpack with format 'E' ignores whitespace in the format string
fails:String#unpack with format 'E' calls #to_str to coerce the directives string
fails:String#unpack with format 'E' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'e' ignores whitespace in the format string
fails:String#unpack with format 'e' calls #to_str to coerce the directives string
fails:String#unpack with format 'e' adds nil for each element requested beyond the end of the String
4 changes: 0 additions & 4 deletions spec/truffle/tags/core/string/unpack/f_tags.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
fails:String#unpack with format 'F' ignores whitespace in the format string
fails:String#unpack with format 'F' calls #to_str to coerce the directives string
fails:String#unpack with format 'F' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'f' ignores whitespace in the format string
fails:String#unpack with format 'f' calls #to_str to coerce the directives string
fails:String#unpack with format 'f' adds nil for each element requested beyond the end of the String
4 changes: 0 additions & 4 deletions spec/truffle/tags/core/string/unpack/g_tags.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
fails:String#unpack with format 'G' ignores whitespace in the format string
fails:String#unpack with format 'G' calls #to_str to coerce the directives string
fails:String#unpack with format 'G' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'g' ignores whitespace in the format string
fails:String#unpack with format 'g' calls #to_str to coerce the directives string
fails:String#unpack with format 'g' adds nil for each element requested beyond the end of the String
20 changes: 0 additions & 20 deletions spec/truffle/tags/core/string/unpack/h_tags.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,2 @@
fails:String#unpack with format 'H' calls #to_str to coerce the directives string
fails:String#unpack with format 'H' decodes one nibble from each byte for each format character starting with the most significant bit
fails:String#unpack with format 'H' decodes only the number of nibbles in the string when passed a count
fails:String#unpack with format 'H' decodes multiple differing nibble counts from a single string
fails:String#unpack with format 'H' decodes a directive with a '*' modifier after a directive with a count modifier
fails:String#unpack with format 'H' decodes a directive with a count modifier after a directive with a '*' modifier
fails:String#unpack with format 'H' decodes the number of nibbles specified by the count modifier
fails:String#unpack with format 'H' decodes all the nibbles when passed the '*' modifier
fails:String#unpack with format 'H' adds an empty string for each element requested beyond the end of the String
fails:String#unpack with format 'H' ignores NULL bytes between directives
fails:String#unpack with format 'H' ignores spaces between directives
fails:String#unpack with format 'h' calls #to_str to coerce the directives string
fails:String#unpack with format 'h' decodes one nibble from each byte for each format character starting with the least significant bit
fails:String#unpack with format 'h' decodes only the number of nibbles in the string when passed a count
fails:String#unpack with format 'h' decodes multiple differing nibble counts from a single string
fails:String#unpack with format 'h' decodes a directive with a '*' modifier after a directive with a count modifier
fails:String#unpack with format 'h' decodes a directive with a count modifier after a directive with a '*' modifier
fails:String#unpack with format 'h' decodes the number of nibbles specified by the count modifier
fails:String#unpack with format 'h' decodes all the nibbles when passed the '*' modifier
fails:String#unpack with format 'h' adds an empty string for each element requested beyond the end of the String
fails:String#unpack with format 'h' ignores NULL bytes between directives
fails:String#unpack with format 'h' ignores spaces between directives
20 changes: 0 additions & 20 deletions spec/truffle/tags/core/string/unpack/i_tags.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,2 @@
fails:String#unpack with format 'I' with modifier '<' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'I' with modifier '<' and '_' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'I' with modifier '<' and '!' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'I' with modifier '>' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'I' with modifier '>' and '_' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'I' with modifier '>' and '!' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'i' with modifier '<' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'i' with modifier '<' and '_' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'i' with modifier '<' and '!' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'i' with modifier '>' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'i' with modifier '>' and '_' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'i' with modifier '>' and '!' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'I' ignores whitespace in the format string
fails:String#unpack with format 'I' calls #to_str to coerce the directives string
fails:String#unpack with format 'I' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'I' with modifier '_' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'I' with modifier '!' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'i' ignores whitespace in the format string
fails:String#unpack with format 'i' calls #to_str to coerce the directives string
fails:String#unpack with format 'i' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'i' with modifier '_' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'i' with modifier '!' adds nil for each element requested beyond the end of the String
14 changes: 0 additions & 14 deletions spec/truffle/tags/core/string/unpack/l_tags.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
fails:String#unpack with format 'L' with modifier '<' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'L' with modifier '>' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'L' with modifier '<' and '_' decodes a long with most significant bit set as a positive number
fails:String#unpack with format 'L' with modifier '<' and '!' decodes a long with most significant bit set as a positive number
fails:String#unpack with format 'L' with modifier '>' and '_' decodes a long with most significant bit set as a positive number
fails:String#unpack with format 'L' with modifier '>' and '!' decodes a long with most significant bit set as a positive number
fails:String#unpack with format 'l' with modifier '<' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'l' with modifier '>' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'L' ignores whitespace in the format string
fails:String#unpack with format 'L' calls #to_str to coerce the directives string
fails:String#unpack with format 'L' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'l' ignores whitespace in the format string
fails:String#unpack with format 'l' calls #to_str to coerce the directives string
fails:String#unpack with format 'l' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'L' with modifier '_' decodes a long with most significant bit set as a positive number
fails:String#unpack with format 'L' with modifier '!' decodes a long with most significant bit set as a positive number
fails:String#unpack with format 'L' with modifier '<' and '_' decodes one int for a single format character
fails:String#unpack with format 'L' with modifier '<' and '_' decodes two ints for two format characters
fails:String#unpack with format 'L' with modifier '<' and '_' decodes the number of ints requested by the count modifier
20 changes: 0 additions & 20 deletions spec/truffle/tags/core/string/unpack/m_tags.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,2 @@
fails:String#unpack with format 'M' calls #to_str to coerce the directives string
fails:String#unpack with format 'M' decodes an empty string
fails:String#unpack with format 'M' decodes the complete string ignoring newlines when given a single directive
fails:String#unpack with format 'M' appends empty string to the array for directives exceeding the input size
fails:String#unpack with format 'M' ignores the count or '*' modifier and decodes the entire string
fails:String#unpack with format 'M' decodes the '=' character
fails:String#unpack with format 'M' decodes an embedded space character
fails:String#unpack with format 'M' decodes a space at the end of the pre-encoded string
fails:String#unpack with format 'M' decodes an embedded tab character
fails:String#unpack with format 'M' decodes a tab character at the end of the pre-encoded string
fails:String#unpack with format 'M' decodes an embedded newline
fails:String#unpack with format 'M' decodes pre-encoded byte values 33..60
fails:String#unpack with format 'M' decodes pre-encoded byte values 62..126
fails:String#unpack with format 'M' decodes pre-encoded byte values 0..31 except tab and newline
fails:String#unpack with format 'M' decodes pre-encoded byte values 127..255
fails:String#unpack with format 'm' calls #to_str to coerce the directives string
fails:String#unpack with format 'm' decodes an empty string
fails:String#unpack with format 'm' decodes the complete string ignoring newlines when given a single directive
fails:String#unpack with format 'm' ignores the count or '*' modifier and decodes the entire string
fails:String#unpack with format 'm' appends empty string to the array for directives exceeding the input size
fails:String#unpack with format 'm' decodes all pre-encoded ascii byte values
fails:String#unpack with format 'm' produces binary strings
3 changes: 0 additions & 3 deletions spec/truffle/tags/core/string/unpack/n_tags.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
fails:String#unpack with format 'N' ignores whitespace in the format string
fails:String#unpack with format 'N' calls #to_str to coerce the directives string
fails:String#unpack with format 'N' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'n' calls #to_str to coerce the directives string
fails:String#unpack with format 'n' adds nil for each element requested beyond the end of the String
7 changes: 0 additions & 7 deletions spec/truffle/tags/core/string/unpack/q_tags.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
fails:String#unpack with format 'Q' with modifier '<' decodes a long with most significant bit set as a positive number
fails:String#unpack with format 'Q' with modifier '>' decodes a long with most significant bit set as a positive number
fails:String#unpack with format 'Q' ignores whitespace in the format string
fails:String#unpack with format 'Q' calls #to_str to coerce the directives string
fails:String#unpack with format 'q' ignores whitespace in the format string
fails:String#unpack with format 'q' calls #to_str to coerce the directives string
fails:String#unpack with format 'Q' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'Q' decodes a long with most significant bit set as a positive number
fails:String#unpack with format 'q' adds nil for each element requested beyond the end of the String
18 changes: 0 additions & 18 deletions spec/truffle/tags/core/string/unpack/s_tags.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,2 @@
fails:String#unpack with format 'S' with modifier '<' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'S' with modifier '<' and '_' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'S' with modifier '<' and '!' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'S' with modifier '>' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'S' with modifier '>' and '_' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'S' with modifier '>' and '!' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 's' with modifier '<' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 's' with modifier '<' and '_' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 's' with modifier '<' and '!' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 's' with modifier '>' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 's' with modifier '>' and '_' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 's' with modifier '>' and '!' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'S' calls #to_str to coerce the directives string
fails:String#unpack with format 'S' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'S' with modifier '_' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'S' with modifier '!' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 's' calls #to_str to coerce the directives string
fails:String#unpack with format 's' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 's' with modifier '_' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 's' with modifier '!' adds nil for each element requested beyond the end of the String
5 changes: 0 additions & 5 deletions spec/truffle/tags/core/string/unpack/u_tags.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
fails:String#unpack with format 'U' calls #to_str to coerce the directives string
fails:String#unpack with format 'u' calls #to_str to coerce the directives string
fails:String#unpack with format 'u' decodes an empty string as an empty string
fails:String#unpack with format 'u' decodes the complete string ignoring newlines when given a single directive
fails:String#unpack with format 'u' appends empty string to the array for directives exceeding the input size
fails:String#unpack with format 'u' ignores the count or '*' modifier and decodes the entire string
fails:String#unpack with format 'u' decodes all ascii characters
3 changes: 0 additions & 3 deletions spec/truffle/tags/core/string/unpack/v_tags.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
fails:String#unpack with format 'V' ignores whitespace in the format string
fails:String#unpack with format 'V' calls #to_str to coerce the directives string
fails:String#unpack with format 'V' adds nil for each element requested beyond the end of the String
fails:String#unpack with format 'v' calls #to_str to coerce the directives string
fails:String#unpack with format 'v' adds nil for each element requested beyond the end of the String
1 change: 0 additions & 1 deletion spec/truffle/tags/core/string/unpack/w_tags.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
fails:String#unpack with directive 'w' calls #to_str to coerce the directives string
fails:String#unpack with directive 'w' decodes a BER-compressed integer
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/string/unpack/x_tags.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
fails:String#unpack with format 'X' calls #to_str to coerce the directives string
fails:String#unpack with format 'x' calls #to_str to coerce the directives string
fails:String#unpack with format 'x' moves the read index to the end of the string when passed the '*' modifier
fails:String#unpack with format 'x' positions the read index one beyond the last readable byte in the String
9 changes: 0 additions & 9 deletions spec/truffle/tags/core/string/unpack/z_tags.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
fails:String#unpack with format 'Z' calls #to_str to coerce the directives string
fails:String#unpack with format 'Z' returns an empty string if the input is empty
fails:String#unpack with format 'Z' returns empty strings for repeated formats if the input is empty
fails:String#unpack with format 'Z' returns an empty string and does not decode any bytes when the count modifier is zero
fails:String#unpack with format 'Z' implicitly has a count of one when no count is specified
fails:String#unpack with format 'Z' decodes the number of bytes specified by the count modifier
fails:String#unpack with format 'Z' decodes the number of bytes specified by the count modifier including whitespace bytes
fails:String#unpack with format 'Z' decodes past whitespace bytes when passed the '*' modifier
fails:String#unpack with format 'Z' stops decoding at NULL bytes when passed the '*' modifier
fails:String#unpack with format 'Z' decodes the number of bytes specified by the count modifier and truncates the decoded string at the first NULL byte
Original file line number Diff line number Diff line change
@@ -2159,7 +2159,7 @@ public UnpackNode(RubyContext context, SourceSection sourceSection) {
@Specialization
public RubyArray unpack(RubyString string, RubyString format) {
final org.jruby.RubyArray jrubyArray = Pack.unpack(getContext().getRuntime(), string.getByteList(), format.getByteList());
return RubyArray.fromObjects(getContext().getCoreLibrary().getArrayClass(), jrubyArray.toArray());
return getContext().toTruffle(jrubyArray);
}

}
20 changes: 11 additions & 9 deletions truffle/src/main/java/org/jruby/truffle/runtime/RubyContext.java
Original file line number Diff line number Diff line change
@@ -504,22 +504,24 @@ public Object toTruffle(IRubyObject object) {
} else if (object instanceof org.jruby.RubySymbol) {
return getSymbolTable().getSymbol(object.toString());
} else if (object instanceof org.jruby.RubyArray) {
final org.jruby.RubyArray jrubyArray = (org.jruby.RubyArray) object;

final Object[] truffleArray = new Object[jrubyArray.size()];

for (int n = 0; n < truffleArray.length; n++) {
truffleArray[n] = toTruffle((IRubyObject) jrubyArray.get(n));
}

return new RubyArray(coreLibrary.getArrayClass(), truffleArray, truffleArray.length);
return toTruffle((org.jruby.RubyArray) object);
} else if (object instanceof org.jruby.RubyException) {
return toTruffle((org.jruby.RubyException) object, null);
} else {
throw object.getRuntime().newRuntimeError("cannot pass " + object.inspect() + " (" + object.getClass().getName() + ") to Truffle");
}
}

public RubyArray toTruffle(org.jruby.RubyArray array) {
final Object[] store = new Object[array.size()];

for (int n = 0; n < store.length; n++) {
store[n] = toTruffle(array.entry(n));
}

return RubyArray.fromObjects(coreLibrary.getArrayClass(), store);
}

public RubyString toTruffle(org.jruby.RubyString jrubyString) {
final RubyString truffleString = new RubyString(getCoreLibrary().getStringClass(), jrubyString.getByteList().dup());

0 comments on commit cf0bfa9

Please sign in to comment.