Skip to content

Commit

Permalink
[test] Adding tests for records with web semantics for numerics.
Browse files Browse the repository at this point in the history
See: #52480

Change-Id: Ife785a2f77579b93854779e43ac349342ac06af3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305480
Reviewed-by: Nicholas Shahan <[email protected]>
  • Loading branch information
Markzipan authored and Commit Queue committed May 25, 2023
1 parent f96d179 commit 8dfd25a
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/web/record_numbers_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) 2023, 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.

// Tests record numeric subtyping rules with web semantics.
// Regression test for https://github.com/dart-lang/sdk/issues/52480

import "package:expect/expect.dart";

main() {
Expect.notSubtype<(int, int), (double, double)>();
Expect.notSubtype<(int, double), (double, double)>();
Expect.notSubtype<(double, double), (int, int)>();
Expect.notSubtype<(int, double), (int, int)>();

Object mixedTuple = (0, 0.1);
(double, double) doubleTuple = (0.0, 0.1);
Object someTuple = doubleTuple;

Expect.type<(double, double)>(mixedTuple);
Expect.type<(int, double)>(mixedTuple);
Expect.type<(double, double)>(someTuple);
Expect.type<(int, double)>(someTuple);

dynamic dynamicIntTuple = (4, 4);
dynamic dynamicDoubleTuple = doubleTuple;

Expect.type<(int, int)>(dynamicIntTuple);
Expect.type<(int, double)>(dynamicIntTuple);
Expect.type<(double, int)>(dynamicIntTuple);
Expect.type<(double, double)>(dynamicIntTuple);
Expect.notType<(int, int)>(dynamicDoubleTuple);
Expect.type<(int, double)>(dynamicDoubleTuple);
Expect.notType<(double, int)>(dynamicDoubleTuple);
Expect.type<(double, double)>(dynamicDoubleTuple);
}

0 comments on commit 8dfd25a

Please sign in to comment.