mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 03:17:55 +00:00
[tests] Split corelib{,_2}/list_concurrent_modify_test
Splitting out a failing test to increase coverage of other tests. It is not clear that `a.addAll(a)` should throw if `a` is empty. `a` is not modified by the action. dart2js/DDC do not detect this case and I'm reluctant to add a check for the case where `a` is in fact not modified. The VM test is very specific to an identical argument and cannot detect the case for `a = Mylist([])`. Another option to this proposal is to simply delete the `[]` case. In general, I'd like to move more ConcurrentModificationError tests into assert statements. Change-Id: I1f9559bdb43ea1bae0575413748c9d9d0de58b99 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170023 Commit-Queue: Stephen Adams <sra@google.com> Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
This commit is contained in:
parent
9d3b932640
commit
e769817cdc
|
@ -42,6 +42,7 @@ bigint_test: Skip # Issue 31659
|
|||
[ $compiler == dartdevc || $compiler == dartdevk ]
|
||||
bigint_test/03: SkipSlow # modPow is very slow
|
||||
bigint_test/15: SkipSlow # modPow is very slow
|
||||
list_concurrent_modify_self_test: SkipSlow # missing check causes list to grow to whole heap
|
||||
uri_parse_test: Slow, Pass
|
||||
uri_test: Slow, Pass
|
||||
|
||||
|
|
17
tests/corelib/list_concurrent_modify_self_test.dart
Normal file
17
tests/corelib/list_concurrent_modify_self_test.dart
Normal file
|
@ -0,0 +1,17 @@
|
|||
// 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 "dart:collection";
|
||||
import "dart:typed_data";
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
void main() {
|
||||
testConcurrentAddSelf([1, 2, 3]);
|
||||
}
|
||||
|
||||
testConcurrentAddSelf(List list) {
|
||||
Expect.throws(() {
|
||||
list.addAll(list);
|
||||
}, (e) => e is ConcurrentModificationError, "testConcurrentAddSelf($list)");
|
||||
}
|
|
@ -21,9 +21,6 @@ void main() {
|
|||
testConcurrentModification(new Int16List(0).toList());
|
||||
testConcurrentModification(new Uint32List(0).toList());
|
||||
testConcurrentModification(new Int32List(0).toList());
|
||||
|
||||
testConcurrentAddSelf([]);
|
||||
testConcurrentAddSelf([1, 2, 3]);
|
||||
}
|
||||
|
||||
void testConcurrentModification(List<int> list) {
|
||||
|
@ -77,12 +74,6 @@ void testConcurrentModification(List<int> list) {
|
|||
}
|
||||
}
|
||||
|
||||
testConcurrentAddSelf(List list) {
|
||||
Expect.throws(() {
|
||||
list.addAll(list);
|
||||
}, (e) => e is ConcurrentModificationError, "testConcurrentAddSelf($list)");
|
||||
}
|
||||
|
||||
class MyList<E> extends ListBase<E> {
|
||||
// TODO(42496): Use a nullable list because insert() is implemented in terms
|
||||
// of length=. Change this back to `E` and remove the `as E` below when that
|
||||
|
|
|
@ -53,6 +53,7 @@ bigint_test: Skip # Issue 31659
|
|||
[ $compiler == dartdevc || $compiler == dartdevk ]
|
||||
bigint_test/03: SkipSlow # modPow is very slow
|
||||
bigint_test/15: SkipSlow # modPow is very slow
|
||||
list_concurrent_modify_self_test: SkipSlow # missing check causes list to grow to whole heap
|
||||
uri_parse_test: Slow, Pass
|
||||
uri_test: Slow, Pass
|
||||
|
||||
|
|
17
tests/corelib_2/list_concurrent_modify_self_test.dart
Normal file
17
tests/corelib_2/list_concurrent_modify_self_test.dart
Normal file
|
@ -0,0 +1,17 @@
|
|||
// 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 "dart:collection";
|
||||
import "dart:typed_data";
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
void main() {
|
||||
testConcurrentAddSelf([1, 2, 3]);
|
||||
}
|
||||
|
||||
testConcurrentAddSelf(List list) {
|
||||
Expect.throws(() {
|
||||
list.addAll(list);
|
||||
}, (e) => e is ConcurrentModificationError, "testConcurrentAddSelf($list)");
|
||||
}
|
|
@ -23,9 +23,6 @@ void main() {
|
|||
testConcurrentModification(new Int16List(0).toList());
|
||||
testConcurrentModification(new Uint32List(0).toList());
|
||||
testConcurrentModification(new Int32List(0).toList());
|
||||
|
||||
testConcurrentAddSelf([]);
|
||||
testConcurrentAddSelf([1, 2, 3]);
|
||||
}
|
||||
|
||||
void testConcurrentModification(List<int> list) {
|
||||
|
@ -79,12 +76,6 @@ void testConcurrentModification(List<int> list) {
|
|||
}
|
||||
}
|
||||
|
||||
testConcurrentAddSelf(List list) {
|
||||
Expect.throws(() {
|
||||
list.addAll(list);
|
||||
}, (e) => e is ConcurrentModificationError, "testConcurrentAddSelf($list)");
|
||||
}
|
||||
|
||||
class MyList<E> extends ListBase<E> {
|
||||
List<E> _source;
|
||||
MyList(this._source);
|
||||
|
|
Loading…
Reference in a new issue