OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library typed_arrays_5_test; | 5 library typed_arrays_5_test; |
6 import '../../pkg/unittest/lib/unittest.dart'; | 6 import '../../pkg/unittest/lib/unittest.dart'; |
7 import '../../pkg/unittest/lib/html_config.dart'; | 7 import '../../pkg/unittest/lib/html_config.dart'; |
8 import 'dart:html'; | 8 import 'dart:html'; |
9 | 9 |
10 main() { | 10 main() { |
11 useHtmlConfiguration(); | 11 useHtmlConfiguration(); |
12 | 12 |
13 // Only perform tests if ArrayBuffer is supported. | 13 // Only perform tests if ArrayBuffer is supported. |
14 if (!ArrayBuffer.supported) { | 14 if (!ArrayBuffer.supported) { |
15 return; | 15 return; |
16 } | 16 } |
17 | 17 |
18 test('filter_dynamic', () { | 18 test('filter_dynamic', () { |
19 var a = new Float32Array(1024); | 19 var a = new Float32Array(1024); |
20 for (int i = 0; i < a.length; i++) { | 20 for (int i = 0; i < a.length; i++) { |
21 a[i] = i; | 21 a[i] = i; |
22 } | 22 } |
23 | 23 |
24 expect(a.filter((x) => x >= 1000).length, equals(24)); | 24 expect(a.where((x) => x >= 1000).length, equals(24)); |
25 }); | 25 }); |
26 | 26 |
27 test('filter_typed', () { | 27 test('filter_typed', () { |
28 Float32Array a = new Float32Array(1024); | 28 Float32Array a = new Float32Array(1024); |
29 for (int i = 0; i < a.length; i++) { | 29 for (int i = 0; i < a.length; i++) { |
30 a[i] = i; | 30 a[i] = i; |
31 } | 31 } |
32 | 32 |
33 expect(a.filter((x) => x >= 1000).length, equals(24)); | 33 expect(a.where((x) => x >= 1000).length, equals(24)); |
34 }); | 34 }); |
35 | 35 |
36 test('contains', () { | 36 test('contains', () { |
37 var a = new Int16Array(1024); | 37 var a = new Int16Array(1024); |
38 for (int i = 0; i < a.length; i++) { | 38 for (int i = 0; i < a.length; i++) { |
39 a[i] = i; | 39 a[i] = i; |
40 } | 40 } |
41 expect(a.contains(0), isTrue); | 41 expect(a.contains(0), isTrue); |
42 expect(a.contains(5), isTrue); | 42 expect(a.contains(5), isTrue); |
43 expect(a.contains(1023), isTrue); | 43 expect(a.contains(1023), isTrue); |
44 | 44 |
45 expect(a.contains(-5), isFalse); | 45 expect(a.contains(-5), isFalse); |
46 expect(a.contains(-1), isFalse); | 46 expect(a.contains(-1), isFalse); |
47 expect(a.contains(1024), isFalse); | 47 expect(a.contains(1024), isFalse); |
48 }); | 48 }); |
49 } | 49 } |
OLD | NEW |