Skip to content

Commit

Permalink
Chanage error format.
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlesZ-Chen committed Nov 21, 2017
1 parent 987ba91 commit e10ecab
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions tests/binaryOpRefine/BinaryOpRefinement.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void testLessThan(Reader in) throws IOException {
if (buff < 0) {
;
}
//:: error: (cast.unsafe)
// :: error: (cast.unsafe)
cur = (char) buff;
} while (true);
}
Expand All @@ -30,7 +30,7 @@ void testGreaterThanOrEqual(Reader in) throws IOException {
}

while ((buff = in.read()) > 0) {
//:: error: (cast.unsafe)
// :: error: (cast.unsafe)
cur = (char) buff; // this is because although the casting is safe,
// 0x00 byte or 0x0000 char is still missed

Expand Down Expand Up @@ -58,7 +58,7 @@ void testEqualTo(Reader in) throws IOException {
if (buff == -1) {
;
}
//:: error: (cast.unsafe)
// :: error: (cast.unsafe)
cur = (char) buff;
} while (true);
}
Expand Down
16 changes: 8 additions & 8 deletions tests/casting/ErrorCasting.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,31 @@ public class ErrorCasting {
public void readCharMethod(@UnsafeRead int unsafeReadBuff, int unknownInt) {
int bar = unknownInt = unsafeReadBuff;

//:: error: (cast.unsafe)
// :: error: (cast.unsafe)
char unSafeChar_1 = (char) bar;
//:: error: (cast.unsafe)
// :: error: (cast.unsafe)
byte unsafeByte_1 = (byte) bar;

int foo = unsafeReadBuff = unsafeReadBuff;
//:: error: (cast.unsafe)
// :: error: (cast.unsafe)
char unSafeChar_2 = (char) foo;
//:: error: (cast.unsafe)
// :: error: (cast.unsafe)
byte unsafeByte_2 = (byte) foo;
}

@SuppressWarnings("unused")
public void postPreIncrementDecrement(@UnsafeRead int inbuff, int unknownInt) {
//:: error: (cast.unsafe)
// :: error: (cast.unsafe)
char unknownSafetyChar_1 = (char) (inbuff++); // postIncrement would return original value of inbuff, unsafe
char unknownSafetyChar_2 = (char) (++inbuff); // Should cast up to UnknownSafety, OK
//:: error: (cast.unsafe)
// :: error: (cast.unsafe)
char unknownSafetyChar_3 = (char) (inbuff--); // postDecrement would return original value of inbuff, unsafe
char unknownSafetyChar_4 = (char) (--inbuff); // Should cast up to UnknownSafety, OK

//:: error: (cast.unsafe)
// :: error: (cast.unsafe)
byte unknownSafetyByte_1 = (byte) (inbuff++); // postIncrement would return original value of inbuff, unsafe
byte unknownSafetyByte_2 = (byte) (++inbuff); // Should cast up to UnknownSafety, OK
//:: error: (cast.unsafe)
// :: error: (cast.unsafe)
byte unknownSafetyByte_3 = (byte) (inbuff--); // postDecrement would return original value of inbuff, unsafe
byte unknownSafetyByte_4 = (byte) (--inbuff); // Should cast up to UnknownSafety, OK
}
Expand Down
2 changes: 1 addition & 1 deletion tests/noc-examples/NOCE4InputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public void unsafeWayOfCasting() throws IOException {
InputStream in = new FileInputStream("afile");
@SuppressWarnings("unused")
byte data;
//:: error: (cast.unsafe)
// :: error: (cast.unsafe)
while ((data = (byte) in.read()) != -1) {
//...
}
Expand Down
2 changes: 1 addition & 1 deletion tests/noc-examples/NOCE4Reader.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public void unsafeWayOfCasting() throws IOException {
Reader in = new FileReader("afile");
@SuppressWarnings("unused")
char data;
//:: error: (cast.unsafe)
// :: error: (cast.unsafe)
while ((data = (char) in.read()) != -1) {
//...
}
Expand Down
8 changes: 4 additions & 4 deletions tests/read-typeHierarchy/TypeHierarchy.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ public class TypeHierarchy {

void testMethod(int i, @UnsafeRead int unsafeRead, @SafeRead int safeRead, @SafetyBottom int safetyBottom) {

//:: error: (assignment.type.incompatible)
// :: error: (assignment.type.incompatible)
unsafeRead = i; // ERROR: violate type rule UnsafeRead <: UnknownSafety

//:: error: (assignment.type.incompatible)
// :: error: (assignment.type.incompatible)
safeRead = unsafeRead; // ERROR: violate type rule SafeRead <: UnsafeRead

//:: error: (assignment.type.incompatible)
// :: error: (assignment.type.incompatible)
safetyBottom = safeRead; // ERROR: violate type rule SafetyBottom <: SafeRead

//:: error: (assignment.type.incompatible)
// :: error: (assignment.type.incompatible)
safetyBottom = 1; // ERROR: violate type rule SafetyBottom <: UnknownSafetyLiterals

int a = unsafeRead; // OK: UnsafeRead <: UnknownSafety
Expand Down
4 changes: 2 additions & 2 deletions tests/teamed-quiz/BadParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public String getContent() throws IOException {
String output = "";
int data;
while ((data = i.read()) > 0) {
//:: error: (cast.unsafe)
// :: error: (cast.unsafe)
output += (char) data;
}
return output;
Expand All @@ -30,7 +30,7 @@ public String getContentWithoutUnicode() throws IOException {
int data;
while ((data = i.read()) > 0) {
if (data < 0x80) {
//:: error: (cast.unsafe)
// :: error: (cast.unsafe)
output += (char) data;
}
}
Expand Down
8 changes: 4 additions & 4 deletions tests/wtfCodeSOD061102/WTFCodeSOD061102.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ public void test(boolean _validConnection, InputStream _inputStream) throws IOEx
while (true) {
char _char;
_stringBuffer.append(
//:: error: (cast.unsafe)
// :: error: (cast.unsafe)
_char = (char)_inputStream.read());
if (_char == -1) {
break;
} else if (_char == '\r') {
_stringBuffer.append(
//:: error: (cast.unsafe)
// :: error: (cast.unsafe)
_char = (char)_inputStream.read());
if (_char == -1) {
break;
} else if (_char == '\n') {
_stringBuffer.append(
//:: error: (cast.unsafe)
// :: error: (cast.unsafe)
_char = (char)_inputStream.read());
if (_char == -1) {
break;
} else if (_char == '\r') {
_stringBuffer.append(
//:: error: (cast.unsafe)
// :: error: (cast.unsafe)
_char = (char)_inputStream.read());
if (_char == -1) {
break;
Expand Down

0 comments on commit e10ecab

Please sign in to comment.