mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 16:41:07 +00:00
[test_runner] Support new features in Requirements.
Support `checkedExplicitCasts`,`checkedImplicitDowncasts`, `checkedParameters`, `jsNumbers`, and `nativeNumbers`. dart2js and DDC configs should support `jsNumbers`. dart2js and dart2wasm (both optimized) do not support checked parameters nor implicit downcasts checks. dart2wasm optimized does not support explicit cast checks. This CL adds these features and makes sure certain configs are opting into these features. Bug: https://github.com/dart-lang/sdk/issues/54798 Change-Id: If61d513569259317b1fb89c27d3fd97e3542697d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352103 Reviewed-by: Sigmund Cherem <sigmund@google.com> Reviewed-by: Nate Bosch <nbosch@google.com> Commit-Queue: Kallen Tu <kallentu@google.com> Reviewed-by: Bob Nystrom <rnystrom@google.com>
This commit is contained in:
parent
86146ed6cf
commit
7a82e8e995
|
@ -417,6 +417,9 @@ class TestConfiguration {
|
|||
return {...Feature.all.where((f) => !Feature.legacy.contains(f))};
|
||||
}
|
||||
|
||||
var isDart2jsProduction = dart2jsOptions.contains('-O3');
|
||||
var isOptimizedDart2Wasm = dart2wasmOptions.contains('-O1');
|
||||
var isJsCompiler = compiler == Compiler.dart2js || compiler == Compiler.ddc;
|
||||
return {
|
||||
// The supported NNBD features depending on the `nnbdMode`.
|
||||
if (NnbdMode.legacy == configuration.nnbdMode)
|
||||
|
@ -429,9 +432,17 @@ class TestConfiguration {
|
|||
// The configurations with the following builder tags and configurations
|
||||
// with the `minified` flag set to `true` will obfuscate `Type.toString`
|
||||
// strings.
|
||||
if (!(const {"dart2js_production", "obfuscated"}).contains(builderTag) &&
|
||||
!isMinified)
|
||||
if (!isDart2jsProduction && builderTag != 'obfuscated' && !isMinified)
|
||||
Feature.readableTypeStrings,
|
||||
|
||||
if (isJsCompiler) Feature.jsNumbers else Feature.nativeNumbers,
|
||||
|
||||
if (!isDart2jsProduction && !isOptimizedDart2Wasm) ...[
|
||||
Feature.checkedImplicitDowncasts,
|
||||
Feature.checkedParameters,
|
||||
],
|
||||
|
||||
if (!isOptimizedDart2Wasm) Feature.checkedExplicitCasts,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,32 @@
|
|||
/// requires. If a test requires a feature not supported by the current
|
||||
/// configution, the test runner automatically skips it.
|
||||
class Feature {
|
||||
/// Enforces that explicit casts from `as` expressions are type checked at
|
||||
/// runtime.
|
||||
static const checkedExplicitCasts = Feature._("checked-explicit-casts");
|
||||
|
||||
/// Enforces that implicit downcasts from `dynamic` are typed checked at
|
||||
/// runtime.
|
||||
static const checkedImplicitDowncasts =
|
||||
Feature._("checked-implicit-downcasts");
|
||||
|
||||
/// Enforces runtime parameter type checks.
|
||||
///
|
||||
/// These checks include both covariant parameter checks, either from generics
|
||||
/// or declared as `covariant`, and parameter checks of dynamic function
|
||||
/// invocations through `dynamic` or `Function`.
|
||||
static const checkedParameters = Feature._("checked-parameters");
|
||||
|
||||
/// Supports JavaScript number semantics.
|
||||
///
|
||||
/// In code compiled to JavaScript, Dart integers are represented by
|
||||
/// JavaScript numbers, which have different ranges and behavior than native
|
||||
/// integers.
|
||||
static const jsNumbers = Feature._("js-numbers");
|
||||
|
||||
/// Supports native number semantics.
|
||||
static const nativeNumbers = Feature._("native-numbers");
|
||||
|
||||
/// Opted out of NNBD and still using the legacy semantics.
|
||||
static const nnbdLegacy = Feature._("nnbd-legacy");
|
||||
|
||||
|
@ -25,11 +51,16 @@ class Feature {
|
|||
/// Full strong checking of NNBD features.
|
||||
static const nnbdStrong = Feature._("nnbd-strong");
|
||||
|
||||
/// [Type.toString] is expected to show the original type name and original
|
||||
/// Expects [Type.toString] to show the original type name and original
|
||||
/// names in function type named parameters.
|
||||
static const readableTypeStrings = Feature._("readable-type-strings");
|
||||
|
||||
static const all = [
|
||||
checkedExplicitCasts,
|
||||
checkedImplicitDowncasts,
|
||||
checkedParameters,
|
||||
jsNumbers,
|
||||
nativeNumbers,
|
||||
nnbdLegacy,
|
||||
nnbd,
|
||||
nnbdWeak,
|
||||
|
|
Loading…
Reference in a new issue