blob: 050fe6eaeee48acac8f4bf60644e7d7622e109c8 [file] [log] [blame]
// 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.
/// @assertion Two objects T1 and T2 which are instances of Type (that is,
/// runtime type objects) are considered equal if and only if the runtime type
/// objects T1 and T2 corresponds to the types S1 and S2 respectively, and the
/// normal forms NORM(S1) and NORM(S2) are syntactically equal up to equivalence
/// of bound variables and ignoring * modifiers on types.
/// ...
/// In both sound and unsound null checking, and in both opted in and opted out
/// code, comparison of constant instances for identity is defined such that any
/// two instances which are otherwise identical except for their generic type
/// arguments shall be considered identical if those generic type arguments
/// compare equal using the definition of runtime type object equality defined
/// above. That is, comparison (or canonicalization) of constant instances of
/// generic classes is performed relative to the normal forms of their generic
/// type arguments, and ignoring legacy type annotations as described above.
/// Hence, an instance of C<T0> compares identical to C<T1> if T0 and T1 have
/// the same normal form (up to the identity of bound variables), and the
/// objects are otherwise identical.
///
/// @description Checks that two constants are not equal if their type arguments
/// are not equal according to the runtime type equality.
/// @author sgrekhov22@gmail.com
import "dart:async";
import "../../Utils/expect.dart";
main() {
const cNull = <Set<Null>>[];
const cNever = <Set<Never>>[];
const cDynamic = <Set<dynamic>>[];
const cObject = <Set<Object>>[];
const cNullableObject = <Set<Object?>>[];
const cVoid = <Set<void>>[];
const cFutureOrVoid = <Set<FutureOr<void>>>[];
const cFutureOrDynamic = <Set<FutureOr<dynamic>>>[];
const cFutureOrObject = <Set<FutureOr<Object>>>[];
const cFutureOrNullableObject = <Set<FutureOr<Object?>>>[];
const cFutureOrNull = <Set<FutureOr<Null>>>[];
Expect.notEquals(cNull, cNever);
Expect.notEquals(cNull, cDynamic);
Expect.notEquals(cNull, cObject);
Expect.notEquals(cNull, cNullableObject);
Expect.notEquals(cNull, cVoid);
Expect.notEquals(cNull, cFutureOrVoid);
Expect.notEquals(cNull, cFutureOrDynamic);
Expect.notEquals(cNull, cFutureOrObject);
Expect.notEquals(cNull, cFutureOrNullableObject);
Expect.notEquals(cNull, cFutureOrNull);
Expect.notEquals(cNever, cDynamic);
Expect.notEquals(cNever, cObject);
Expect.notEquals(cNever, cNullableObject);
Expect.notEquals(cNever, cVoid);
Expect.notEquals(cNever, cFutureOrVoid);
Expect.notEquals(cNever, cFutureOrDynamic);
Expect.notEquals(cNever, cFutureOrObject);
Expect.notEquals(cNever, cFutureOrNullableObject);
Expect.notEquals(cNever, cFutureOrNull);
Expect.notEquals(cDynamic, cObject);
Expect.notEquals(cDynamic, cNullableObject);
Expect.notEquals(cDynamic, cVoid);
Expect.notEquals(cDynamic, cFutureOrVoid);
Expect.notEquals(cDynamic, cFutureOrObject);
Expect.notEquals(cDynamic, cFutureOrNullableObject);
Expect.notEquals(cDynamic, cFutureOrNull);
Expect.notEquals(cObject, cNullableObject);
Expect.notEquals(cObject, cVoid);
Expect.notEquals(cObject, cFutureOrVoid);
Expect.notEquals(cObject, cFutureOrDynamic);
Expect.notEquals(cObject, cFutureOrNullableObject);
Expect.notEquals(cObject, cFutureOrNull);
Expect.notEquals(cNullableObject, cVoid);
Expect.notEquals(cNullableObject, cFutureOrVoid);
Expect.notEquals(cNullableObject, cFutureOrDynamic);
Expect.notEquals(cNullableObject, cFutureOrObject);
Expect.notEquals(cNullableObject, cFutureOrNull);
Expect.notEquals(cVoid, cFutureOrDynamic);
Expect.notEquals(cVoid, cFutureOrObject);
Expect.notEquals(cVoid, cFutureOrNullableObject);
Expect.notEquals(cVoid, cFutureOrNull);
Expect.notEquals(cFutureOrVoid, cFutureOrDynamic);
Expect.notEquals(cFutureOrVoid, cFutureOrObject);
Expect.notEquals(cFutureOrVoid, cFutureOrNullableObject);
Expect.notEquals(cFutureOrVoid, cFutureOrNull);
Expect.notEquals(cFutureOrDynamic, cFutureOrObject);
Expect.notEquals(cFutureOrDynamic, cFutureOrNullableObject);
Expect.notEquals(cFutureOrDynamic, cFutureOrNull);
Expect.notEquals(cFutureOrObject, cFutureOrNullableObject);
Expect.notEquals(cFutureOrObject, cFutureOrNull);
Expect.notEquals(cFutureOrNullableObject, cFutureOrNull);
}