mirror of
https://github.com/revanced/smali.git
synced 2025-05-25 18:42:07 +02:00
Fix newline issue for smali tests on Windows
This commit is contained in:
parent
a8be1b4c80
commit
097b40531b
@ -30,7 +30,6 @@ import org.antlr.runtime.ANTLRInputStream;
|
||||
import org.antlr.runtime.CommonToken;
|
||||
import org.antlr.runtime.CommonTokenStream;
|
||||
import org.antlr.runtime.RecognitionException;
|
||||
import org.jf.dexlib.Util.Utf8Utils;
|
||||
import org.jf.smali.*;
|
||||
import static org.jf.smali.expectedTokensTestGrammarParser.ExpectedToken;
|
||||
import org.junit.Assert;
|
||||
@ -43,12 +42,21 @@ import java.util.List;
|
||||
public class LexerTest {
|
||||
private static final HashMap<String, Integer> tokenTypesByName;
|
||||
|
||||
private static final String newlineReplacement;
|
||||
|
||||
static {
|
||||
tokenTypesByName = new HashMap<String, Integer>();
|
||||
|
||||
for (int i=0; i<smaliParser.tokenNames.length; i++) {
|
||||
tokenTypesByName.put(smaliParser.tokenNames[i], i);
|
||||
}
|
||||
|
||||
String newLine = System.getProperty("line.separator");
|
||||
if (!"\n".equals(newLine)) {
|
||||
newlineReplacement = newLine;
|
||||
} else {
|
||||
newlineReplacement = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -190,9 +198,13 @@ public class LexerTest {
|
||||
}
|
||||
|
||||
if (expectedToken.tokenText != null) {
|
||||
if (!expectedToken.tokenText.equals(token.getText())) {
|
||||
Assert.fail(
|
||||
String.format("Invalid token text at index %d. Expecting text \"%s\", got \"%s\"",
|
||||
String expectedTokenText = expectedToken.tokenText;
|
||||
if (newlineReplacement != null) {
|
||||
expectedTokenText = expectedTokenText.replace("\n", newlineReplacement);
|
||||
}
|
||||
|
||||
if (!expectedTokenText.equals(token.getText())) {
|
||||
Assert.fail(String.format("Invalid token text at index %d. Expecting text \"%s\", got \"%s\"",
|
||||
expectedTokenIndex - 1, expectedToken.tokenText, token.getText()));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user