blob: 78970f804372b90940cfb734e4a2234aed1d9ff0 [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 Iterable<E> takeWhile(bool test(E value))
/// ...
/// The elements can be computed by stepping through iterator until an element
/// is found where test(element) is false. At that point, the returned iterable
/// stops (its moveNext() returns false).
/// @description Checks that once an element does not satisfy the [test] every
/// later element is skipped.
/// @author msyabro
import "dart:typed_data";
import "../../../Utils/expect.dart";
Float32x4 pack(v) => new Float32x4.splat(v);
equal(obj1, obj2) {
var res = obj1.equal(obj2);
return res.flagX && res.flagY && res.flagZ && res.flagW;
}
main() {
var list = new Float32x4List.fromList(
[pack(1.0), pack(1.0), pack(2.0), pack(1.0), pack(1.0), pack(1.0)]);
var res = list.takeWhile((e) => e.x == 1.0);
Expect.equals(2, res.length);
for (int i = 1; i < 2; ++i) {
Expect.isTrue(equal(pack(1.0), res.elementAt(i)));
}
}