File tree Expand file tree Collapse file tree 2 files changed +11
-8
lines changed
spec/truffle/tags/core/string
truffle/src/main/java/org/jruby/truffle/nodes/core Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Original file line number Diff line number Diff line change 1
1
fails:String#chomp when passed no argument removes one trailing carrige return, newline pair
2
2
fails: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
5
3
fails: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
7
4
fails:String#chomp when passed '' removes a final newline
8
5
fails:String#chomp when passed '' removes a final carriage return, newline
9
6
fails: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
18
15
fails:String#chomp! when passed no argument returns nil if self is not modified
19
16
fails:String#chomp! when passed no argument removes one trailing newline
20
17
fails: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
22
18
fails: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
25
19
fails:String#chomp! when passed '' removes a final newline
26
20
fails:String#chomp! when passed '' removes a final carriage return, newline
27
21
fails: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) {
512
512
}
513
513
514
514
@ Specialization
515
- public RubyString chompBang (RubyString string , UndefinedPlaceholder undefined ) {
515
+ public Object chompBang (RubyString string , UndefinedPlaceholder undefined ) {
516
516
notDesignedForCompilation ();
517
517
518
+ if (string .length () == 0 ) {
519
+ return getContext ().getCoreLibrary ().getNilObject ();
520
+ }
521
+
518
522
string .set (StringNodesHelper .chomp (string ));
519
523
return string ;
520
524
}
521
525
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])" })
523
532
public RubyString chompBangWithString (VirtualFrame frame , RubyString string , Object stringToChomp ) {
524
533
notDesignedForCompilation ();
525
534
You can’t perform that action at this time.
0 commit comments