blob: 97198283d7befc47dc5c68dc88eae228f7b76522 [file] [log] [blame]
// 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.
/**
* @assertion E singleWhere(bool test(E element))
* Returns the single element that satisfies [test].
* Checks all elements to see if test(element) returns true. If exactly one
* element satisfies test, that element is returned.
* @description Checks that the single element satisfying [test] is returned.
* @author msyabro
*/
import "dart:typed_data";
import "../../../Utils/expect.dart";
main() {
var l = new Uint16List.fromList([0, 0, 0, 0, 0, 5, 0, 0, 11, 0]);
var res = l.singleWhere((e) => e == 5 );
Expect.equals(5, res);
res = l.singleWhere((e) => e > 10 );
Expect.equals(11, res);
}