Skip to content

Commit

Permalink
dart-lang#2641. Add tests for unchanged declarations named _
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrekhov committed May 14, 2024
1 parent 73d7db1 commit 2c2b572
Show file tree
Hide file tree
Showing 13 changed files with 282 additions and 0 deletions.
22 changes: 22 additions & 0 deletions LanguageFeatures/Wildcards/unchanged_A01_t01.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 top-level variable named `_` is still accessible
/// and its value can be used.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=wildcard-variables

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

var _;

main() {
_ = "value";
Expect.equals("value", _);
}
21 changes: 21 additions & 0 deletions LanguageFeatures/Wildcards/unchanged_A01_t02.dart
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 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 top-level variable named `_` is still accessible
/// and its value can be used.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=wildcard-variables

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

final _ = 42;

main() {
Expect.equals(42, _);
}
21 changes: 21 additions & 0 deletions LanguageFeatures/Wildcards/unchanged_A01_t03.dart
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 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 top-level variable named `_` is still accessible
/// and its value can be used.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=wildcard-variables

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

int _ = 42;

main() {
Expect.equals(42, _);
}
21 changes: 21 additions & 0 deletions LanguageFeatures/Wildcards/unchanged_A01_t04.dart
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 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 it is a compile-time error to declare more than one
/// top-level variable named `_`.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=wildcard-variables

var _, _;
// ^
// [analyzer] unspecified
// [cfe] unspecified

main() {
}
21 changes: 21 additions & 0 deletions LanguageFeatures/Wildcards/unchanged_A01_t05.dart
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 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 it is a compile-time error to declare more than one
/// top-level variable named `_`.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=wildcard-variables

final _ = 1, _ = 2;
// ^
// [analyzer] unspecified
// [cfe] unspecified

main() {
}
21 changes: 21 additions & 0 deletions LanguageFeatures/Wildcards/unchanged_A01_t06.dart
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 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 it is a compile-time error to declare more than one
/// top-level variable named `_`.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=wildcard-variables

int? _ = 42, _;
// ^
// [analyzer] unspecified
// [cfe] unspecified

main() {
}
27 changes: 27 additions & 0 deletions LanguageFeatures/Wildcards/unchanged_A01_t07.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// 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 it is a compile-time error to declare more than one
/// top-level variable named `_`.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=wildcard-variables

const _ = 42;
final _ = 43;
// ^
// [analyzer] unspecified
// [cfe] unspecified

var _;
// ^
// [analyzer] unspecified
// [cfe] unspecified

main() {
}
22 changes: 22 additions & 0 deletions LanguageFeatures/Wildcards/unchanged_A02_t01.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 top-level function named `_` is still accessible
/// and can be called.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=wildcard-variables

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

int _() => 42;

main() {
print(_);
Expect.equals(42, _());
}
21 changes: 21 additions & 0 deletions LanguageFeatures/Wildcards/unchanged_A02_t02.dart
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 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 top-level getter named `_` is still accessible
/// and can be called.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=wildcard-variables

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

int get _ => 42;

main() {
Expect.equals(42, _);
}
22 changes: 22 additions & 0 deletions LanguageFeatures/Wildcards/unchanged_A02_t03.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 it is a compile-time error to declare more than one
/// top-level function named `_`.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=wildcard-variables

int _() => 42;
int _() => 43;
// ^
// [analyzer] unspecified
// [cfe] unspecified

main() {
}
22 changes: 22 additions & 0 deletions LanguageFeatures/Wildcards/unchanged_A02_t04.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 it is a compile-time error to declare more than one
/// top-level getter named `_`.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=wildcard-variables

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

main() {
}
19 changes: 19 additions & 0 deletions LanguageFeatures/Wildcards/unchanged_A02_t05.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 top-level setter named `_` is still accessible
/// and can be called.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=wildcard-variables

void set _(int v) {}

main() {
_ = 42;
}
22 changes: 22 additions & 0 deletions LanguageFeatures/Wildcards/unchanged_A02_t06.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 it is a compile-time error to declare more than one
/// top-level setter named `_`.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=wildcard-variables

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

main() {
}

0 comments on commit 2c2b572

Please sign in to comment.