Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Merged
merged 1 commit into from

2 participants

@tychobrailleur
Collaborator

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

@tychobrailleur tychobrailleur 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
@headius headius merged commit 5391e26 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 7, 2012
  1. @tychobrailleur

    Apply '-' behaviour to blank padded format directives.

    tychobrailleur authored
    This commit addresses jruby issue #289.  The expected behaviour is documented in this rubyspec pull request: rubyspec/rubyspec#153
This page is out of date. Refresh to see the latest.
View
2  src/org/jruby/util/TimeOutputFormatter.java
@@ -121,7 +121,7 @@ public String format(String sequence) {
paddedWith = '0';
break;
case '-':
- sequence = sequence.replaceAll("^[0]", "");
+ sequence = sequence.replaceAll("^[0 ]", "");
break;
}
}
View
10 test/org/jruby/util/TimeOutputFormatterTest.java
@@ -88,4 +88,14 @@ public void testPaddingWithUpperCase() {
TimeOutputFormatter formatter = TimeOutputFormatter.getFormatter("%^5H");
assertEquals(" UP", formatter.format("up"));
}
+
+ public void testFormatNoPaddingForBlankPaddedValues() {
+ TimeOutputFormatter formatter = TimeOutputFormatter.getFormatter("%-3H");
+ assertEquals("up", formatter.format(" up"));
+ }
+
+ public void testFormatNoPaddingForZeroPaddedValues() {
+ TimeOutputFormatter formatter = TimeOutputFormatter.getFormatter("%-3H");
+ assertEquals("up", formatter.format("0up"));
+ }
}
Something went wrong with that request. Please try again.