56f46b0659
This changes the CFE expectation test suites to use unsound null safety as default to avoid passing --enable-experiments=no-non-nullable to opt out old test folders. This change removes most test folders from the 'strong' tester, since this now only supports sound null safety, which requires all libraries to be opted in. Instead, the 'weak' tester now runs all test folders. Additionally the 'outline' tester is changed to use unsound null safety so that it call be used on all test folders. The 'fast_strong' tester is removed since it should just be run locally and it can be run by passing an option to the other testers. References to non-existing 'shaker' folder has been removed from testing.json. Change-Id: Ibcc306f7b27d06b9637c205238bc408194f1d062 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184787 Commit-Queue: Johnni Winther <johnniwinther@google.com> Reviewed-by: Jens Johansen <jensj@google.com>
221 lines
7.2 KiB
Dart
221 lines
7.2 KiB
Dart
// Copyright (c) 2020, 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.
|
|
// @dart=2.9
|
|
// Environment does not contain "bar".
|
|
const bool barFromEnv = const bool.fromEnvironment("bar");
|
|
const bool hasBarEnv = const bool.hasEnvironment("bar");
|
|
const bool barFromEnvOrNull =
|
|
const bool.fromEnvironment("bar", defaultValue: null);
|
|
const bool notBarFromEnvOrNull = !barFromEnvOrNull;
|
|
const bool conditionalOnNull = barFromEnvOrNull ? true : false;
|
|
const bool nullAwareOnNullTrue = barFromEnvOrNull ?? true;
|
|
const bool nullAwareOnNullFalse = barFromEnvOrNull ?? false;
|
|
const bool andOnFalse = nullAwareOnNullFalse && nullAwareOnNullTrue;
|
|
const bool andOnFalse2 = nullAwareOnNullTrue && nullAwareOnNullFalse;
|
|
const bool andOnNull = barFromEnvOrNull && true;
|
|
const bool andOnNull2 = true && barFromEnvOrNull;
|
|
const bool orOnNull = barFromEnvOrNull || true;
|
|
const bool orOnNull2 = barFromEnvOrNull || false;
|
|
const bool orOnNull3 = true || barFromEnvOrNull;
|
|
const bool orOnNull4 = false || barFromEnvOrNull;
|
|
|
|
const String barFromEnvString = const String.fromEnvironment("bar");
|
|
const String barFromEnvOrNullString =
|
|
const String.fromEnvironment("bar", defaultValue: null);
|
|
const String barFromEnvOrActualString =
|
|
const String.fromEnvironment("bar", defaultValue: "hello");
|
|
const String nullFromEnvString =
|
|
const String.fromEnvironment(barFromEnvOrNullString);
|
|
|
|
const bool barFromEnvBool = const bool.fromEnvironment("bar");
|
|
const bool barFromEnvOrNullBool =
|
|
const bool.fromEnvironment("bar", defaultValue: null);
|
|
const bool barFromEnvOrActualBool =
|
|
const bool.fromEnvironment("bar", defaultValue: true);
|
|
const bool nullFromEnvBool = const bool.fromEnvironment(barFromEnvOrNullString);
|
|
|
|
const int barFromEnvInt = const int.fromEnvironment("bar");
|
|
const int barFromEnvOrNullInt =
|
|
const int.fromEnvironment("bar", defaultValue: null);
|
|
const int barFromEnvOrActualInt =
|
|
const int.fromEnvironment("bar", defaultValue: 42);
|
|
const int nullFromEnvInt = const int.fromEnvironment(barFromEnvOrNullString);
|
|
|
|
// Environment does contain "baz" (value '42', i.e. neither true nor false).
|
|
const bool bazFromEnv = const bool.fromEnvironment("baz");
|
|
const bool hasBazEnv = const bool.hasEnvironment("baz");
|
|
const int bazFromEnvAsInt = const int.fromEnvironment("baz");
|
|
const String bazFromEnvAsString = const String.fromEnvironment("baz");
|
|
|
|
// Environment does contain "bazTrue" (value 'true') and
|
|
// "bazFalse" (value 'false').
|
|
const bool bazTrueFromEnv = const bool.fromEnvironment("bazTrue");
|
|
const bool bazFalseFromEnv = const bool.fromEnvironment("bazFalse");
|
|
|
|
const bool trueBool = true;
|
|
const bool falseBool = false;
|
|
const bool binaryOnBoolCaret = trueBool ^ falseBool;
|
|
const bool binaryOnBoolAmpersand = trueBool & falseBool;
|
|
const bool binaryOnBoolBar = trueBool | falseBool;
|
|
const bool binaryOnBoolBar2 = falseBool | trueBool;
|
|
|
|
const dynamic willBeDouble = const bool.fromEnvironment("foo") ? 42 : 42.42;
|
|
const binaryOnDouble = willBeDouble << 2;
|
|
const dynamic willBeInt = const bool.fromEnvironment("foo") ? 42.42 : 42;
|
|
const binaryOnIntWithDoubleBad = willBeInt << willBeDouble;
|
|
const binaryOnIntWithDoubleOK = willBeInt + willBeDouble;
|
|
const binaryOnIntWithString = willBeInt << "hello";
|
|
const dynamic willBeString =
|
|
const bool.fromEnvironment("foo") ? 42.42 : "hello";
|
|
const binaryOnStringWithStringOK = willBeString + " world";
|
|
const binaryOnStringWithInt = willBeString + willBeInt;
|
|
const binaryOnStringWithStringBad = willBeString - " world";
|
|
|
|
var x = 1;
|
|
const x1 = --x;
|
|
const x2 = ++x;
|
|
const x3 = x--;
|
|
const x4 = x++;
|
|
|
|
const y = 1;
|
|
const y1 = --y;
|
|
const y2 = ++y;
|
|
const y3 = y--;
|
|
const y4 = y++;
|
|
|
|
abstract class AbstractClass {}
|
|
|
|
abstract class AbstractClassWithConstructor {
|
|
const AbstractClassWithConstructor();
|
|
|
|
int foo();
|
|
}
|
|
|
|
AbstractClassWithConstructor abstractClassWithConstructor =
|
|
const AbstractClassWithConstructor();
|
|
|
|
class NotAbstractClass {
|
|
@AbstractClass()
|
|
Object foo;
|
|
|
|
@AbstractClassWithConstructor()
|
|
Object bar;
|
|
}
|
|
|
|
class Foo {
|
|
final int x;
|
|
final int y;
|
|
const Foo(int x)
|
|
: this.x = x,
|
|
this.y = "hello".length;
|
|
}
|
|
|
|
class ExtendsFoo1 extends Foo {
|
|
// No constructor.
|
|
}
|
|
|
|
const ExtendsFoo1 extendsFoo1 = const ExtendsFoo1();
|
|
|
|
class ExtendsFoo2 extends Foo {
|
|
const ExtendsFoo2();
|
|
}
|
|
|
|
const ExtendsFoo2 extendsFoo2 = const ExtendsFoo2();
|
|
|
|
const Foo foo1 = const Foo(42);
|
|
const Foo foo2 = const Foo(42);
|
|
const bool foosIdentical = identical(foo1, foo2);
|
|
const bool foosEqual = foo1 == foo2;
|
|
const Symbol barFoo = const Symbol("Foo");
|
|
const Symbol barFooEqual = const Symbol("Foo=");
|
|
const Symbol tripleShiftSymbol = const Symbol(">>>");
|
|
const Symbol symbolWithDots = const Symbol("I.Have.Dots");
|
|
|
|
const int circularity1 = circularity2;
|
|
const int circularity2 = circularity3;
|
|
const int circularity3 = circularity4;
|
|
const int circularity4 = circularity1;
|
|
|
|
const function_const = () {};
|
|
var function_var = () {};
|
|
|
|
class ConstClassWithFailingAssertWithEmptyMessage {
|
|
const ConstClassWithFailingAssertWithEmptyMessage() : assert(false, "");
|
|
}
|
|
|
|
ConstClassWithFailingAssertWithEmptyMessage failedAssertEmptyMessage =
|
|
const ConstClassWithFailingAssertWithEmptyMessage();
|
|
|
|
class ClassWithTypeArguments<E, F, G> {
|
|
const ClassWithTypeArguments(E e, F f, G g);
|
|
}
|
|
|
|
const ClassWithTypeArguments classWithTypeArguments1 =
|
|
const ClassWithTypeArguments<int, int, int>(42, 42, 42);
|
|
const ClassWithTypeArguments classWithTypeArguments2 =
|
|
const ClassWithTypeArguments(42, 42, 42);
|
|
const bool classWithTypeArgumentsIdentical =
|
|
identical(classWithTypeArguments1, classWithTypeArguments2);
|
|
|
|
class ClassWithNonEmptyConstConstructor {
|
|
const ClassWithNonEmptyConstConstructor() {
|
|
print("hello");
|
|
}
|
|
}
|
|
|
|
ClassWithNonEmptyConstConstructor classWithNonEmptyConstConstructor =
|
|
const ClassWithNonEmptyConstConstructor();
|
|
|
|
class ConstClassWithFinalFields1 {
|
|
const ConstClassWithFinalFields1();
|
|
|
|
final x = 1;
|
|
}
|
|
|
|
class ConstClassWithFinalFields2 {
|
|
const ConstClassWithFinalFields2();
|
|
|
|
final y = 1;
|
|
final z1 = y;
|
|
final z2 = x;
|
|
}
|
|
|
|
ConstClassWithFinalFields2 constClassWithFinalFields =
|
|
const ConstClassWithFinalFields2();
|
|
|
|
const zeroPointZeroIdentical = identical(0.0, 0.0);
|
|
const zeroPointZeroIdenticalToZero = identical(0.0, 0);
|
|
const zeroIdenticalToZeroPointZero = identical(0, 0.0);
|
|
const nanIdentical = identical(0 / 0, 0 / 0);
|
|
|
|
const zeroPointZeroEqual = 0.0 == 0.0;
|
|
const zeroPointZeroEqualToZero = 0.0 == 0;
|
|
const zeroEqualToZeroPointZero = 0 == 0.0;
|
|
const nanEqual = 0 / 0 == 0 / 0;
|
|
|
|
T id1<T>(T t) => t;
|
|
T id2<T>(T t) => t;
|
|
|
|
const dynamic willBecomeNull = const bool.fromEnvironment("foo") ? id1 : null;
|
|
|
|
const int Function(int) willBecomeNullToo =
|
|
const bool.fromEnvironment("foo") ? id1 : willBecomeNull;
|
|
const int Function(int) partialInstantiation =
|
|
const bool.fromEnvironment("foo") ? willBecomeNull : id1;
|
|
|
|
const bool yBool = true;
|
|
const bool zBool = !yBool;
|
|
|
|
const maybeInt = bool.fromEnvironment("foo") ? 42 : true;
|
|
const bool isItInt = maybeInt is int ? true : false;
|
|
const maybeInt2 = zBool ? 42 : true;
|
|
const bool isItInt2 = maybeInt2 is int ? true : false;
|
|
const maybeInt3 = zBool ? 42 : null;
|
|
const bool isItInt3 = maybeInt3 is int ? true : false;
|
|
|
|
main() {
|
|
print(barFromEnv);
|
|
print(hasBarEnv);
|
|
}
|