dart-sdk/tests/corelib_2/from_environment_const_type_undefined_test.dart
Erik Ernst e3af7e724f Update usage of int/String fromEnvironment
Breaking change 40678 requires the constructors int.fromEnvironment and
String.fromEnvironment to get new default values for the named
parameter `defaultValue`. This CL changes usages of these constructors
such that they do not depend on the default value, such that it
becomes a non-breaking change for code in the SDK repo to perform the
change in sdk and in sdk_nnbd.

Change-Id: I82af0e1f92d6cd3618b65c0c50d754ae8c39eb0a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140284
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2020-03-24 11:19:14 +00:00

43 lines
1.1 KiB
Dart

// Copyright (c) 2014, 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";
class Foo {}
const
bool // //# 01: ok
int // //# 02: compile-time error
String //# 03: compile-time error
Foo // //# 04: compile-time error
a = const bool.fromEnvironment('a');
const
bool // //# 05: ok
int // //# 06: compile-time error
String //# 07: compile-time error
Foo // //# 08: compile-time error
b = const bool.fromEnvironment('b');
const
bool // //# 09: compile-time error
int // //# 10: ok
String //# 11: compile-time error
Foo // //# 12: compile-time error
c = const int.fromEnvironment('c', defaultValue: 0);
const
bool // //# 13: compile-time error
int // //# 14: compile-time error
String //# 15: ok
Foo // //# 16: compile-time error
d = const String.fromEnvironment('d', defaultValue: '');
main() {
Expect.equals(false, a);
Expect.equals(false, b);
Expect.equals(0, c);
Expect.equals('', d);
}