forked from phoedos/pmd
Added test case for template strings in Ecmascript.
This commit is contained in:
Maikel Steneker
committed by
Juan Martín Sotuyo Dodero
parent
f801b30e70
commit
1681b05222
@ -118,4 +118,36 @@ public class EcmascriptTokenizerTest {
|
||||
sb.append( "}" ).append(PMD.EOL);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTemplateStrings() throws IOException {
|
||||
Tokenizer t = new EcmascriptTokenizer();
|
||||
SourceCode sourceCode = new SourceCode( new SourceCode.StringCodeLoader(
|
||||
"export default class DrawLocation extends joint.shapes.basic.Generic {\n"
|
||||
+ " constructor(location: ILocation) {\n"
|
||||
+ " this.markup = `<g>\n"
|
||||
+ " <path class=\"location\"/>\n"
|
||||
+ " <text x=\"0\" y=\"0\" text-anchor=\"middle\" class=\"location-text\"></text>\n"
|
||||
+ "\n"
|
||||
+ " <path class=\"location\"/>\n"
|
||||
+ " <circle class=\"location-circle\"/>\n"
|
||||
+ " ${drawIndicators.Check.markup}\n"
|
||||
+ "\n"
|
||||
+ " </g>`;\n"
|
||||
+ " }\n"
|
||||
+ "\n"
|
||||
+ "}") );
|
||||
final Tokens tokens = new Tokens();
|
||||
t.tokenize(sourceCode, tokens);
|
||||
final String templateString = "`<g>\n"
|
||||
+ " <path class=\"location\"/>\n"
|
||||
+ " <text x=\"0\" y=\"0\" text-anchor=\"middle\" class=\"location-text\"></text>\n"
|
||||
+ "\n"
|
||||
+ " <path class=\"location\"/>\n"
|
||||
+ " <circle class=\"location-circle\"/>\n"
|
||||
+ " ${drawIndicators.Check.markup}\n"
|
||||
+ "\n"
|
||||
+ " </g>`";
|
||||
assertEquals(templateString, tokens.getTokens().get(24).toString());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user