dart-sdk/tests/language/string/substring_test.dart
Johnni Winther 4948c31b7a [test_runner] Support detection of CFE warnings
+ some test expectation fixes

Change-Id: Ibf0259914960ea25978f2b8e29aa89336e209f2f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162321
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-09-15 07:57:31 +00:00

23 lines
891 B
Dart

// Copyright (c) 2011, 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 version of two-argument Ackermann-Peter function.
import "package:expect/expect.dart";
main() {
try {
print("abcdef".substring(1.5, 3.5));
// ^^^
// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// [cfe] The argument type 'double' can't be assigned to the parameter type 'int'.
// ^^^
// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
// [cfe] The argument type 'double' can't be assigned to the parameter type 'int?'.
Expect.fail("Should have thrown an exception");
} on TypeError catch (e) {
// OK.
} on ArgumentError catch (e) {
// OK.
}
}