diff --git a/tool/test/org/antlr/v4/test/BaseTest.java b/tool/test/org/antlr/v4/test/BaseTest.java index 50d6afe35..850d9a040 100644 --- a/tool/test/org/antlr/v4/test/BaseTest.java +++ b/tool/test/org/antlr/v4/test/BaseTest.java @@ -335,6 +335,33 @@ public abstract class BaseTest { return null; } + protected String load(String fileName, @Nullable String encoding) + throws IOException + { + if ( fileName==null ) { + return null; + } + + String fullFileName = getClass().getPackage().getName().replace('.', '/') + '/' + fileName; + int size = 65000; + InputStreamReader isr; + InputStream fis = getClass().getClassLoader().getResourceAsStream(fullFileName); + if ( encoding!=null ) { + isr = new InputStreamReader(fis, encoding); + } + else { + isr = new InputStreamReader(fis); + } + try { + char[] data = new char[size]; + int n = isr.read(data); + return new String(data, 0, n); + } + finally { + isr.close(); + } + } + /** Wow! much faster than compiling outside of VM. Finicky though. * Had rules called r and modulo. Wouldn't compile til I changed to 'a'. */ diff --git a/tool/test/org/antlr/v4/test/TestLexerExec.java b/tool/test/org/antlr/v4/test/TestLexerExec.java index 5dccd3433..32aee67ba 100644 --- a/tool/test/org/antlr/v4/test/TestLexerExec.java +++ b/tool/test/org/antlr/v4/test/TestLexerExec.java @@ -657,31 +657,4 @@ public class TestLexerExec extends BaseTest { "[@1,5:4='',<-1>,1:5]\n"; assertEquals(expecting, found); } - - protected String load(String fileName, @Nullable String encoding) - throws IOException - { - if ( fileName==null ) { - return null; - } - - String fullFileName = getClass().getPackage().getName().replace('.', '/') + '/' + fileName; - int size = 65000; - InputStreamReader isr; - InputStream fis = getClass().getClassLoader().getResourceAsStream(fullFileName); - if ( encoding!=null ) { - isr = new InputStreamReader(fis, encoding); - } - else { - isr = new InputStreamReader(fis); - } - try { - char[] data = new char[size]; - int n = isr.read(data); - return new String(data, 0, n); - } - finally { - isr.close(); - } - } } diff --git a/tool/test/org/antlr/v4/test/TestPerformance.java b/tool/test/org/antlr/v4/test/TestPerformance.java index 4e1cf1671..e24e1487b 100644 --- a/tool/test/org/antlr/v4/test/TestPerformance.java +++ b/tool/test/org/antlr/v4/test/TestPerformance.java @@ -1134,33 +1134,6 @@ public class TestPerformance extends BaseTest { assertTrue(success); } - protected String load(String fileName, @Nullable String encoding) - throws IOException - { - if ( fileName==null ) { - return null; - } - - String fullFileName = getClass().getPackage().getName().replace('.', '/') + '/' + fileName; - int size = 65000; - InputStreamReader isr; - InputStream fis = getClass().getClassLoader().getResourceAsStream(fullFileName); - if ( encoding!=null ) { - isr = new InputStreamReader(fis, encoding); - } - else { - isr = new InputStreamReader(fis); - } - try { - char[] data = new char[size]; - int n = isr.read(data); - return new String(data, 0, n); - } - finally { - isr.close(); - } - } - private static void updateChecksum(Checksum checksum, int value) { checksum.update((value) & 0xFF); checksum.update((value >>> 8) & 0xFF);