Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] - add quotes to toString representation of a String literal
Browse files Browse the repository at this point in the history
  • Loading branch information
tobrun committed Sep 4, 2018
1 parent e7642f2 commit 1099bb4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2834,8 +2834,8 @@ public static Expression floor(Number number) {
* CircleLayer circleLayer = new CircleLayer("layer-id", "source-id");
* circleLayer.setProperties(
* circleColor(switchCase(
eq(literal("it"), resolvedLocale(collator(true, true, "it"))), literal(ColorUtils.colorToRgbaString(Color.GREEN)),
literal(ColorUtils.colorToRgbaString(Color.RED))))
* eq(literal("it"), resolvedLocale(collator(true, true, "it"))), literal(ColorUtils.colorToRgbaString(Color.GREEN)),
* literal(ColorUtils.colorToRgbaString(Color.RED))))
* );
* }
* </pre>
Expand Down Expand Up @@ -3921,13 +3921,10 @@ public String toString() {

// special case for handling unusual input like 'rgba(r, g, b, a)'
if (literalValue instanceof String) {
if (((String) literalValue).contains(",")) {
builder.append("\"").append(literalValue).append("\"");
continue;
}
builder.append("\"").append(literalValue).append("\"");
} else {
builder.append(literalValue);
}

builder.append(literalValue);
} else {
builder.append(argument.toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ public void testCubicBezierExpressionLiteral() throws Exception {

@Test
public void testExpressionConcatToString() throws Exception {
String expected = "[\"concat\", foo, bar]";
String expected = "[\"concat\", \"foo\", \"bar\"]";
String actual = concat(literal("foo"), literal("bar")).toString();
assertEquals("toString should match", expected, actual);
}
Expand All @@ -1116,7 +1116,7 @@ public void testExpressionMinToString() throws Exception {
@Test
public void testExpressionExponentialToString() throws Exception {
String expected = "[\"interpolate\", [\"cubic-bezier\", 1.0, 1.0, 1.0, 1.0],"
+ " [\"get\", x], 0.0, 100.0, 100.0, 200.0]";
+ " [\"get\", \"x\"], 0.0, 100.0, 100.0, 200.0]";
String actual = interpolate(cubicBezier(literal(1), literal(1), literal(1), literal(1)),
get(literal("x")), literal(0), literal(100), literal(100), literal(200)).toString();
assertEquals("toString should match", expected, actual);
Expand Down Expand Up @@ -1367,4 +1367,11 @@ public void testStringNestedCollator() {
String actual = collator(literal(false), eq(literal(2), literal(1)), literal("it")).toString();
assertEquals("expression should match", expected, actual);
}

@Test
public void testStringReverseConversion() {
String expected = "[\"to-string\", [\"get\", \"name_en\"]]";
String actual = Expression.toString(get("name_en")).toString();
assertEquals("Reverse string conversion should match", expected, actual);
}
}

0 comments on commit 1099bb4

Please sign in to comment.