Skip to content

Commit 4feca49

Browse files
committed
[Truffle] String#num_bytes= and primitive :string_resize_capacity
1 parent cf89fd2 commit 4feca49

File tree

12 files changed

+34
-55
lines changed

12 files changed

+34
-55
lines changed
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,2 @@
1-
fails:StringIO#<< when passed [Object] returns self
21
fails:StringIO#<< when passed [Object] writes the passed argument onto self
32
fails:StringIO#<< when passed [Object] writes the passed argument at the current position
4-
fails:StringIO#<< when passed [Object] pads self with \000 when the current position is after the end
5-
fails:StringIO#<< when passed [Object] taints self's String when the passed argument is tainted
6-
fails:StringIO#<< when passed [Object] does not taint self when the passed argument is tainted
7-
fails:StringIO#<< when passed [Object] updates self's position
8-
fails:StringIO#<< when passed [Object] tries to convert the passed argument to a String using #to_s

spec/truffle/tags/rubysl/rubysl-stringio/spec/close_read_tags.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
fails:StringIO#print prints $_ when passed no arguments
22
fails:StringIO#print prints the passed arguments to self
33
fails:StringIO#print tries to convert the passed Object to a String using #to_s
4-
fails:StringIO#print returns nil
54
fails:StringIO#print pads self with \000 when the current position is after the end
6-
fails:StringIO#print honors the output record separator global
75
fails:StringIO#print updates the current position
8-
fails:StringIO#print correctly updates the current position when honoring the output record separator global
96
fails:StringIO#print when in append mode appends the passed argument to the end of self
107
fails:StringIO#print when in append mode correctly updates self's position
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
fails:StringIO#printf returns nil
2-
fails:StringIO#printf pads self with \000 when the current position is after the end
31
fails:StringIO#printf performs format conversion
4-
fails:StringIO#printf updates the current position

spec/truffle/tags/rubysl/rubysl-stringio/spec/putc_tags.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

spec/truffle/tags/rubysl/rubysl-stringio/spec/reopen_tags.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ fails:StringIO#reopen when passed [Object, Integer] raises an Errno::EACCES when
66
fails:StringIO#reopen when passed [Object, Integer] raises a TypeError when trying to reopen self with a frozen String in truncate-mode
77
fails:StringIO#reopen when passed [Object, Integer] raises a RuntimeError when trying to reopen self with a frozen String in truncate-mode
88
fails:StringIO#reopen when passed [Object, Integer] does not raise IOError when passed a frozen String in read-mode
9-
fails:StringIO#reopen reopens a stream when given a String argument
109
fails:StringIO#reopen does not truncate the content even when the StringIO argument is in the truncate mode

spec/truffle/tags/rubysl/rubysl-stringio/spec/syswrite_tags.txt

Lines changed: 0 additions & 10 deletions
This file was deleted.

spec/truffle/tags/rubysl/rubysl-stringio/spec/write_nonblock_tags.txt

Lines changed: 0 additions & 10 deletions
This file was deleted.

spec/truffle/tags/rubysl/rubysl-stringio/spec/write_tags.txt

Lines changed: 0 additions & 10 deletions
This file was deleted.

truffle/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2213,4 +2213,22 @@ public static ByteList swapcase(RubyString string) {
22132213
}
22142214
}
22152215

2216+
@CoreMethod(names = "_set_num_bytes", required = 1)
2217+
public abstract static class SetNumBytesNode extends CoreMethodNode {
2218+
2219+
public SetNumBytesNode(RubyContext context, SourceSection sourceSection) {
2220+
super(context, sourceSection);
2221+
}
2222+
2223+
public SetNumBytesNode(SetNumBytesNode prev) {
2224+
super(prev);
2225+
}
2226+
2227+
@Specialization
2228+
public RubyString setNumBytes(RubyString string, int count) {
2229+
string.getByteList().view(0, count);
2230+
return string;
2231+
}
2232+
}
2233+
22162234
}

0 commit comments

Comments
 (0)