File tree Expand file tree Collapse file tree
spec/truffle/tags/core/string
truffle/src/main/java/org/jruby/truffle/nodes/core Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11fails:String#chomp when passed no argument removes one trailing carrige return, newline pair
22fails:String#chomp when passed no argument taints the result if self is tainted
3- fails:String#chomp when passed nil does not modify the String
4- fails:String#chomp when passed nil returns a copy of the String
53fails:String#chomp when passed nil taints the result if self is tainted
6- fails:String#chomp when passed nil returns an empty String when self is empty
74fails:String#chomp when passed '' removes a final newline
85fails:String#chomp when passed '' removes a final carriage return, newline
96fails:String#chomp when passed '' removes more than one trailing newlines
@@ -18,10 +15,7 @@ fails:String#chomp! raises a RuntimeError on a frozen instance when it would not
1815fails:String#chomp! when passed no argument returns nil if self is not modified
1916fails:String#chomp! when passed no argument removes one trailing newline
2017fails:String#chomp! when passed no argument removes one trailing carrige return, newline pair
21- fails:String#chomp! when passed no argument returns nil when self is empty
2218fails:String#chomp! when passed no argument removes trailing characters that match $/ when it has been assigned a value
23- fails:String#chomp! when passed nil returns nil
24- fails:String#chomp! when passed nil returns nil when self is empty
2519fails:String#chomp! when passed '' removes a final newline
2620fails:String#chomp! when passed '' removes a final carriage return, newline
2721fails:String#chomp! when passed '' does not remove a final carriage return
Original file line number Diff line number Diff line change @@ -512,14 +512,23 @@ public ChompBangNode(ChompBangNode prev) {
512512 }
513513
514514 @ Specialization
515- public RubyString chompBang (RubyString string , UndefinedPlaceholder undefined ) {
515+ public Object chompBang (RubyString string , UndefinedPlaceholder undefined ) {
516516 notDesignedForCompilation ();
517517
518+ if (string .length () == 0 ) {
519+ return getContext ().getCoreLibrary ().getNilObject ();
520+ }
521+
518522 string .set (StringNodesHelper .chomp (string ));
519523 return string ;
520524 }
521525
522- @ Specialization (guards = "!isUndefinedPlaceholder(arguments[1])" )
526+ @ Specialization
527+ public RubyNilClass chompBangWithNil (RubyString string , RubyNilClass stringToChomp ) {
528+ return getContext ().getCoreLibrary ().getNilObject ();
529+ }
530+
531+ @ Specialization (guards = { "!isUndefinedPlaceholder(arguments[1])" , "!isRubyNilClass(arguments[1])" })
523532 public RubyString chompBangWithString (VirtualFrame frame , RubyString string , Object stringToChomp ) {
524533 notDesignedForCompilation ();
525534
You can’t perform that action at this time.
0 commit comments