Skip to content

Commit

Permalink
[Truffle] Fixed some more String#{chomp, chomp\!} cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvdrum committed Feb 6, 2015
1 parent e249a18 commit 6644d04
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
6 changes: 0 additions & 6 deletions spec/truffle/tags/core/string/chomp_tags.txt
@@ -1,9 +1,6 @@
fails:String#chomp when passed no argument removes one trailing carrige return, newline pair
fails:String#chomp when passed no argument taints the result if self is tainted
fails:String#chomp when passed nil does not modify the String
fails:String#chomp when passed nil returns a copy of the String
fails:String#chomp when passed nil taints the result if self is tainted
fails:String#chomp when passed nil returns an empty String when self is empty
fails:String#chomp when passed '' removes a final newline
fails:String#chomp when passed '' removes a final carriage return, newline
fails:String#chomp when passed '' removes more than one trailing newlines
Expand All @@ -18,10 +15,7 @@ fails:String#chomp! raises a RuntimeError on a frozen instance when it would not
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
fails:String#chomp! when passed no argument returns nil when self is empty
fails:String#chomp! when passed no argument removes trailing characters that match $/ when it has been assigned a value
fails:String#chomp! when passed nil returns nil
fails:String#chomp! when passed nil returns nil when self is empty
fails:String#chomp! when passed '' removes a final newline
fails:String#chomp! when passed '' removes a final carriage return, newline
fails:String#chomp! when passed '' does not remove a final carriage return
Expand Down
Expand Up @@ -512,14 +512,23 @@ public ChompBangNode(ChompBangNode prev) {
}

@Specialization
public RubyString chompBang(RubyString string, UndefinedPlaceholder undefined) {
public Object chompBang(RubyString string, UndefinedPlaceholder undefined) {
notDesignedForCompilation();

if (string.length() == 0) {
return getContext().getCoreLibrary().getNilObject();
}

string.set(StringNodesHelper.chomp(string));
return string;
}

@Specialization(guards = "!isUndefinedPlaceholder(arguments[1])")
@Specialization
public RubyNilClass chompBangWithNil(RubyString string, RubyNilClass stringToChomp) {
return getContext().getCoreLibrary().getNilObject();
}

@Specialization(guards = { "!isUndefinedPlaceholder(arguments[1])", "!isRubyNilClass(arguments[1])" })
public RubyString chompBangWithString(VirtualFrame frame, RubyString string, Object stringToChomp) {
notDesignedForCompilation();

Expand Down

0 comments on commit 6644d04

Please sign in to comment.