Skip to content

Commit

Permalink
dart-lang#2485. Add more constant evaluation tests for record types (d…
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrekhov authored Jan 22, 2024
1 parent 700636f commit 07ce2fd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Language/Expressions/Constants/as_type_A01_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ main() {
const c18 = IntET2(1) as IntET1;
const c19 = C() as Object;
const c20 = const C() as Object;
const c21 = () as ();
const c22 = (i: 1) as ({num i});

Expect.identical(1, c1);
Expect.identical(3.14, c2);
Expand All @@ -69,4 +71,6 @@ main() {
Expect.identical(1, c18);
Expect.identical(const C(), c19);
Expect.identical(const C(), c20);
Expect.identical((), c21);
Expect.identical((i: 1), c22);
}
9 changes: 9 additions & 0 deletions Language/Expressions/Constants/as_type_A01_t03.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
/// expression if `T` is a constant type expression of type `FutureOr<void>` or
/// an extension type with a representation type `void`
/// @author sgrekhov22@gmail.com
/// @issue 54620
// SharedOptions=--enable-experiment=inline-class

Expand All @@ -37,7 +38,15 @@ extension type const VoidET(void _) {}
main() {
const c1 = 1 as VoidET;
const c2 = 2 as FutureOr<void>;
const c3 = (3,) as (VoidET,);
const c4 = (4,) as (FutureOr<void>,);
const c5 = (i: 5) as ({VoidET i});
const c6 = (i: 6) as ({FutureOr<void> i});

Expect.identical(1, c1);
Expect.identical(2, c2);
Expect.identical((3,), c3);
Expect.identical((4,), c4);
Expect.identical((i: 5), c5);
Expect.identical((i: 6), c6);
}
10 changes: 10 additions & 0 deletions Language/Expressions/Constants/as_type_A02_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,14 @@ main() {
// ^^^^^
// [analyzer] unspecified
// [cfe] unspecified
const R1 = (void,) as Type;
// ^^^^
// [analyzer] unspecified
// [cfe] unspecified
const R2 = ({int i}) as Type;
// ^
// [analyzer] unspecified
// [cfe] unspecified


}

0 comments on commit 07ce2fd

Please sign in to comment.