-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
3 changed files
with
204 additions
and
0 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
LanguageFeatures/Extension-types/exhaustiveness_relational_A01_t01.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// 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 Relational pattern doesn't take part in the calculating of the | ||
/// exhaustiveness | ||
/// | ||
/// @description Check that relational pattern doesn't take part in the | ||
/// calculating of the exhaustiveness. Test the case when constants in | ||
/// relational patterns are extension types | ||
/// @author sgrekhov22@gmail.com | ||
/// @issue 54506 | ||
// SharedOptions=--enable-experiment=inline-class | ||
|
||
extension type const BoolET1(bool _) {} | ||
extension type const BoolET2(bool _) implements bool {} | ||
|
||
const True1 = BoolET1(true); | ||
const False1 = BoolET1(false); | ||
const True2 = BoolET2(true); | ||
const False2 = BoolET2(false); | ||
|
||
String testStatement1(bool b) { | ||
switch (b) { | ||
//^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
case == True1: | ||
return "true"; | ||
case == False1: | ||
return "false"; | ||
} | ||
|
||
} | ||
|
||
String testStatement2(bool b) { | ||
switch (b) { | ||
//^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
case == True2: | ||
return "true"; | ||
case == False2: | ||
return "false"; | ||
} | ||
} | ||
|
||
String testExpression1(bool b) => switch (b) { | ||
// ^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
== True1 => "true", | ||
== False1 => "false" | ||
}; | ||
|
||
String testExpression2(bool b) => switch (b) { | ||
// ^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
== True2 => "true", | ||
== False2 => "false" | ||
}; | ||
|
||
main() { | ||
testStatement1(true); | ||
testStatement2(false); | ||
testExpression1(true); | ||
testExpression2(false); | ||
} |
64 changes: 64 additions & 0 deletions
64
LanguageFeatures/Extension-types/exhaustiveness_relational_A01_t02.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// 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 Relational pattern doesn't take part in the calculating of the | ||
/// exhaustiveness | ||
/// | ||
/// @description Check that relational pattern doesn't take part in the | ||
/// calculating of the exhaustiveness. Test the case when expression in | ||
/// a `switch` are extension types | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=inline-class | ||
|
||
extension type const BoolET1(bool _) {} | ||
extension type const BoolET2(bool _) implements bool {} | ||
|
||
String testStatement1(BoolET1 b) { | ||
switch (b) { | ||
//^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
case == true: | ||
return "true"; | ||
case == false: | ||
return "false"; | ||
} | ||
|
||
} | ||
|
||
String testStatement2(BoolET2 b) { | ||
switch (b) { | ||
//^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
case == true: | ||
return "true"; | ||
case == false: | ||
return "false"; | ||
} | ||
} | ||
|
||
String testExpression1(BoolET1 b) => switch (b) { | ||
// ^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
== true => "true", | ||
== false => "false" | ||
}; | ||
|
||
String testExpression2(BoolET2 b) => switch (b) { | ||
// ^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
== true => "true", | ||
== false => "false" | ||
}; | ||
|
||
main() { | ||
testStatement1(BoolET1(true)); | ||
testStatement2(BoolET2(false)); | ||
testExpression1(BoolET1(false)); | ||
testExpression2(BoolET2(true)); | ||
} |
70 changes: 70 additions & 0 deletions
70
LanguageFeatures/Extension-types/exhaustiveness_relational_A01_t03.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// 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 Relational pattern doesn't take part in the calculating of the | ||
/// exhaustiveness | ||
/// | ||
/// @description Check that relational pattern doesn't take part in the | ||
/// calculating of the exhaustiveness. Test the case when both expression in | ||
/// a `switch` and constants in relational patterns are extension types | ||
/// @author sgrekhov22@gmail.com | ||
/// @issue 54506 | ||
// SharedOptions=--enable-experiment=inline-class | ||
|
||
extension type const BoolET1(bool _) {} | ||
extension type const BoolET2(bool _) implements bool {} | ||
|
||
const True1 = BoolET1(true); | ||
const False1 = BoolET1(false); | ||
const True2 = BoolET2(true); | ||
const False2 = BoolET2(false); | ||
|
||
String testStatement1(BoolET1 b) { | ||
switch (b) { | ||
//^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
case == True1: | ||
return "true"; | ||
case == False1: | ||
return "false"; | ||
} | ||
|
||
} | ||
|
||
String testStatement2(BoolET2 b) { | ||
switch (b) { | ||
//^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
case == True2: | ||
return "true"; | ||
case == False2: | ||
return "false"; | ||
} | ||
} | ||
|
||
String testExpression1(BoolET1 b) => switch (b) { | ||
// ^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
== True1 => "true", | ||
== False1 => "false" | ||
}; | ||
|
||
String testExpression2(BoolET2 b) => switch (b) { | ||
// ^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
== True2 => "true", | ||
== False2 => "false" | ||
}; | ||
|
||
main() { | ||
testStatement1(True1); | ||
testStatement2(False2); | ||
testExpression1(False1); | ||
testExpression2(True2); | ||
} |