Skip to content

Commit

Permalink
#2641. Add tests for unchanged type declarations named _ (#2666)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrekhov committed May 15, 2024
1 parent 176226f commit 157dd49
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 0 deletions.
20 changes: 20 additions & 0 deletions LanguageFeatures/Wildcards/unchanged_A03_t01.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// 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 Other declarations: top-level variables, top-level function
/// names, type names, member names, etc. are unchanged. They can be named `_`
/// as they are today.
///
/// @description Checks that a type named `_` is still accessible and can be
/// used.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=wildcard-variables

class _ {}

main() {
_ v = _();
print(_);
}
19 changes: 19 additions & 0 deletions LanguageFeatures/Wildcards/unchanged_A03_t02.dart
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 Other declarations: top-level variables, top-level function
/// names, type names, member names, etc. are unchanged. They can be named `_`
/// as they are today.
///
/// @description Checks that a type named `_` is still accessible and can be
/// used.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=wildcard-variables

mixin _ {}

main() {
print(_);
}
20 changes: 20 additions & 0 deletions LanguageFeatures/Wildcards/unchanged_A03_t03.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// 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 Other declarations: top-level variables, top-level function
/// names, type names, member names, etc. are unchanged. They can be named `_`
/// as they are today.
///
/// @description Checks that a type named `_` is still accessible and can be
/// used.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=wildcard-variables

enum _ {e1;}

main() {
print(_);
print(_.e1);
}
19 changes: 19 additions & 0 deletions LanguageFeatures/Wildcards/unchanged_A03_t04.dart
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 Other declarations: top-level variables, top-level function
/// names, type names, member names, etc. are unchanged. They can be named `_`
/// as they are today.
///
/// @description Checks that a type named `_` is still accessible and can be
/// used.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=wildcard-variables

extension type _(int id) {}

main() {
print(_);
}
22 changes: 22 additions & 0 deletions LanguageFeatures/Wildcards/unchanged_A03_t05.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 Other declarations: top-level variables, top-level function
/// names, type names, member names, etc. are unchanged. They can be named `_`
/// as they are today.
///
/// @description Checks that a type named `_` is still accessible and can be
/// used.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=wildcard-variables

class A {}
extension _ on A {
static int s = 42;
}

main() {
print(_.s);
}
20 changes: 20 additions & 0 deletions LanguageFeatures/Wildcards/unchanged_A03_t06.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// 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 Other declarations: top-level variables, top-level function
/// names, type names, member names, etc. are unchanged. They can be named `_`
/// as they are today.
///
/// @description Checks that a type alias named `_` is still accessible and can
/// be used.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=wildcard-variables

class C {}
typedef _ = C;

main() {
print(_);
}
22 changes: 22 additions & 0 deletions LanguageFeatures/Wildcards/unchanged_A03_t07.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 Other declarations: top-level variables, top-level function
/// names, type names, member names, etc. are unchanged. They can be named `_`
/// as they are today.
///
/// @description Checks that a type alias named `_` is still accessible and can
/// be used.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=wildcard-variables

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

typedef int _(String s);

main() {
_ f = (String s) {return 42;};
Expect.equals(42, f(""));
}

0 comments on commit 157dd49

Please sign in to comment.