Skip to content

Commit

Permalink
Add tests for metadata in all locations, cf. grammar
Browse files Browse the repository at this point in the history
Change-Id: Ibaa2bcd014257c6ec7c756d352e55d48f8a4a902
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167801
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
  • Loading branch information
eernstg authored and commit-bot@chromium.org committed Oct 16, 2020
1 parent 1e5f4ec commit 016ebdd
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/language/metadata/metadata_location_part.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@m
part of 'metadata_location_test.dart';
122 changes: 122 additions & 0 deletions tests/language/metadata/metadata_location_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// Test that metadata can be located everywhere the grammar specifies that
// it can occur, with a few variants especially for parameter locations.

@m
library metadata.location.test;

@m
import 'dart:async';

@m
export 'dart:async';

@m
part 'metadata_location_part.dart';

@m
const m = 0;

@m
void f1(@m p1, @m int p2, [@m p3, @m int? p4]) {}

@m
void f2({@m p1, @m int? p2}) {}

@m
void f3(@m p1(), @m int p2()) {}

@m
class C {
@m
var x, y, z, w;

@m
covariant var u, v;

@m
C(@m this.x, @m int this.y,
{@m this.z, @m int? this.w, @m this.u()?, @m int this.v()?});

@m
void f1(@m p1, @m int p2, [@m p3, @m int? p4]) {}

@m
void f2({@m p1, @m int? p2}) {}

@m
void f3(@m covariant p1, @m covariant int p2,
[@m covariant p3, @m covariant int? p4]) {}

@m
void f4({@m covariant p1, @m covariant int? p2}) {}

@m
int get prop => 0;

@m
set prop(int _) {}

@m
bool operator ==(other) => true;
}

@m
mixin M {
@m
var x, y, z, w, u, v;

@m
void f1(@m p1, @m int p2, [@m p3, @m int p4 = 0]) {}

@m
void f2({@m p1, @m int p2 = 0}) {}

@m
void f3(@m covariant p1, @m covariant int p2,
[@m covariant p3, @m covariant int p4 = 0]) {}

@m
void f4({@m covariant p1, @m covariant int p2 = 0}) {}
}

@m
extension Extension on int {
@m
void f1(@m p1, @m int p2, [@m p3, @m int p4 = 0]) {}

@m
void f2({@m p1, @m int p2 = 0}) {}
}

@m
enum E {
@m
one,
@m
two,
}

void f<@m X>() {}

class D<@m X> {}

@m
typedef void F<@m X>();

void main() {
@m
var x;

@m
void f() {}

for (@m
int i = 0;
i < 1;
i++) {}
for (@m int i in []) {}
}

0 comments on commit 016ebdd

Please sign in to comment.