2017-05-26 21:49:14 +00:00
|
|
|
// Copyright (c) 2017, 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.
|
|
|
|
|
2020-03-21 16:12:36 +00:00
|
|
|
// @dart = 2.7
|
|
|
|
|
2017-05-26 21:49:14 +00:00
|
|
|
import 'package:expect/expect.dart';
|
|
|
|
|
|
|
|
/// Dart2js only supports the const constructor for `?.fromEnvironment`. The
|
|
|
|
/// current behavior is to throw at runtime if they call this constructor with
|
|
|
|
/// `new` instead of `const`.
|
|
|
|
main() {
|
|
|
|
Expect.isFalse(const bool.fromEnvironment('X'));
|
2020-03-24 11:19:14 +00:00
|
|
|
Expect.equals('', const String.fromEnvironment('X', defaultValue: ''));
|
2017-05-26 21:49:14 +00:00
|
|
|
Expect.equals(const int.fromEnvironment('X', defaultValue: 0), 0);
|
|
|
|
|
|
|
|
Expect.throws(() => new bool.fromEnvironment('X'));
|
|
|
|
Expect.throws(() => new String.fromEnvironment('X'));
|
|
|
|
Expect.throws(() => new int.fromEnvironment('X', defaultValue: 0));
|
|
|
|
}
|