Skip to content
This repository

Apply '-' behaviour to blank padded format directives. #292

Merged
merged 1 commit into from over 1 year ago

2 participants

Sébastien Le Callonnec Charles Oliver Nutter
Sébastien Le Callonnec
Collaborator

This commit addresses jruby issue #289. The expected behaviour is documented in this rubyspec pull request: rubyspec/rubyspec#153

Sébastien Le Callonnec Apply '-' behaviour to blank padded format directives.
This commit addresses jruby issue #289.  The expected behaviour is documented in this rubyspec pull request: rubyspec/rubyspec#153
6f86d35
Charles Oliver Nutter headius merged commit 5391e26 into from September 28, 2012
Charles Oliver Nutter headius closed this September 28, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Sep 07, 2012
Sébastien Le Callonnec Apply '-' behaviour to blank padded format directives.
This commit addresses jruby issue #289.  The expected behaviour is documented in this rubyspec pull request: rubyspec/rubyspec#153
6f86d35
This page is out of date. Refresh to see the latest.
2  src/org/jruby/util/TimeOutputFormatter.java
@@ -121,7 +121,7 @@ public String format(String sequence) {
121 121
                         paddedWith = '0';
122 122
                         break;
123 123
                     case '-':
124  
-                        sequence = sequence.replaceAll("^[0]", "");
  124
+                        sequence = sequence.replaceAll("^[0 ]", "");
125 125
                         break;
126 126
                 }
127 127
             }
10  test/org/jruby/util/TimeOutputFormatterTest.java
@@ -88,4 +88,14 @@ public void testPaddingWithUpperCase() {
88 88
         TimeOutputFormatter formatter = TimeOutputFormatter.getFormatter("%^5H");
89 89
         assertEquals("   UP", formatter.format("up"));
90 90
     }
  91
+
  92
+    public void testFormatNoPaddingForBlankPaddedValues() {
  93
+       TimeOutputFormatter formatter = TimeOutputFormatter.getFormatter("%-3H");
  94
+        assertEquals("up", formatter.format(" up"));
  95
+    }
  96
+
  97
+   public void testFormatNoPaddingForZeroPaddedValues() {
  98
+       TimeOutputFormatter formatter = TimeOutputFormatter.getFormatter("%-3H");
  99
+        assertEquals("up", formatter.format("0up"));
  100
+    }
91 101
 }
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.