Use skylark-preferred quote char for string literal
We currently have no need to discern between strings quoted with ' or ". While it could be
nice for something one day (and may have been in the past), it's yagni now. Removing the
distinction simplifies string concatenation.
--
PiperOrigin-RevId: 148273400
MOS_MIGRATED_REVID=148273400
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/ParserTest.java b/src/test/java/com/google/devtools/build/lib/syntax/ParserTest.java
index 43f6bcf..db96a9d 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/ParserTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/ParserTest.java
@@ -224,7 +224,7 @@
@Test
public void testStringLiteralOptimizationToString() throws Exception {
StringLiteral l = (StringLiteral) parseExpression("'abc' + 'def'");
- assertEquals("'abcdef'", l.toString());
+ assertEquals("\"abcdef\"", l.toString());
}
@Test
@@ -236,7 +236,9 @@
@Test
public void testStringLiteralOptimizationDifferentQuote() throws Exception {
- assertThat(parseExpression("'abc' + \"def\"")).isInstanceOf(BinaryOperatorExpression.class);
+ StringLiteral l = (StringLiteral) parseExpression("'abc' + \"def\"");
+ assertEquals(0, l.getLocation().getStartOffset());
+ assertEquals(13, l.getLocation().getEndOffset());
}
@Test
@@ -443,8 +445,8 @@
assertEquals("[x[1::2]\n]", parseFile("x[1::2]").toString());
assertEquals("[x[1:]\n]", parseFile("x[1:]").toString());
assertEquals("[str[42]\n]", parseFile("str[42]").toString());
- assertEquals("[ctx.new_file('hello')\n]", parseFile("ctx.new_file('hello')").toString());
- assertEquals("[new_file('hello')\n]", parseFile("new_file('hello')").toString());
+ assertEquals("[ctx.new_file(\"hello\")\n]", parseFile("ctx.new_file('hello')").toString());
+ assertEquals("[new_file(\"hello\")\n]", parseFile("new_file(\"hello\")").toString());
}
@Test
@@ -1044,7 +1046,7 @@
Label containingFileLabel = Label.parseAbsoluteUnchecked(containingFileLabelString);
assertThat(imp.getLabel(containingFileLabel)).named("containingFileLabel()")
- .isEqualTo(Label.parseAbsoluteUnchecked(expectedLabelString));
+ .isEqualTo(Label.parseAbsoluteUnchecked(expectedLabelString));
int startOffset = stmt.getImport().getLocation().getStartOffset();
int endOffset = stmt.getImport().getLocation().getEndOffset();
@@ -1055,7 +1057,7 @@
private void invalidImportTest(String importString, String expectedMsg) {
setFailFast(false);
- parseFileForSkylark("load('" + importString + "', 'fun_test')\n");
+ parseFileForSkylark("load('" + importString + "', 'fun_test')\n");
assertContainsError(expectedMsg);
}