Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Unified Diff: pkg/kernel/test/verify_test.dart

Issue 2533793005: Check that invocations have well-formed targets in kernel verifier. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/kernel/lib/verifier.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/kernel/test/verify_test.dart
diff --git a/pkg/kernel/test/verify_test.dart b/pkg/kernel/test/verify_test.dart
index e9f03b94caa43e7f25bcadd6e3ccc6e92b92ac9f..11f54f97ac38ab2d4d5f41ad7823dc44016797ce 100644
--- a/pkg/kernel/test/verify_test.dart
+++ b/pkg/kernel/test/verify_test.dart
@@ -125,6 +125,86 @@ main() {
procedure.function = new FunctionNode(new EmptyStatement());
return procedure;
});
+ negativeTest('StaticGet without target', () {
+ return new StaticGet(null);
+ });
+ negativeTest('StaticSet without target', () {
+ return new StaticSet(null, new NullLiteral());
+ });
+ negativeTest('StaticInvocation without target', () {
+ return new StaticInvocation(null, new Arguments.empty());
+ });
+ positiveTest('Correct StaticInvocation', () {
+ var method = new Procedure(new Name('test'), ProcedureKind.Method, null,
+ isStatic: true);
+ method.function = new FunctionNode(
+ new ReturnStatement(
+ new StaticInvocation(method, new Arguments([new NullLiteral()]))),
+ positionalParameters: [new VariableDeclaration('p')])..parent = method;
+ return new Class(
+ name: 'Test',
+ supertype: objectClass.asRawSupertype,
+ procedures: [method]);
+ });
+ negativeTest('StaticInvocation with too many parameters', () {
+ var method = new Procedure(new Name('test'), ProcedureKind.Method, null,
+ isStatic: true);
+ method.function = new FunctionNode(new ReturnStatement(
+ new StaticInvocation(method, new Arguments([new NullLiteral()]))))
+ ..parent = method;
+ return new Class(
+ name: 'Test',
+ supertype: objectClass.asRawSupertype,
+ procedures: [method]);
+ });
+ negativeTest('StaticInvocation with too few parameters', () {
+ var method = new Procedure(new Name('test'), ProcedureKind.Method, null,
+ isStatic: true);
+ method.function = new FunctionNode(
+ new ReturnStatement(
+ new StaticInvocation(method, new Arguments.empty())),
+ positionalParameters: [new VariableDeclaration('p')])..parent = method;
+ return new Class(
+ name: 'Test',
+ supertype: objectClass.asRawSupertype,
+ procedures: [method]);
+ });
+ negativeTest('StaticInvocation with unmatched named parameter', () {
+ var method = new Procedure(new Name('test'), ProcedureKind.Method, null,
+ isStatic: true);
+ method.function = new FunctionNode(new ReturnStatement(new StaticInvocation(
+ method,
+ new Arguments([],
+ named: [new NamedExpression('p', new NullLiteral())]))))
+ ..parent = method;
+ return new Class(
+ name: 'Test',
+ supertype: objectClass.asRawSupertype,
+ procedures: [method]);
+ });
+ negativeTest('StaticInvocation with missing type argument', () {
+ var method = new Procedure(new Name('test'), ProcedureKind.Method, null,
+ isStatic: true);
+ method.function = new FunctionNode(
+ new ReturnStatement(
+ new StaticInvocation(method, new Arguments.empty())),
+ typeParameters: [makeTypeParameter()])..parent = method;
+ return new Class(
+ name: 'Test',
+ supertype: objectClass.asRawSupertype,
+ procedures: [method]);
+ });
+ negativeTest('ConstructorInvocation with missing type argument', () {
+ var constructor = new Constructor(null);
+ constructor.function = new FunctionNode(new ReturnStatement(
+ new ConstructorInvocation(constructor, new Arguments.empty())))
+ ..parent = constructor;
+ return new Class(
+ name: 'Test',
+ typeParameters: [makeTypeParameter()],
+ supertype: objectClass.asRawSupertype,
+ constructors: [constructor]);
+ });
}
checkHasError(Program program) {
« no previous file with comments | « pkg/kernel/lib/verifier.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698