mirror of
https://github.com/dart-lang/sdk
synced 2024-09-18 21:31:20 +00:00
e0b7841d16
Also, tests/corelib/string_operations_with_null_test.dart is fixed for strong mode: in strong mode TypeError is thrown when null is casted to a non-nullable type; in weak mode null is silently passed and ArgumentError or NoSuchMethodError is thrown. Change-Id: I566a80293ffb03752cc3409e1b79491f0aff6888 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140779 Reviewed-by: Ryan Macnak <rmacnak@google.com> Commit-Queue: Alexander Markov <alexmarkov@google.com>
19 lines
664 B
Dart
19 lines
664 B
Dart
// Copyright (c) 2013, 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";
|
|
|
|
@pragma('dart2js:noInline')
|
|
@pragma('dart2js:assumeDynamic')
|
|
returnStringOrNull() {
|
|
return new DateTime.now().millisecondsSinceEpoch == 0 ? 'foo' : null;
|
|
}
|
|
|
|
main() {
|
|
Expect.throws(() => 'foo' + returnStringOrNull(),
|
|
(e) => e is ArgumentError || e is TypeError);
|
|
Expect.throws(() => 'foo'.split(returnStringOrNull()),
|
|
(e) => e is ArgumentError || e is NoSuchMethodError || e is TypeError);
|
|
}
|