Moved more tests into java.g and improved some tests.

This commit is contained in:
Oliver Burn 2002-01-13 07:52:23 +00:00
parent 3335cdeb4d
commit 8d1cba0676
4 changed files with 33 additions and 18 deletions

View File

@ -813,10 +813,10 @@ multiplicativeExpression
;
unaryExpression
: INC^ unaryExpression
| DEC^ unaryExpression
| MINUS^ {#MINUS.setType(UNARY_MINUS);} unaryExpression
| PLUS^ {#PLUS.setType(UNARY_PLUS);} unaryExpression
: INC^ unaryExpression {ver.verifyNoWSAfter(#INC);}
| DEC^ unaryExpression {ver.verifyNoWSAfter(#DEC);}
| MINUS^ {#MINUS.setType(UNARY_MINUS); ver.verifyNoWSAfter(#MINUS);} unaryExpression
| PLUS^ {#PLUS.setType(UNARY_PLUS); ver.verifyNoWSAfter(#PLUS);} unaryExpression
| unaryExpressionNotPlusMinus
;
@ -882,8 +882,8 @@ postfixExpression
// possibly add on a post-increment or post-decrement.
// allows INC/DEC on too much, but semantics can check
( in:INC^ {#in.setType(POST_INC);}
| de:DEC^ {#de.setType(POST_DEC);}
( in:INC^ {#in.setType(POST_INC); ver.verifyNoWSBefore(#in);}
| de:DEC^ {#de.setType(POST_DEC); ver.verifyNoWSBefore(#de);}
| // nothing
)
;
@ -1044,10 +1044,10 @@ DIV : '/' {ver.verifyWSAroundEnd(getLine(), getColumn(), "/");} ;
DIV_ASSIGN : "/=" {ver.verifyWSAroundEnd(getLine(), getColumn(), "/=");};
PLUS : '+'; // must handle the UNARY_PLUS
PLUS_ASSIGN : "+=" {ver.verifyWSAroundEnd(getLine(), getColumn(), "+=");};
INC : "++" ;
INC : "++" ; // must handle POST_INC
MINUS : '-' ; // must handle the UNARY_MINUS
MINUS_ASSIGN : "-=" {ver.verifyWSAroundEnd(getLine(), getColumn(), "-=");};
DEC : "--" ;
DEC : "--" ; // must handle POST_DEC
STAR : '*' ; // star is special cause it can be used in imports.
STAR_ASSIGN : "*=" {ver.verifyWSAroundEnd(getLine(), getColumn(), "*=");};
MOD : '%' {ver.verifyWSAroundEnd(getLine(), getColumn(), "%");} ;

View File

@ -389,15 +389,15 @@ expr
| #(DIV expr expr)
| #(MOD expr expr)
| #(STAR expr expr)
| #(INC expr) { ver.verifyNoWSAfter(#INC); }
| #(DEC expr) { ver.verifyNoWSAfter(#DEC); }
| #(POST_INC expr) { ver.verifyNoWSBefore(#POST_INC); }
| #(POST_DEC expr) { ver.verifyNoWSBefore(#POST_DEC); }
| #(INC expr)
| #(DEC expr)
| #(POST_INC expr)
| #(POST_DEC expr)
| #(BNOT expr) { ver.verifyNoWSAfter(#BNOT); }
| #(LNOT expr) { ver.verifyNoWSAfter(#LNOT); }
| #("instanceof" expr expr) // Java ensures surrounded by WS!
| #(UNARY_MINUS expr) { ver.verifyNoWSAfter(#UNARY_MINUS); }
| #(UNARY_PLUS expr) { ver.verifyNoWSAfter(#UNARY_PLUS); }
| #(UNARY_MINUS expr)
| #(UNARY_PLUS expr)
| primaryExpression
;
@ -454,7 +454,7 @@ constant
newExpression
: #( "new" type
( newArrayDeclarator (arrayInitializer)?
| elist ({ver.reportStartTypeBlock(Scope.ANONINNER, false);} objBlock {ver.reportEndTypeBlock();})?
| elist ( objBlock )?
)
)

View File

@ -98,8 +98,11 @@ public class CheckerTest
filepath + ":26: '+=' is not proceeded with whitespace.",
filepath + ":27: '-=' is not proceeded with whitespace.",
filepath + ":27: '-' is proceeded with whitespace.",
filepath + ":27: '+' is proceeded with whitespace.",
filepath + ":28: '++' is preceeded with whitespace.",
filepath + ":28: '--' is preceeded with whitespace.",
filepath + ":29: '++' is proceeded with whitespace.",
filepath + ":29: '--' is proceeded with whitespace.",
filepath + ":35: 'synchronized' is not proceeded with whitespace.",
filepath + ":37: 'try' is not proceeded with whitespace.",
filepath + ":39: 'catch' is not proceeded with whitespace.",
@ -114,6 +117,7 @@ public class CheckerTest
filepath + ":96: '==' is not proceeded with whitespace.",
filepath + ":102: '*' is not proceeded with whitespace.",
filepath + ":102: '*' is not preceeded with whitespace.",
filepath + ":109: '!' is proceeded with whitespace.",
};
verify(c, filepath, expected);
}
@ -137,8 +141,11 @@ public class CheckerTest
filepath + ":26: '+=' is not proceeded with whitespace.",
filepath + ":27: '-=' is not proceeded with whitespace.",
filepath + ":27: '-' is proceeded with whitespace.",
filepath + ":27: '+' is proceeded with whitespace.",
filepath + ":28: '++' is preceeded with whitespace.",
filepath + ":28: '--' is preceeded with whitespace.",
filepath + ":29: '++' is proceeded with whitespace.",
filepath + ":29: '--' is proceeded with whitespace.",
filepath + ":35: 'synchronized' is not proceeded with whitespace.",
filepath + ":37: 'try' is not proceeded with whitespace.",
filepath + ":39: 'catch' is not proceeded with whitespace.",
@ -152,6 +159,7 @@ public class CheckerTest
filepath + ":96: '==' is not proceeded with whitespace.",
filepath + ":102: '*' is not proceeded with whitespace.",
filepath + ":102: '*' is not preceeded with whitespace.",
filepath + ":109: '!' is proceeded with whitespace.",
};
verify(c, filepath, expected);
}

View File

@ -24,9 +24,9 @@ class InputWhitespace
int b= 1; // Ignore 1
b=1; // Ignore 1
b+=1; // Ignore 1
b -=- 1; // Ignore 2
b = b ++; // Ignore 1
b = ++ b; // Ignore 1
b -=- 1 + (+ b); // Ignore 2
b = b ++ + b --; // Ignore 1
b = ++ b - -- b; // Ignore 1
}
/** method **/
@ -101,4 +101,11 @@ class InputWhitespace
{
int x = 2 *3* 4;
}
/** boolean test **/
private void boolTest()
{
boolean a = true;
boolean x = ! a;
}
}