blob: 96e99691d933c8f2c21eebbac26889afbe4c6943 [file] [log] [blame]
/*
* 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.
*/
/**
* @assertion final E single
* Returns the single element in this.
* If this is empty or has more than one element throws a StateError.
* @description Checks that the single element is returned.
* Checks that StateError is thrown if this list is empty or has more than one element
* @author kaigorodov
*/
import "dart:collection";
import "../../../Utils/expect.dart";
import "LinkedList.lib.dart";
var v;
void check(List a0) {
LinkedList a=toLinkedList(a0);
if (a.length==1) {
Expect.equals(a.first, a.single);
} else {
Expect.throws(() {
var v=a.single;
},
(e) => e is StateError
);
}
}
main() {
check([]);
List a = new List();
check(a);
a.add(0);
check(a);
a.length = 25476;
check(a);
a.clear();
a.length = 1;
check(a);
a = const[];
check(a);
a = const[1];
check(a);
}