Merge branch 'master' into 7.0.x

This commit is contained in:
Clément Fournier
2019-04-11 15:18:54 +02:00
21 changed files with 1414 additions and 23 deletions

View File

@@ -917,10 +917,10 @@ RUNE_LIT
//unicode_value = unicode_char | little_u_value | big_u_value | escaped_char .
fragment UNICODE_VALUE
: UNICODE_CHAR
| LITTLE_U_VALUE
: LITTLE_U_VALUE
| BIG_U_VALUE
| ESCAPED_CHAR
| UNICODE_CHAR
;
//byte_value = octal_byte_value | hex_byte_value .

View File

@@ -0,0 +1,29 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cpd;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import org.apache.commons.io.IOUtils;
import org.junit.Test;
public class EdgeCasesTokenizerTest {
private String getSampleCode(final String filename) throws IOException {
return IOUtils.toString(GoTokenizer.class.getResourceAsStream(filename), StandardCharsets.UTF_8);
}
@Test
public void testEscapedBackSlash() throws IOException {
// See https://github.com/pmd/pmd/issues/1751
final String filename = "issue1751.go";
final GoTokenizer tokenizer = new GoTokenizer();
final SourceCode sourceCode = new SourceCode(new SourceCode.StringCodeLoader(getSampleCode(filename), filename));
final Tokens tokens = new Tokens();
tokenizer.tokenize(sourceCode, tokens); // it should simply not fail
}
}

View File

@@ -0,0 +1,6 @@
func test(in *Value, param *Value) (*Value, *Error) {
output := strings.Replace(in.String(), "\\", "\\\\", -1)
output = strings.Replace(output, "\"", "\\\"", -1)
output = strings.Replace(output, "'", "\\'", -1)
return AsValue(output), nil
}