mirror of
https://github.com/dart-lang/sdk
synced 2024-09-18 21:41:19 +00:00
2dcd56ef43
There are far too many files here to review everyone carefully. Spot checking most of the diffs look good as test code is generally written with less care than application code so lots of ugly formatting get through. If people notice files where the automated formatting bothers them feel free to comment indicating file names and I'll move spaces within comments to make the formatting cleaner and use comments to force block formatting as I have done for other case where formatting looked bad. BUG= R=efortuna@google.com Review-Url: https://codereview.chromium.org/2771453003 .
52 lines
1.3 KiB
Dart
52 lines
1.3 KiB
Dart
// Copyright (c) 2012, 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.
|
|
|
|
library typed_arrays_5_test;
|
|
|
|
import 'package:unittest/unittest.dart';
|
|
import 'package:unittest/html_config.dart';
|
|
import 'dart:html';
|
|
import 'dart:typed_data';
|
|
|
|
main() {
|
|
useHtmlConfiguration();
|
|
|
|
// Only perform tests if ArrayBuffer is supported.
|
|
if (!Platform.supportsTypedData) {
|
|
return;
|
|
}
|
|
|
|
test('filter_dynamic', () {
|
|
var a = new Float32List(1024);
|
|
for (int i = 0; i < a.length; i++) {
|
|
a[i] = i.toDouble();
|
|
}
|
|
|
|
expect(a.where((x) => x >= 1000).length, equals(24));
|
|
});
|
|
|
|
test('filter_typed', () {
|
|
Float32List a = new Float32List(1024);
|
|
for (int i = 0; i < a.length; i++) {
|
|
a[i] = i.toDouble();
|
|
}
|
|
|
|
expect(a.where((x) => x >= 1000).length, equals(24));
|
|
});
|
|
|
|
test('contains', () {
|
|
var a = new Int16List(1024);
|
|
for (int i = 0; i < a.length; i++) {
|
|
a[i] = i;
|
|
}
|
|
expect(a.contains(0), isTrue);
|
|
expect(a.contains(5), isTrue);
|
|
expect(a.contains(1023), isTrue);
|
|
|
|
expect(a.contains(-5), isFalse);
|
|
expect(a.contains(-1), isFalse);
|
|
expect(a.contains(1024), isFalse);
|
|
});
|
|
}
|