From a92ac0237a67eee901db006f1e4d4e9f0e8eb4d5 Mon Sep 17 00:00:00 2001 From: Nicholas Shahan Date: Wed, 14 Feb 2024 00:13:57 +0000 Subject: [PATCH] [ddc] Delete tests requiring the old type system These are tests for the specific apis of the old runtime type system and they will never pass in the new type system. Change-Id: I740fc06411cdc621b072782d22ec630c5b6bf96a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341784 Commit-Queue: Nicholas Shahan Reviewed-by: Sigmund Cherem --- .../runtime_debugger_api_test.dart | 2 +- tests/dartdevc/runtime_utils.dart | 34 ++-------- tests/dartdevc/runtime_utils_nnbd.dart | 29 -------- tests/dartdevc/subtype_test.dart | 66 +++++++++---------- tests/dartdevc/subtype_weak_test.dart | 64 +++++++++--------- tests/dartdevc/type_normalization_test.dart | 38 ----------- 6 files changed, 66 insertions(+), 167 deletions(-) delete mode 100644 tests/dartdevc/runtime_utils_nnbd.dart delete mode 100644 tests/dartdevc/type_normalization_test.dart diff --git a/pkg/dev_compiler/test/expression_compiler/runtime_debugger_api_test.dart b/pkg/dev_compiler/test/expression_compiler/runtime_debugger_api_test.dart index 11d1de06cfd..538bd44d9b1 100644 --- a/pkg/dev_compiler/test/expression_compiler/runtime_debugger_api_test.dart +++ b/pkg/dev_compiler/test/expression_compiler/runtime_debugger_api_test.dart @@ -332,7 +332,7 @@ void runSharedTests( }); }); - test('getObjectMetadata (List) (new types)', () async { + test('getObjectMetadata (List)', () async { await driver.checkRuntimeInFrame( breakpointId: 'BP', expression: 'dart.getObjectMetadata(list)', diff --git a/tests/dartdevc/runtime_utils.dart b/tests/dartdevc/runtime_utils.dart index 8fea4f70506..aa1e4557f84 100644 --- a/tests/dartdevc/runtime_utils.dart +++ b/tests/dartdevc/runtime_utils.dart @@ -2,39 +2,13 @@ // 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. -import 'dart:_foreign_helper' show TYPE_REF; -import 'dart:_runtime' show gFnType, isSubtypeOf; +import 'dart:_foreign_helper' show JS_EMBEDDED_GLOBAL; +import 'dart:_js_shared_embedded_names' show RTI_UNIVERSE; +import 'dart:_rti' show isSubtype; import 'package:expect/expect.dart'; -/// Returns an unwrapped generic function type with a bounded type argument in -/// the form: void -> void. -/// -// TODO(nshahan): The generic function type is created as a legacy type. -genericFunction(bound) => - gFnType((T) => [TYPE_REF(), []], (T) => [bound]); - -/// Returns an unwrapped generic function type with a bounded type argument in -/// the form: [argumentType] -> T. -/// -// TODO(nshahan): The generic function type is created as a legacy type. -functionGenericReturn(bound, argumentType) => gFnType( - (T) => [ - T, - [argumentType] - ], - (T) => [bound]); - -/// Returns an unwrapped generic function type with a bounded type argument in -/// the form: T -> [returnType]. -/// -// TODO(nshahan): The generic function type is created as a legacy type. -functionGenericArg(bound, returnType) => gFnType( - (T) => [ - returnType, - [T] - ], - (T) => [bound]); +bool isSubtypeOf(s, t) => isSubtype(JS_EMBEDDED_GLOBAL('', RTI_UNIVERSE), s, t); void checkSubtype(s, t) => Expect.isTrue(isSubtypeOf(s, t), '$s should be subtype of $t.'); diff --git a/tests/dartdevc/runtime_utils_nnbd.dart b/tests/dartdevc/runtime_utils_nnbd.dart deleted file mode 100644 index 733c1e05999..00000000000 --- a/tests/dartdevc/runtime_utils_nnbd.dart +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2019, 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. - -import 'dart:_foreign_helper' show JS, TYPE_REF; -import 'dart:_runtime' show gFnType; - -/// Returns an unwrapped generic function type with a bounded type argument in -/// the form: void -> void. -Object genericFunction(Object bound) => - gFnType((T) => [TYPE_REF(), []], (T) => [bound]); - -/// Returns an unwrapped generic function type with a bounded type argument in -/// the form: [argumentType] -> T. -Object functionGenericReturn(Object bound, Object argType) => gFnType( - (T) => [ - T, - [argType] - ], - (T) => [bound]); - -/// Returns an unwrapped generic function type with a bounded type argument in -/// the form: T -> [returnType]. -Object functionGenericArg(Object bound, Object returnType) => gFnType( - (T) => [ - returnType, - [T] - ], - (T) => [bound]); diff --git a/tests/dartdevc/subtype_test.dart b/tests/dartdevc/subtype_test.dart index 22d565f54ab..5de26aeeb90 100644 --- a/tests/dartdevc/subtype_test.dart +++ b/tests/dartdevc/subtype_test.dart @@ -13,7 +13,6 @@ import 'runtime_utils.dart' checkProperSubtype, checkMutualSubtype, checkSubtypeFailure; -import 'runtime_utils_nnbd.dart'; class A {} @@ -148,72 +147,69 @@ void main() { // Generic Function Subtypes. // Bound is a built in type. // void -> void <: void -> void - checkSubtype( - genericFunction(TYPE_REF()), genericFunction(TYPE_REF())); + checkSubtype(TYPE_REF()>(), + TYPE_REF()>()); // A -> T <: B -> T - checkProperSubtype(functionGenericReturn(TYPE_REF(), TYPE_REF()), - functionGenericReturn(TYPE_REF(), TYPE_REF())); + checkProperSubtype(TYPE_REF(A)>(), + TYPE_REF(B)>()); // T -> B <: T -> A - checkProperSubtype(functionGenericArg(TYPE_REF(), TYPE_REF()), - functionGenericArg(TYPE_REF(), TYPE_REF())); + checkProperSubtype(TYPE_REF(T)>(), + TYPE_REF(T)>()); // Bound is a function type. // B> void -> void <: B> void -> void - checkSubtype(genericFunction(TYPE_REF()), - genericFunction(TYPE_REF())); + checkSubtype(TYPE_REF()>(), + TYPE_REF()>()); // B> A -> T <: B> B -> T - checkProperSubtype( - functionGenericReturn(TYPE_REF(), TYPE_REF()), - functionGenericReturn(TYPE_REF(), TYPE_REF())); + checkProperSubtype(TYPE_REF(A)>(), + TYPE_REF(B)>()); // B> T -> B <: B> T -> A - checkProperSubtype( - functionGenericArg(TYPE_REF(), TYPE_REF()), - functionGenericArg(TYPE_REF(), TYPE_REF())); + checkProperSubtype(TYPE_REF(T)>(), + TYPE_REF(T)>()); // Bound is a user defined class. // void -> void <: void -> void - checkSubtype(genericFunction(TYPE_REF()), genericFunction(TYPE_REF())); + checkSubtype(TYPE_REF()>(), + TYPE_REF()>()); // A -> T <: B -> T - checkProperSubtype(functionGenericReturn(TYPE_REF(), TYPE_REF()), - functionGenericReturn(TYPE_REF(), TYPE_REF())); + checkProperSubtype(TYPE_REF(A)>(), + TYPE_REF(B)>()); - // T -> B <: T -> A - checkProperSubtype(functionGenericArg(TYPE_REF(), TYPE_REF()), - functionGenericArg(TYPE_REF(), TYPE_REF())); + // // T -> B <: T -> A + checkProperSubtype(TYPE_REF(T)>(), + TYPE_REF(T)>()); // Bound is a Future. // > void -> void <: > void -> void - checkSubtype(genericFunction(TYPE_REF>()), - genericFunction(TYPE_REF>())); + checkSubtype(TYPE_REF>()>(), + TYPE_REF>()>()); // > A -> T <: > B -> T - checkProperSubtype( - functionGenericReturn(TYPE_REF>(), TYPE_REF()), - functionGenericReturn(TYPE_REF>(), TYPE_REF())); + checkProperSubtype(TYPE_REF>(A)>(), + TYPE_REF>(B)>()); // > T -> B <: > T -> A - checkProperSubtype(functionGenericArg(TYPE_REF>(), TYPE_REF()), - functionGenericArg(TYPE_REF>(), TYPE_REF())); + checkProperSubtype(TYPE_REF>(T)>(), + TYPE_REF>(T)>()); // Bound is a FutureOr. // > void -> void <: // > void -> void - checkSubtype(genericFunction(TYPE_REF>()), - genericFunction(TYPE_REF>())); + checkSubtype(TYPE_REF>()>(), + TYPE_REF>()>()); // > A -> T <: > B -> T - checkProperSubtype( - functionGenericReturn(TYPE_REF>(), TYPE_REF()), - functionGenericReturn(TYPE_REF>(), TYPE_REF())); + checkProperSubtype(TYPE_REF>(A)>(), + TYPE_REF>(B)>()); // > T -> B <: > T -> A - checkProperSubtype(functionGenericArg(TYPE_REF>(), TYPE_REF()), - functionGenericArg(TYPE_REF>(), TYPE_REF())); + checkProperSubtype(TYPE_REF>(T)>(), + TYPE_REF>(T)>()); // Generics. // D <:> D diff --git a/tests/dartdevc/subtype_weak_test.dart b/tests/dartdevc/subtype_weak_test.dart index cddd9d7e207..ea02c97f59e 100644 --- a/tests/dartdevc/subtype_weak_test.dart +++ b/tests/dartdevc/subtype_weak_test.dart @@ -13,7 +13,6 @@ import 'runtime_utils.dart' checkProperSubtype, checkMutualSubtype, checkSubtypeFailure; -import 'runtime_utils_nnbd.dart'; class A {} @@ -148,72 +147,69 @@ void main() { // Generic Function Subtypes. // Bound is a built in type. // void -> void <: void -> void - checkSubtype( - genericFunction(TYPE_REF()), genericFunction(TYPE_REF())); + checkSubtype(TYPE_REF()>(), + TYPE_REF()>()); // A -> T <: B -> T - checkProperSubtype(functionGenericReturn(TYPE_REF(), TYPE_REF()), - functionGenericReturn(TYPE_REF(), TYPE_REF())); + checkProperSubtype(TYPE_REF(A)>(), + TYPE_REF(B)>()); // T -> B <: T -> A - checkProperSubtype(functionGenericArg(TYPE_REF(), TYPE_REF()), - functionGenericArg(TYPE_REF(), TYPE_REF())); + checkProperSubtype(TYPE_REF(T)>(), + TYPE_REF(T)>()); // Bound is a function type. // B> void -> void <: B> void -> void - checkSubtype(genericFunction(TYPE_REF()), - genericFunction(TYPE_REF())); + checkSubtype(TYPE_REF()>(), + TYPE_REF()>()); // B> A -> T <: B> B -> T - checkProperSubtype( - functionGenericReturn(TYPE_REF(), TYPE_REF()), - functionGenericReturn(TYPE_REF(), TYPE_REF())); + checkProperSubtype(TYPE_REF(A)>(), + TYPE_REF(B)>()); // B> T -> B <: B> T -> A - checkProperSubtype( - functionGenericArg(TYPE_REF(), TYPE_REF()), - functionGenericArg(TYPE_REF(), TYPE_REF())); + checkProperSubtype(TYPE_REF(T)>(), + TYPE_REF(T)>()); // Bound is a user defined class. // void -> void <: void -> void - checkSubtype(genericFunction(TYPE_REF()), genericFunction(TYPE_REF())); + checkSubtype(TYPE_REF()>(), + TYPE_REF()>()); // A -> T <: B -> T - checkProperSubtype(functionGenericReturn(TYPE_REF(), TYPE_REF()), - functionGenericReturn(TYPE_REF(), TYPE_REF())); + checkProperSubtype(TYPE_REF(A)>(), + TYPE_REF(B)>()); // T -> B <: T -> A - checkProperSubtype(functionGenericArg(TYPE_REF(), TYPE_REF()), - functionGenericArg(TYPE_REF(), TYPE_REF())); + checkProperSubtype(TYPE_REF(T)>(), + TYPE_REF(T)>()); // Bound is a Future. // > void -> void <: > void -> void - checkSubtype(genericFunction(TYPE_REF>()), - genericFunction(TYPE_REF>())); + checkSubtype(TYPE_REF>()>(), + TYPE_REF>()>()); // > A -> T <: > B -> T - checkProperSubtype( - functionGenericReturn(TYPE_REF>(), TYPE_REF()), - functionGenericReturn(TYPE_REF>(), TYPE_REF())); + checkProperSubtype(TYPE_REF>(A)>(), + TYPE_REF>(B)>()); // > T -> B <: > T -> A - checkProperSubtype(functionGenericArg(TYPE_REF>(), TYPE_REF()), - functionGenericArg(TYPE_REF>(), TYPE_REF())); + checkProperSubtype(TYPE_REF>(T)>(), + TYPE_REF>(T)>()); // Bound is a FutureOr. // > void -> void <: // > void -> void - checkSubtype(genericFunction(TYPE_REF>()), - genericFunction(TYPE_REF>())); + checkSubtype(TYPE_REF>()>(), + TYPE_REF>()>()); // > A -> T <: > B -> T - checkProperSubtype( - functionGenericReturn(TYPE_REF>(), TYPE_REF()), - functionGenericReturn(TYPE_REF>(), TYPE_REF())); + checkProperSubtype(TYPE_REF>(A)>(), + TYPE_REF>(B)>()); // > T -> B <: > T -> A - checkProperSubtype(functionGenericArg(TYPE_REF>(), TYPE_REF()), - functionGenericArg(TYPE_REF>(), TYPE_REF())); + checkProperSubtype(TYPE_REF>(T)>(), + TYPE_REF>(T)>()); // Generics. // D <:> D diff --git a/tests/dartdevc/type_normalization_test.dart b/tests/dartdevc/type_normalization_test.dart deleted file mode 100644 index fb446d4488c..00000000000 --- a/tests/dartdevc/type_normalization_test.dart +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2019, 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. - -// Requirements=nnbd - -import 'dart:_foreign_helper' show LEGACY_TYPE_REF, TYPE_REF; -import 'dart:_runtime' show legacy, nullable; - -import 'package:expect/expect.dart'; - -class A {} - -void main() { - // A?? == A? - Expect.identical(nullable(TYPE_REF()), TYPE_REF()); - // A?* == A? - Expect.identical(legacy(TYPE_REF()), TYPE_REF()); - // A*? == A? - Expect.identical(nullable(LEGACY_TYPE_REF()), TYPE_REF()); - // A** == A* - Expect.identical(legacy(LEGACY_TYPE_REF()), LEGACY_TYPE_REF()); - - // The tests below need explicit wrapping in nullable and legacy to ensure - // they appear at runtime and the runtime library normalizes them correctly. - // Null? == Null - Expect.identical(nullable(TYPE_REF()), TYPE_REF()); - // Never? == Null - Expect.identical(nullable(TYPE_REF()), TYPE_REF()); - // dynamic? == dynamic - Expect.identical(nullable(TYPE_REF()), TYPE_REF()); - // void? == void - Expect.identical(nullable(TYPE_REF()), TYPE_REF()); - // dynamic* == dynamic - Expect.identical(legacy(TYPE_REF()), TYPE_REF()); - // void* == void - Expect.identical(legacy(TYPE_REF()), TYPE_REF()); -}