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 import 'dart:html'; | 5 import 'dart:html'; |
6 import 'dart:typed_data'; | 6 import 'dart:typed_data'; |
7 | 7 |
8 import 'package:expect/minitest.dart'; | 8 import 'package:expect/minitest.dart'; |
9 | 9 |
10 main() { | 10 main() { |
11 // Only perform tests if ArrayBuffer is supported. | 11 // Only perform tests if ArrayBuffer is supported. |
12 if (!Platform.supportsTypedData) { | 12 if (!Platform.supportsTypedData) { |
13 return; | 13 return; |
14 } | 14 } |
15 | 15 |
16 test('constructor', () { | 16 test('constructor', () { |
17 var a = new Int8List(100); | 17 var a = new Int8List(100); |
18 expect(a.lengthInBytes, 100); | 18 expect(a.lengthInBytes, 100); |
19 }); | 19 }); |
20 | 20 |
21 test('sublist1', () { | 21 test('sublist1', () { |
22 var a = new Int8List(100); | 22 var a = new Int8List(100); |
23 var s = a.sublist(10, 40); | 23 var s = a.sublist(10, 40); |
24 expect(s.length, 30); | 24 expect(s.length, 30); |
25 }); | 25 }); |
26 | 26 |
27 test('sublist2', () { | 27 test('sublist2', () { |
28 var a = new Int8List(100); | 28 var a = new Int8List(100); |
29 expect(() => a.sublist(10, 400), throwsRangeError); | 29 expect(() => a.sublist(10, 400), throwsRangeError); |
30 }); | 30 }); |
31 | 31 |
32 test('sublist3', () { | 32 test('sublist3', () { |
33 var a = new Int8List(100); | 33 var a = new Int8List(100); |
34 expect(() => a.sublist(50, 10), throwsRangeError); | 34 expect(() => a.sublist(50, 10), throwsRangeError); |
35 }); | 35 }); |
36 | 36 |
37 test('sublist4', () { | 37 test('sublist4', () { |
38 var a = new Int8List(100); | 38 var a = new Int8List(100); |
39 expect(() => a.sublist(-90, -30), throwsRangeError); | 39 expect(() => a.sublist(-90, -30), throwsRangeError); |
40 }); | 40 }); |
41 } | 41 } |
OLD | NEW |