mirror of
https://github.com/dart-lang/sdk
synced 2024-09-19 14:32:49 +00:00
7afb23a7d9
One test verifies that the default values of fromEnvironment constructors are the values false/0/''. The other new test verifies that it is allowed to invoke an expression whose static type is a proper subtype of a function type (X extends F, where F is a function type), cf. https://github.com/dart-lang/language/issues/896. Change-Id: I4ee32df7c5950be07b800027f000a486bf3af61c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/141249 Commit-Queue: Erik Ernst <eernst@google.com> Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
21 lines
883 B
Dart
21 lines
883 B
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.
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
main() {
|
|
// Verify that the default value is as expected.
|
|
Expect.equals(false, const bool.fromEnvironment('UNDEFINED_NAME'));
|
|
Expect.equals(0, const int.fromEnvironment('UNDEFINED_NAME'));
|
|
Expect.equals('', const String.fromEnvironment('UNDEFINED_NAME'));
|
|
|
|
// Verify that `defaultValue` is used when passed, not the default values.
|
|
Expect.equals(
|
|
true, const bool.fromEnvironment('UNDEFINED_NAME', defaultValue: true));
|
|
Expect.equals(
|
|
1, const int.fromEnvironment('UNDEFINED_NAME', defaultValue: 1));
|
|
Expect.equals('qux',
|
|
const String.fromEnvironment('UNDEFINED_NAME', defaultValue: 'qux'));
|
|
}
|