Skip to content

Commit

Permalink
dart-lang#2559. Add tests for augment libraries errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrekhov committed Mar 6, 2024
1 parent 6f34e53 commit 804c45b
Show file tree
Hide file tree
Showing 13 changed files with 639 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,94 @@
// 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. Test the case when an entry point (function `main()`) is in an
/// augmentation library
/// @author sgrekhov22@gmail.com
/// @issue 55113
// SharedOptions=--enable-experiment=macros

library augment 'defining_augmentation_A03_t02_main.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

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,43 @@
// 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. Test the case when an entry point (function `main()`) is in an
/// augmentation library
/// @author sgrekhov22@gmail.com
/// @issue 55113
// SharedOptions=--enable-experiment=macros

import augment 'defining_augmentation_A03_t02.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,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;

0 comments on commit 804c45b

Please sign in to comment.