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