Skip to content

Commit

Permalink
[Truffle] Handle frozen checks in String.
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvdrum committed Mar 5, 2015
1 parent f081603 commit 5942d92
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 14 deletions.
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/string/chomp_tags.txt
Expand Up @@ -5,8 +5,6 @@ fails:String#chomp when passed '' removes more than one trailing newlines
fails:String#chomp when passed '' removes more than one trailing carriage return, newline pairs
fails:String#chomp when passed '\n' removes one trailing carriage return
fails:String#chomp when passed '\n' removes one trailing carrige return, newline pair
fails:String#chomp! raises a RuntimeError on a frozen instance when it is modified
fails:String#chomp! raises a RuntimeError on a frozen instance when it would not be modified
fails:String#chomp! when passed no argument returns nil if self is not modified
fails:String#chomp! when passed no argument removes one trailing newline
fails:String#chomp! when passed no argument removes one trailing carrige return, newline pair
Expand Down
1 change: 0 additions & 1 deletion spec/truffle/tags/core/string/clear_tags.txt
@@ -1,2 +1 @@
fails:String#clear preserves its encoding
fails:String#clear raises a RuntimeError if self is frozen
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/string/reverse_tags.txt
@@ -1,4 +1,2 @@
fails:String#reverse! raises a RuntimeError on a frozen instance that is modified
fails:String#reverse! raises a RuntimeError on a frozen instance that would not be modified
fails:String#reverse! reverses a string with multi byte characters
fails:String#reverse reverses a string with multi byte characters
1 change: 0 additions & 1 deletion spec/truffle/tags/core/string/setbyte_tags.txt
Expand Up @@ -8,5 +8,4 @@ fails:String#setbyte raises an IndexError if the index is greater than the Strin
fails:String#setbyte raises an IndexError if the nexgative index is greater magnitude than the String bytesize
fails:String#setbyte sets a byte at an index greater than String size
fails:String#setbyte does not modify the original string when using String.new
fails:String#setbyte raises a RuntimeError if self is frozen
fails:String#setbyte raises a TypeError unless the second argument is an Integer
1 change: 0 additions & 1 deletion spec/truffle/tags/core/string/swapcase_tags.txt
@@ -1,4 +1,3 @@
fails:String#swapcase is locale insensitive (only upcases a-z and only downcases A-Z)
fails:String#swapcase returns subclass instances when called on a subclass
fails:String#swapcase! returns nil if no modifications were made
fails:String#swapcase! raises a RuntimeError when self is frozen
1 change: 0 additions & 1 deletion spec/truffle/tags/core/string/upcase_tags.txt
@@ -1,4 +1,3 @@
fails:String#upcase is locale insensitive (only replaces a-z)
fails:String#upcase returns a subclass instance for subclasses
fails:String#upcase! returns nil if no modifications were made
fails:String#upcase! raises a RuntimeError when self is frozen
Expand Up @@ -634,7 +634,7 @@ public int byteSize(RubyString string) {

}

@CoreMethod(names = "chomp!", optional = 1)
@CoreMethod(names = "chomp!", optional = 1, raiseIfFrozenSelf = true)
public abstract static class ChompBangNode extends CoreMethodNode {

@Child private ToStrNode toStrNode;
Expand Down Expand Up @@ -1349,7 +1349,7 @@ public RubyString swapcase(RubyString string) {
}
}

@CoreMethod(names = "swapcase!")
@CoreMethod(names = "swapcase!", raiseIfFrozenSelf = true)
public abstract static class SwapcaseBangNode extends CoreMethodNode {
public SwapcaseBangNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
Expand Down Expand Up @@ -1509,7 +1509,7 @@ public RubyString scan(VirtualFrame frame, RubyString string, RubyRegexp regexp,
}
}

@CoreMethod(names = "setbyte", required = 2)
@CoreMethod(names = "setbyte", required = 2, raiseIfFrozenSelf = true)
public abstract static class SetByteNode extends CoreMethodNode {

public SetByteNode(RubyContext context, SourceSection sourceSection) {
Expand Down Expand Up @@ -1769,7 +1769,7 @@ public RubyString reverse(RubyString string) {
}
}

@CoreMethod(names = "reverse!")
@CoreMethod(names = "reverse!", raiseIfFrozenSelf = true)
public abstract static class ReverseBangNode extends CoreMethodNode {

public ReverseBangNode(RubyContext context, SourceSection sourceSection) {
Expand Down Expand Up @@ -1830,7 +1830,7 @@ public RubyString upcase(RubyString string) {

}

@CoreMethod(names = "upcase!")
@CoreMethod(names = "upcase!", raiseIfFrozenSelf = true)
public abstract static class UpcaseBangNode extends CoreMethodNode {

public UpcaseBangNode(RubyContext context, SourceSection sourceSection) {
Expand Down Expand Up @@ -1927,7 +1927,7 @@ public RubyString capitalize(RubyString string) {

}

@CoreMethod(names = "clear")
@CoreMethod(names = "clear", raiseIfFrozenSelf = true)
public abstract static class ClearNode extends CoreMethodNode {

public ClearNode(RubyContext context, SourceSection sourceSection) {
Expand Down

0 comments on commit 5942d92

Please sign in to comment.