Skip to content

Commit

Permalink
[Truffle] - String#capitalize! raises a RuntimeError when self is frozen
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasallan committed Mar 4, 2015
1 parent 116100f commit 4e4e46a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 1 addition & 2 deletions spec/truffle/tags/core/string/capitalize_tags.txt
@@ -1,5 +1,4 @@
fails:String#capitalize taints resulting string when self is tainted
fails:String#capitalize is locale insensitive (only upcases a-z and only downcases A-Z)
fails:String#capitalize returns subclass instances when called on a subclass
fails:String#capitalize! returns nil when no changes are made
fails:String#capitalize! raises a RuntimeError when self is frozen
fails:String#capitalize! returns nil when no changes are made
Expand Up @@ -1926,6 +1926,8 @@ public RubyString capitalizeBang(RubyString string) {
String javaString = string.toString();
if (javaString.isEmpty()) {
return string;
} else if (string.isFrozen()) {
throw new RaiseException(getContext().getCoreLibrary().runtimeError("can't modify frozen string", this));
} else {
final ByteList byteListString = StringNodesHelper.capitalize(string);

Expand Down

1 comment on commit 4e4e46a

@nirvdrum
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, RubyBasicObject now has a checkFrozen method that that we're using for frozen checks. Check out its usages to see where and how we use it.

Please sign in to comment.