use of java.io.CharArrayReader in project ceylon-compiler by ceylon.
the class JavaPositionsRetriever method addCeylonLinesComments.
private String addCeylonLinesComments(char[] source) {
String annotatedSourceCode = "";
BufferedReader reader = new BufferedReader(new CharArrayReader(source));
String line = null;
int javaLine = 1;
try {
while ((line = reader.readLine()) != null) {
annotatedSourceCode += line;
String ceylonLines = getCeylonLinesForJavaLine(revertMap(ceylonToJavaLines), javaLine);
annotatedSourceCode += ceylonLines.isEmpty() ? "" : " // line " + ceylonLines;
annotatedSourceCode += "\n";
javaLine++;
}
} catch (IOException e) {
e.printStackTrace();
}
return annotatedSourceCode;
}
use of java.io.CharArrayReader in project j2objc by google.
the class OldCharArrayReaderTest method test_markI.
/**
* java.io.CharArrayReader#mark(int)
*/
public void test_markI() throws IOException {
cr = new CharArrayReader(hw);
cr.skip(5L);
cr.mark(100);
cr.read();
cr.reset();
assertEquals("Test 1: Failed to mark correct position;", 'W', cr.read());
cr.close();
try {
cr.mark(100);
fail("Test 2: IOException expected.");
} catch (IOException e) {
// Expected.
}
}
use of java.io.CharArrayReader in project j2objc by google.
the class OldCharArrayReaderTest method test_markSupported.
/**
* java.io.CharArrayReader#markSupported()
*/
public void test_markSupported() {
cr = new CharArrayReader(hw);
assertTrue("markSupported returned false", cr.markSupported());
}
use of java.io.CharArrayReader in project j2objc by google.
the class OldCharArrayReaderTest method test_read$CII.
/**
* java.io.CharArrayReader#read(char[], int, int)
*/
public void test_read$CII() throws IOException {
// Test for method int java.io.CharArrayReader.read(char [], int, int)
char[] c = new char[11];
cr = new CharArrayReader(hw);
cr.read(c, 1, 10);
assertTrue("Test 1: Read returned incorrect chars.", new String(c, 1, 10).equals(new String(hw, 0, 10)));
// Illegal argument checks.
try {
cr.read(null, 1, 0);
fail("Test 2: NullPointerException expected.");
} catch (NullPointerException e) {
// Expected.
}
try {
cr.read(c, -1, 1);
fail("Test 3: ArrayIndexOutOfBoundsException expected.");
} catch (IndexOutOfBoundsException e) {
// Expected
}
try {
cr.read(c, 1, -1);
fail("Test 4: ArrayIndexOutOfBoundsException expected.");
} catch (IndexOutOfBoundsException e) {
// Expected
}
try {
cr.read(c, 1, c.length);
fail("Test 5: ArrayIndexOutOfBoundsException expected.");
} catch (IndexOutOfBoundsException e) {
// Expected
}
cr.close();
try {
cr.read(c, 1, 1);
fail("Test 6: IOException expected.");
} catch (IOException e) {
// Expected.
}
}
use of java.io.CharArrayReader in project j2objc by google.
the class OldCharArrayReaderTest method test_Constructor$CII.
/**
* java.io.CharArrayReader#CharArrayReader(char[], int, int)
*/
public void test_Constructor$CII() throws IOException {
try {
cr = new CharArrayReader(null, 0, 0);
fail("Test 1: NullPointerException expected.");
} catch (NullPointerException e) {
// Expected.
}
try {
cr = new CharArrayReader(hw, -1, 0);
fail("Test 2: IllegalArgumentException expected.");
} catch (IllegalArgumentException e) {
// Expected.
}
try {
cr = new CharArrayReader(hw, 0, -1);
fail("Test 3: IllegalArgumentException expected.");
} catch (IllegalArgumentException e) {
// Expected.
}
try {
cr = new CharArrayReader(hw, hw.length + 1, 1);
fail("Test 4: IllegalArgumentException expected.");
} catch (IllegalArgumentException e) {
// Expected.
}
cr = new CharArrayReader(hw, 5, 5);
assertTrue("Test 5: Failed to create reader", cr.ready());
assertEquals("Test 6: Incorrect character read;", 'W', cr.read());
}
Aggregations