Skip to content

Commit

Permalink
#2559. Add tests for augment libraries errors (#2562)
Browse files Browse the repository at this point in the history
Add tests for augment libraries errors
  • Loading branch information
sgrekhov committed Mar 11, 2024
1 parent 19d7957 commit 4f0e690
Show file tree
Hide file tree
Showing 11 changed files with 399 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright (c) 2024, 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.

/// @assertion It is a compile-time error if:
/// - A top-level declaration in an augmentation has the same name as a
/// declaration in the main library or another of its augmentations (unless it
/// is an augmenting declaration)
///
/// @description Checks that it is a compile-time error if a top-level
/// declaration in an augmentation has the same name as a declaration in the
/// main library.
/// @author sgrekhov22@gmail.com
/// @issue 55113
// SharedOptions=--enable-experiment=macros

import augment 'defining_augmentation_A03_t01_lib.dart';

class C {}

mixin M {}

enum E {e;}

void foo() {}

typedef void Foo();

typedef StringAlias = String;

int get getter => 42;

void set setter(int _) {}

extension Ext on List {}

extension type ET(int _) {}

var x = 0;

const c = 0;

main() {
print(C);
print(M);
print(E);
print(foo);
print(Foo);
print(StringAlias);
print(getter);
setter = 1;
print(List);
print(ET);
print(x);
print(c);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// Copyright (c) 2024, 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.

/// @assertion It is a compile-time error if:
/// - A top-level declaration in an augmentation has the same name as a
/// declaration in the main library or another of its augmentations (unless it
/// is an augmenting declaration)
///
/// @description Checks that it is a compile-time error if a top-level
/// declaration in an augmentation has the same name as a declaration in the
/// main library.
/// @author sgrekhov22@gmail.com
/// @issue 55113
// SharedOptions=--enable-experiment=macros

library augment 'defining_augmentation_A03_t01.dart';

class C {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

mixin M {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

enum E {e;}
// ^
// [analyzer] unspecified
// [cfe] unspecified

void foo() {}
// ^^^
// [analyzer] unspecified
// [cfe] unspecified

typedef void Foo();
// ^^^
// [analyzer] unspecified
// [cfe] unspecified

typedef StringAlias = String;
// ^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

int get getter => 42;
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

void set setter(int _) {}
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

extension Ext on List {}
// ^^^
// [analyzer] unspecified
// [cfe] unspecified

extension type ET(int _) {}
// ^^
// [analyzer] unspecified
// [cfe] unspecified

var x = 0;
// ^
// [analyzer] unspecified
// [cfe] unspecified

const c = 0;
// ^
// [analyzer] unspecified
// [cfe] unspecified
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) 2024, 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.

/// @assertion It is a compile-time error if:
/// - A top-level declaration in an augmentation has the same name as a
/// declaration in the main library or another of its augmentations (unless it
/// is an augmenting declaration)
///
/// @description Checks that it is a compile-time error if a top-level
/// declaration in an augmentation has the same name as a declaration in another
/// augmentation of the same library.
/// @author sgrekhov22@gmail.com
/// @issue 55113
// SharedOptions=--enable-experiment=macros

import augment 'defining_augmentation_A03_t03_lib1.dart';
import augment 'defining_augmentation_A03_t03_lib2.dart';

main() {
print(C);
print(M);
print(E);
print(foo);
print(Foo);
print(StringAlias);
print(getter);
setter = 1;
print(List);
print(ET);
print(x);
print(c);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright (c) 2024, 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.

/// @assertion It is a compile-time error if:
/// - A top-level declaration in an augmentation has the same name as a
/// declaration in the main library or another of its augmentations (unless it
/// is an augmenting declaration)
///
/// @description Checks that it is a compile-time error if a top-level
/// declaration in an augmentation has the same name as a declaration in another
/// augmentation of the same library.
/// @author sgrekhov22@gmail.com
/// @issue 55113
// SharedOptions=--enable-experiment=macros

library augment 'defining_augmentation_A03_t03.dart';

class C {}

mixin M {}

enum E {e;}

void foo() {}

typedef void Foo();

typedef StringAlias = String;

int get getter => 42;

void set setter(int _) {}

extension Ext on List {}

extension type ET(int _) {}

var x = 0;

const c = 0;
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// Copyright (c) 2024, 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.

/// @assertion It is a compile-time error if:
/// - A top-level declaration in an augmentation has the same name as a
/// declaration in the main library or another of its augmentations (unless it
/// is an augmenting declaration)
///
/// @description Checks that it is a compile-time error if a top-level
/// declaration in an augmentation has the same name as a declaration in another
/// augmentation of the same library.
/// @author sgrekhov22@gmail.com
/// @issue 55113
// SharedOptions=--enable-experiment=macros

library augment 'defining_augmentation_A03_t03.dart';

class C {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

mixin M {}
// ^
// [analyzer] unspecified
// [cfe] unspecified

enum E {e;}
// ^
// [analyzer] unspecified
// [cfe] unspecified

void foo() {}
// ^^^
// [analyzer] unspecified
// [cfe] unspecified

typedef void Foo();
// ^^^
// [analyzer] unspecified
// [cfe] unspecified

typedef StringAlias = String;
// ^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

int get getter => 42;
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

void set setter(int _) {}
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

extension Ext on List {}
// ^^^
// [analyzer] unspecified
// [cfe] unspecified

extension type ET(int _) {}
// ^^
// [analyzer] unspecified
// [cfe] unspecified

var x = 0;
// ^
// [analyzer] unspecified
// [cfe] unspecified

const c = 0;
// ^
// [analyzer] unspecified
// [cfe] unspecified
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) 2024, 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.

/// @assertion It is a compile-time error if:
/// ...
/// - An augmentation library contains any part directives.
///
/// @description Checks that it is a compile-time error if an augmentation
/// library contains any part directives.
/// @author sgrekhov22@gmail.com
/// @issue 55116
// SharedOptions=--enable-experiment=macros

import augment 'defining_augmentation_A04_t01_lib.dart';

main() {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) 2024, 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.

/// @assertion It is a compile-time error if:
/// ...
/// - An augmentation library contains any part directives.
///
/// @description Checks that it is a compile-time error if an augmentation
/// library contains any part directives.
/// @author sgrekhov22@gmail.com
/// @issue 55116
// SharedOptions=--enable-experiment=macros

library augment 'defining_augmentation_A04_t01.dart';

/**/part 'defining_augmentation_A04_t01_part.dart';
// ^^^^
// [analyzer] unspecified
// [cfe] unspecified
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) 2024, 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.

/// @assertion It is a compile-time error if:
/// ...
/// - An augmentation library contains any part directives.
///
/// @description Checks that it is a compile-time error if an augmentation
/// library contains any part directives.
/// @author sgrekhov22@gmail.com
/// @issue 55116
// SharedOptions=--enable-experiment=macros

part of 'defining_augmentation_A04_t01_lib.dart';
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) 2024, 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.

/// @assertion It is a compile-time error if:
/// ...
/// - An augmentation library contains any part directives.
///
/// @description Checks that it is no error if a library that has an
/// augmentation contains a part directive.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros

import augment 'defining_augmentation_A04_t02_lib.dart';
import '../../Utils/expect.dart';

part 'defining_augmentation_A04_t02_part.dart';

main() {
Expect.equals("x", x);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) 2024, 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.

/// @assertion It is a compile-time error if:
/// ...
/// - An augmentation library contains any part directives.
///
/// @description Checks that it is no error if a library that has an
/// augmentation contains a part directive.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros

library augment 'defining_augmentation_A04_t02.dart';

0 comments on commit 4f0e690

Please sign in to comment.