Skip to content

Commit

Permalink
Add test for ST.format
Browse files Browse the repository at this point in the history
Also remove incorrect examples from the documentation of this method.

Fixes antlr#113
  • Loading branch information
sharwell committed Jul 17, 2016
1 parent 1c5d129 commit b631ab4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/org/stringtemplate/v4/ST.java
Expand Up @@ -561,9 +561,7 @@ public String toString() {

/**
* <pre>
* ST.format("name, phone | &lt;name&gt;:&lt;phone&gt;", n, p);
* ST.format("&lt;%1&gt;:&lt;%2&gt;", n, p);
* ST.format("&lt;name&gt;:&lt;phone&gt;", "name", x, "phone", y);
* </pre>
*/
public static String format(String template, Object... attributes) {
Expand Down
8 changes: 8 additions & 0 deletions test/org/stringtemplate/v4/test/TestCoreBasics.java
Expand Up @@ -1064,4 +1064,12 @@ public class TestCoreBasics extends BaseTest {
st2.add("arg1", "value");
assertEquals("simple template", st2.render());
}

@Test public void testFormat_PositionalArguments() {
String n = "n";
String p = "p";
String expected = "n:p";
String actual = ST.format("<%1>:<%2>", n, p);
assertEquals(expected, actual);
}
}

0 comments on commit b631ab4

Please sign in to comment.