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 TypedArrays1Test; | 5 library TypedArrays1Test; |
| 6 |
6 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
7 import 'package:unittest/html_individual_config.dart'; | 8 import 'package:unittest/html_individual_config.dart'; |
8 import 'dart:html'; | 9 import 'dart:html'; |
9 import 'dart:typed_data'; | 10 import 'dart:typed_data'; |
10 | 11 |
11 main() { | 12 main() { |
12 useHtmlIndividualConfiguration(); | 13 useHtmlIndividualConfiguration(); |
13 | 14 |
14 var isnumList = predicate((x) => x is List<num>, 'is a List<num>'); | 15 var isnumList = predicate((x) => x is List<num>, 'is a List<num>'); |
15 var isStringList = predicate((x) => x is List<String>, 'is a List<String>'); | 16 var isStringList = predicate((x) => x is List<String>, 'is a List<String>'); |
(...skipping 10 matching lines...) Expand all Loading... |
26 expect(() { | 27 expect(() { |
27 var a = new Float32List(10); | 28 var a = new Float32List(10); |
28 expect(a.length, 10); | 29 expect(a.length, 10); |
29 expect(a.lengthInBytes, 40); | 30 expect(a.lengthInBytes, 40); |
30 expect(a[4], 0); | 31 expect(a[4], 0); |
31 }, expectation); | 32 }, expectation); |
32 }); | 33 }); |
33 | 34 |
34 test('aliasTest', () { | 35 test('aliasTest', () { |
35 expect(() { | 36 expect(() { |
36 var a1 = new Uint8List.fromList([0,0,1,0x45]); | 37 var a1 = new Uint8List.fromList([0, 0, 1, 0x45]); |
37 var a2 = new Float32List.view(a1.buffer); | 38 var a2 = new Float32List.view(a1.buffer); |
38 | 39 |
39 expect(a1.lengthInBytes, a2.lengthInBytes); | 40 expect(a1.lengthInBytes, a2.lengthInBytes); |
40 | 41 |
41 expect(a2.length, 1); | 42 expect(a2.length, 1); |
42 | 43 |
43 // 0x45010000 = 2048+16 | 44 // 0x45010000 = 2048+16 |
44 expect(a2[0], 2048 + 16); | 45 expect(a2[0], 2048 + 16); |
45 | 46 |
46 a1[2] = 0; | 47 a1[2] = 0; |
(...skipping 16 matching lines...) Expand all Loading... |
63 expect(() { | 64 expect(() { |
64 var a = new Float32List(10); | 65 var a = new Float32List(10); |
65 expect(a, isList); | 66 expect(a, isList); |
66 expect(a, isnumList); | 67 expect(a, isnumList); |
67 expect(a, isNot(isStringList)); | 68 expect(a, isNot(isStringList)); |
68 }, expectation); | 69 }, expectation); |
69 }); | 70 }); |
70 } | 71 } |
71 }); | 72 }); |
72 } | 73 } |
OLD | NEW |