diff options
Diffstat (limited to 'javatests/com/google/turbine/parse/LexerTest.java')
-rw-r--r-- | javatests/com/google/turbine/parse/LexerTest.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/javatests/com/google/turbine/parse/LexerTest.java b/javatests/com/google/turbine/parse/LexerTest.java index c3d7804..bf0b374 100644 --- a/javatests/com/google/turbine/parse/LexerTest.java +++ b/javatests/com/google/turbine/parse/LexerTest.java @@ -17,11 +17,15 @@ package com.google.turbine.parse; import static com.google.common.truth.Truth.assertThat; +import static org.junit.Assume.assumeTrue; import com.google.common.escape.SourceCodeEscapers; +import com.google.common.truth.Expect; import com.google.turbine.diag.SourceFile; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; +import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -29,6 +33,8 @@ import org.junit.runners.JUnit4; @RunWith(JUnit4.class) public class LexerTest { + @Rule public final Expect expect = Expect.create(); + @Test public void testSimple() { assertThat(lex("\nasd dsa\n")).containsExactly("IDENT(asd)", "IDENT(dsa)", "EOF"); @@ -367,4 +373,25 @@ public class LexerTest { } while (token != Token.EOF); return tokens; } + + @Test + public void stripIndent() throws Exception { + assumeTrue(Runtime.version().feature() >= 13); + String[] inputs = { + "", + "hello", + "hello\n", + "\nhello", + "\n hello\n world", + "\n hello\n world\n ", + "\n hello\n world\n", + "\n hello\n world\n ", + "\n hello\nworld", + "\n hello\n \nworld\n ", + }; + Method stripIndent = String.class.getMethod("stripIndent"); + for (String input : inputs) { + expect.that(StreamLexer.stripIndent(input)).isEqualTo(stripIndent.invoke(input)); + } + } } |