Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(668)

Unified Diff: runtime/tests/vm/dart/byte_array_test.dart

Issue 13137002: Adapt remaining dart:scalarlist tests to use dart:typeddata (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/tests/vm/dart/byte_array_optimized_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/tests/vm/dart/byte_array_test.dart
===================================================================
--- runtime/tests/vm/dart/byte_array_test.dart (revision 20623)
+++ runtime/tests/vm/dart/byte_array_test.dart (working copy)
@@ -5,14 +5,14 @@
// Library tag to be able to run in html test framework.
library byte_array_test;
-import 'dart:scalarlist';
+import 'dart:typeddata';
class ByteArrayTest {
static testInt8ListImpl(Int8List array) {
Expect.isTrue(array is List<int>);
Expect.equals(10, array.length);
- Expect.equals(1, array.bytesPerElement());
- Expect.equals(10, array.lengthInBytes());
+ Expect.equals(1, array.elementSizeInBytes);
+ Expect.equals(10, array.lengthInBytes);
Expect.listEquals([0, 0, 0, 0, 0,
0, 0, 0, 0, 0],
array);
@@ -105,8 +105,8 @@
static testUint8ListImpl(Uint8List array) {
Expect.isTrue(array is List<int>);
Expect.equals(10, array.length);
- Expect.equals(1, array.bytesPerElement());
- Expect.equals(10, array.lengthInBytes());
+ Expect.equals(1, array.elementSizeInBytes);
+ Expect.equals(10, array.lengthInBytes);
Expect.listEquals([0, 0, 0, 0, 0,
0, 0, 0, 0, 0],
array);
@@ -188,8 +188,8 @@
static testUint8ClampedListImpl(Uint8ClampedList array) {
Expect.isTrue(array is List<int>);
Expect.equals(10, array.length);
- Expect.equals(1, array.bytesPerElement());
- Expect.equals(10, array.lengthInBytes());
+ Expect.equals(1, array.elementSizeInBytes);
+ Expect.equals(10, array.lengthInBytes);
Expect.listEquals([0, 0, 0, 0, 0,
0, 0, 0, 0, 0],
array);
@@ -267,8 +267,8 @@
static testInt16ListImpl(Int16List array) {
Expect.isTrue(array is List<int>);
Expect.equals(10, array.length);
- Expect.equals(2, array.bytesPerElement());
- Expect.equals(20, array.lengthInBytes());
+ Expect.equals(2, array.elementSizeInBytes);
+ Expect.equals(20, array.lengthInBytes);
Expect.listEquals([0, 0, 0, 0, 0,
0, 0, 0, 0, 0],
array);
@@ -362,8 +362,8 @@
static testUint16ListImpl(Uint16List array) {
Expect.isTrue(array is List<int>);
Expect.equals(10, array.length);
- Expect.equals(2, array.bytesPerElement());
- Expect.equals(20, array.lengthInBytes());
+ Expect.equals(2, array.elementSizeInBytes);
+ Expect.equals(20, array.lengthInBytes);
Expect.listEquals([0, 0, 0, 0, 0,
0, 0, 0, 0, 0],
array);
@@ -445,8 +445,8 @@
static testInt32ListImpl(Int32List array) {
Expect.isTrue(array is List<int>);
Expect.equals(10, array.length);
- Expect.equals(4, array.bytesPerElement());
- Expect.equals(40, array.lengthInBytes());
+ Expect.equals(4, array.elementSizeInBytes);
+ Expect.equals(40, array.lengthInBytes);
Expect.listEquals([0, 0, 0, 0, 0,
0, 0, 0, 0, 0],
array);
@@ -546,8 +546,8 @@
static testUint32ListImpl(Uint32List array) {
Expect.isTrue(array is List<int>);
Expect.equals(10, array.length);
- Expect.equals(4, array.bytesPerElement());
- Expect.equals(40, array.lengthInBytes());
+ Expect.equals(4, array.elementSizeInBytes);
+ Expect.equals(40, array.lengthInBytes);
Expect.listEquals([0, 0, 0, 0, 0,
0, 0, 0, 0, 0],
array);
@@ -633,8 +633,8 @@
static testInt64ListImpl(Int64List array) {
Expect.isTrue(array is List<int>);
Expect.equals(10, array.length);
- Expect.equals(8, array.bytesPerElement());
- Expect.equals(80, array.lengthInBytes());
+ Expect.equals(8, array.elementSizeInBytes);
+ Expect.equals(80, array.lengthInBytes);
Expect.listEquals([0, 0, 0, 0, 0,
0, 0, 0, 0, 0],
array);
@@ -735,8 +735,8 @@
static testUint64ListImpl(Uint64List array) {
Expect.isTrue(array is List<int>);
Expect.equals(10, array.length);
- Expect.equals(8, array.bytesPerElement());
- Expect.equals(80, array.lengthInBytes());
+ Expect.equals(8, array.elementSizeInBytes);
+ Expect.equals(80, array.lengthInBytes);
Expect.listEquals([0, 0, 0, 0, 0,
0, 0, 0, 0, 0],
array);
@@ -821,8 +821,8 @@
static testFloat32ListImpl(Float32List array) {
Expect.isTrue(array is List<double>);
Expect.equals(10, array.length);
- Expect.equals(4, array.bytesPerElement());
- Expect.equals(40, array.lengthInBytes());
+ Expect.equals(4, array.elementSizeInBytes);
+ Expect.equals(40, array.lengthInBytes);
Expect.listEquals([0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0],
array);
@@ -894,8 +894,8 @@
static testFloat64ListImpl(Float64List array) {
Expect.isTrue(array is List<double>);
Expect.equals(10, array.length);
- Expect.equals(8, array.bytesPerElement());
- Expect.equals(80, array.lengthInBytes());
+ Expect.equals(8, array.elementSizeInBytes);
+ Expect.equals(80, array.lengthInBytes);
Expect.listEquals([0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0],
array);
@@ -965,9 +965,9 @@
static testByteList() {
var array = new Uint8List(8);
Expect.equals(8, array.length);
- Expect.equals(8, array.lengthInBytes());
- var byte_array = array.asByteArray(0, array.lengthInBytes());
- Expect.equals(8, byte_array.lengthInBytes());
+ Expect.equals(8, array.lengthInBytes);
+ var byte_array = new ByteData.view(array.buffer);
+ Expect.equals(8, byte_array.lengthInBytes);
Expect.throws(() { byte_array.getInt8(-1); },
(e) { return e is RangeError; });
Expect.throws(() { byte_array.getUint8(-1); },
@@ -1109,39 +1109,39 @@
static testInt8ListViewImpl(var array) {
Expect.equals(12, array.length);
- Expect.equals(1, array.bytesPerElement());
- Expect.equals(12, array.lengthInBytes());
+ Expect.equals(1, array.elementSizeInBytes);
+ Expect.equals(12, array.lengthInBytes);
for (int i = 0; i < array.length; ++i) {
array[i] = 0xFF;
}
- Expect.throws(() { new Int8List.view(array.asByteArray(), -1); },
+ Expect.throws(() { new Int8List.view(array.buffer, -1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Int8List.view(array.asByteArray(), 0, -1); },
+ Expect.throws(() { new Int8List.view(array.buffer, 0, -1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Int8List.view(array.asByteArray(),
- array.lengthInBytes() + 1); },
+ Expect.throws(() { new Int8List.view(array.buffer,
+ array.lengthInBytes + 1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Int8List.view(array.asByteArray(),
+ Expect.throws(() { new Int8List.view(array.buffer,
0, array.length + 1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Int8List.view(array.asByteArray(),
+ Expect.throws(() { new Int8List.view(array.buffer,
array.length - 1, 2); },
(e) { return e is RangeError; });
- var empty = new Int8List.view(array.asByteArray(),
- array.lengthInBytes());
+ var empty = new Int8List.view(array.buffer,
+ array.lengthInBytes);
Expect.isTrue(empty is List<int>);
Expect.isTrue(empty is Int8List);
Expect.equals(0, empty.length);
- var whole = new Int8List.view(array.asByteArray());
+ var whole = new Int8List.view(array.buffer);
Expect.isTrue(whole is List<int>);
Expect.isTrue(whole is Int8List);
Expect.equals(12, whole.length);
- var view = new Int8List.view(array.asByteArray(), 1, array.length - 2);
+ var view = new Int8List.view(array.buffer, 1, array.length - 2);
Expect.isTrue(view is List<int>);
Expect.isTrue(view is Int8List);
Expect.equals(10, view.length);
- Expect.equals(1, view.bytesPerElement());
- Expect.equals(10, view.lengthInBytes());
+ Expect.equals(1, view.elementSizeInBytes);
+ Expect.equals(10, view.lengthInBytes);
Expect.listEquals([-1, -1, -1, -1, -1,
-1, -1, -1, -1, -1],
view);
@@ -1242,39 +1242,39 @@
static testUint8ListViewImpl(var array) {
Expect.isTrue(array is List<int>);
Expect.equals(12, array.length);
- Expect.equals(1, array.bytesPerElement());
- Expect.equals(12, array.lengthInBytes());
+ Expect.equals(1, array.elementSizeInBytes);
+ Expect.equals(12, array.lengthInBytes);
for (int i = 0; i < array.length; ++i) {
array[i] = -1;
}
- Expect.throws(() { new Uint8List.view(array.asByteArray(), -1); },
+ Expect.throws(() { new Uint8List.view(array.buffer, -1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Uint8List.view(array.asByteArray(), 0, -1); },
+ Expect.throws(() { new Uint8List.view(array.buffer, 0, -1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Uint8List.view(array.asByteArray(),
- array.lengthInBytes() + 1); },
+ Expect.throws(() { new Uint8List.view(array.buffer,
+ array.lengthInBytes + 1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Uint8List.view(array.asByteArray(),
+ Expect.throws(() { new Uint8List.view(array.buffer,
0, array.length + 1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Uint8List.view(array.asByteArray(),
+ Expect.throws(() { new Uint8List.view(array.buffer,
array.length - 1, 2); },
(e) { return e is RangeError; });
- var empty = new Uint8List.view(array.asByteArray(),
- array.lengthInBytes());
+ var empty = new Uint8List.view(array.buffer,
+ array.lengthInBytes);
Expect.isTrue(empty is List<int>);
Expect.isTrue(empty is Uint8List);
Expect.equals(0, empty.length);
- var whole = new Uint8List.view(array.asByteArray());
+ var whole = new Uint8List.view(array.buffer);
Expect.isTrue(whole is List<int>);
Expect.isTrue(whole is Uint8List);
Expect.equals(12, whole.length);
- var view = new Uint8List.view(array.asByteArray(), 1, array.length - 2);
+ var view = new Uint8List.view(array.buffer, 1, array.length - 2);
Expect.isTrue(view is List<int>);
Expect.isTrue(view is Uint8List);
Expect.equals(10, view.length);
- Expect.equals(1, view.bytesPerElement());
- Expect.equals(10, view.lengthInBytes());
+ Expect.equals(1, view.elementSizeInBytes);
+ Expect.equals(10, view.lengthInBytes);
Expect.listEquals([0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF],
view);
@@ -1355,39 +1355,39 @@
static testInt16ListViewImpl(var array) {
Expect.equals(24, array.length);
- Expect.equals(1, array.bytesPerElement());
- Expect.equals(24, array.lengthInBytes());
+ Expect.equals(1, array.elementSizeInBytes);
+ Expect.equals(24, array.lengthInBytes);
for (int i = 0; i < array.length; ++i) {
array[i] = 0xFF;
}
- Expect.throws(() { new Int16List.view(array.asByteArray(), -1); },
+ Expect.throws(() { new Int16List.view(array.buffer, -1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Int16List.view(array.asByteArray(), 0, -1); },
+ Expect.throws(() { new Int16List.view(array.buffer, 0, -1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Int16List.view(array.asByteArray(),
- array.lengthInBytes() + 1); },
+ Expect.throws(() { new Int16List.view(array.buffer,
+ array.lengthInBytes + 1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Int16List.view(array.asByteArray(),
- 0, array.length + 1); },
+ Expect.throws(() { new Int16List.view(array.buffer,
+ 0, array.length + 1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Int16List.view(array.asByteArray(),
- array.length - 1, 2); },
+ Expect.throws(() { new Int16List.view(array.buffer,
+ array.length - 1, 2); },
(e) { return e is RangeError; });
- var empty = new Int16List.view(array.asByteArray(),
- array.lengthInBytes());
+ var empty = new Int16List.view(array.buffer,
+ array.lengthInBytes);
Expect.isTrue(empty is List<int>);
Expect.isTrue(empty is Int16List);
Expect.equals(0, empty.length);
- var whole = new Int16List.view(array.asByteArray());
+ var whole = new Int16List.view(array.buffer);
Expect.isTrue(whole is List<int>);
Expect.isTrue(whole is Int16List);
Expect.equals(12, whole.length);
- var view = new Int16List.view(array.asByteArray(), 2, 10);
+ var view = new Int16List.view(array.buffer, 2, 10);
Expect.isTrue(view is List<int>);
Expect.isTrue(view is Int16List);
Expect.equals(10, view.length);
- Expect.equals(2, view.bytesPerElement());
- Expect.equals(20, view.lengthInBytes());
+ Expect.equals(2, view.elementSizeInBytes);
+ Expect.equals(20, view.lengthInBytes);
Expect.listEquals([-1, -1, -1, -1, -1,
-1, -1, -1, -1, -1],
view);
@@ -1496,39 +1496,39 @@
static testUint16ListViewImpl(var array) {
Expect.isTrue(array is List<int>);
Expect.equals(24, array.length);
- Expect.equals(1, array.bytesPerElement());
- Expect.equals(24, array.lengthInBytes());
+ Expect.equals(1, array.elementSizeInBytes);
+ Expect.equals(24, array.lengthInBytes);
for (int i = 0; i < array.length; ++i) {
array[i] = -1;
}
- Expect.throws(() { new Uint16List.view(array.asByteArray(), -1); },
+ Expect.throws(() { new Uint16List.view(array.buffer, -1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Uint16List.view(array.asByteArray(), 0, -1); },
+ Expect.throws(() { new Uint16List.view(array.buffer, 0, -1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Uint16List.view(array.asByteArray(),
- array.lengthInBytes() + 1); },
+ Expect.throws(() { new Uint16List.view(array.buffer,
+ array.lengthInBytes + 1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Uint16List.view(array.asByteArray(),
+ Expect.throws(() { new Uint16List.view(array.buffer,
0, array.length + 1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Uint16List.view(array.asByteArray(),
+ Expect.throws(() { new Uint16List.view(array.buffer,
array.length - 1, 2); },
(e) { return e is RangeError; });
- var empty = new Uint16List.view(array.asByteArray(),
- array.lengthInBytes());
+ var empty = new Uint16List.view(array.buffer,
+ array.lengthInBytes);
Expect.isTrue(empty is List<int>);
Expect.isTrue(empty is Uint16List);
Expect.equals(0, empty.length);
- var whole = new Uint16List.view(array.asByteArray());
+ var whole = new Uint16List.view(array.buffer);
Expect.isTrue(whole is List<int>);
Expect.isTrue(whole is Uint16List);
Expect.equals(12, whole.length);
- var view = new Uint16List.view(array.asByteArray(), 2, 10);
+ var view = new Uint16List.view(array.buffer, 2, 10);
Expect.isTrue(view is List<int>);
Expect.isTrue(view is Uint16List);
Expect.equals(10, view.length);
- Expect.equals(2, view.bytesPerElement());
- Expect.equals(20, view.lengthInBytes());
+ Expect.equals(2, view.elementSizeInBytes);
+ Expect.equals(20, view.lengthInBytes);
Expect.listEquals([0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF],
view);
@@ -1615,39 +1615,39 @@
static testInt32ListView() {
var array = new Uint8List(48);
Expect.equals(48, array.length);
- Expect.equals(1, array.bytesPerElement());
- Expect.equals(48, array.lengthInBytes());
+ Expect.equals(1, array.elementSizeInBytes);
+ Expect.equals(48, array.lengthInBytes);
for (int i = 0; i < array.length; ++i) {
array[i] = 0xFF;
}
- Expect.throws(() { new Int32List.view(array.asByteArray(), -1); },
+ Expect.throws(() { new Int32List.view(array.buffer, -1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Int32List.view(array.asByteArray(), 0, -1); },
+ Expect.throws(() { new Int32List.view(array.buffer, 0, -1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Int32List.view(array.asByteArray(),
- array.lengthInBytes() + 1); },
+ Expect.throws(() { new Int32List.view(array.buffer,
+ array.lengthInBytes + 1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Int32List.view(array.asByteArray(),
+ Expect.throws(() { new Int32List.view(array.buffer,
0, array.length + 1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Int32List.view(array.asByteArray(),
+ Expect.throws(() { new Int32List.view(array.buffer,
array.length - 1, 2); },
(e) { return e is RangeError; });
- var empty = new Int32List.view(array.asByteArray(),
- array.lengthInBytes());
+ var empty = new Int32List.view(array.buffer,
+ array.lengthInBytes);
Expect.isTrue(empty is List<int>);
Expect.isTrue(empty is Int32List);
Expect.equals(0, empty.length);
- var whole = new Int32List.view(array.asByteArray());
+ var whole = new Int32List.view(array.buffer);
Expect.isTrue(whole is List<int>);
Expect.isTrue(whole is Int32List);
Expect.equals(12, whole.length);
- var view = new Int32List.view(array.asByteArray(), 4, 10);
+ var view = new Int32List.view(array.buffer, 4, 10);
Expect.isTrue(view is List<int>);
Expect.isTrue(view is Int32List);
Expect.equals(10, view.length);
- Expect.equals(4, view.bytesPerElement());
- Expect.equals(40, view.lengthInBytes());
+ Expect.equals(4, view.elementSizeInBytes);
+ Expect.equals(40, view.lengthInBytes);
Expect.listEquals([-1, -1, -1, -1, -1,
-1, -1, -1, -1, -1],
view);
@@ -1773,39 +1773,39 @@
static testUint32ListViewImpl(var array) {
Expect.isTrue(array is List<int>);
Expect.equals(48, array.length);
- Expect.equals(1, array.bytesPerElement());
- Expect.equals(48, array.lengthInBytes());
+ Expect.equals(1, array.elementSizeInBytes);
+ Expect.equals(48, array.lengthInBytes);
for (int i = 0; i < array.length; ++i) {
array[i] = -1;
}
- Expect.throws(() { new Uint32List.view(array.asByteArray(), -1); },
+ Expect.throws(() { new Uint32List.view(array.buffer, -1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Uint32List.view(array.asByteArray(), 0, -1); },
+ Expect.throws(() { new Uint32List.view(array.buffer, 0, -1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Uint32List.view(array.asByteArray(),
- array.lengthInBytes() + 1); },
+ Expect.throws(() { new Uint32List.view(array.buffer,
+ array.lengthInBytes + 1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Uint32List.view(array.asByteArray(),
+ Expect.throws(() { new Uint32List.view(array.buffer,
0, array.length + 1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Uint32List.view(array.asByteArray(),
+ Expect.throws(() { new Uint32List.view(array.buffer,
array.length - 1, 2); },
(e) { return e is RangeError; });
- var empty = new Uint32List.view(array.asByteArray(),
- array.lengthInBytes());
+ var empty = new Uint32List.view(array.buffer,
+ array.lengthInBytes);
Expect.isTrue(empty is List<int>);
Expect.isTrue(empty is Uint32List);
Expect.equals(0, empty.length);
- var whole = new Uint32List.view(array.asByteArray());
+ var whole = new Uint32List.view(array.buffer);
Expect.isTrue(whole is List<int>);
Expect.isTrue(whole is Uint32List);
Expect.equals(12, whole.length);
- var view = new Uint32List.view(array.asByteArray(), 4, 10);
+ var view = new Uint32List.view(array.buffer, 4, 10);
Expect.isTrue(view is List<int>);
Expect.isTrue(view is Uint32List);
Expect.equals(10, view.length);
- Expect.equals(4, view.bytesPerElement());
- Expect.equals(40, view.lengthInBytes());
+ Expect.equals(4, view.elementSizeInBytes);
+ Expect.equals(40, view.lengthInBytes);
Expect.listEquals([0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF],
view);
@@ -1908,39 +1908,39 @@
static testInt64ListViewImpl(var array) {
Expect.equals(96, array.length);
- Expect.equals(1, array.bytesPerElement());
- Expect.equals(96, array.lengthInBytes());
+ Expect.equals(1, array.elementSizeInBytes);
+ Expect.equals(96, array.lengthInBytes);
for (int i = 0; i < array.length; ++i) {
array[i] = 0xFF;
}
- Expect.throws(() { new Int64List.view(array.asByteArray(), -1); },
+ Expect.throws(() { new Int64List.view(array.buffer, -1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Int64List.view(array.asByteArray(), 0, -1); },
+ Expect.throws(() { new Int64List.view(array.buffer, 0, -1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Int64List.view(array.asByteArray(),
- array.lengthInBytes() + 1); },
+ Expect.throws(() { new Int64List.view(array.buffer,
+ array.lengthInBytes + 1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Int64List.view(array.asByteArray(),
+ Expect.throws(() { new Int64List.view(array.buffer,
0, array.length + 1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Int64List.view(array.asByteArray(),
+ Expect.throws(() { new Int64List.view(array.buffer,
array.length - 1, 2); },
(e) { return e is RangeError; });
- var empty = new Int64List.view(array.asByteArray(),
- array.lengthInBytes());
+ var empty = new Int64List.view(array.buffer,
+ array.lengthInBytes);
Expect.isTrue(empty is List<int>);
Expect.isTrue(empty is Int64List);
Expect.equals(0, empty.length);
- var whole = new Int64List.view(array.asByteArray());
+ var whole = new Int64List.view(array.buffer);
Expect.isTrue(whole is List<int>);
Expect.isTrue(whole is Int64List);
Expect.equals(12, whole.length);
- var view = new Int64List.view(array.asByteArray(), 8, 10);
+ var view = new Int64List.view(array.buffer, 8, 10);
Expect.isTrue(view is List<int>);
Expect.isTrue(view is Int64List);
Expect.equals(10, view.length);
- Expect.equals(8, view.bytesPerElement());
- Expect.equals(80, view.lengthInBytes());
+ Expect.equals(8, view.elementSizeInBytes);
+ Expect.equals(80, view.lengthInBytes);
Expect.listEquals([-1, -1, -1, -1, -1,
-1, -1, -1, -1, -1],
view);
@@ -2110,39 +2110,39 @@
static testUint64ListViewImpl(var array) {
Expect.isTrue(array is List<int>);
Expect.equals(96, array.length);
- Expect.equals(1, array.bytesPerElement());
- Expect.equals(96, array.lengthInBytes());
+ Expect.equals(1, array.elementSizeInBytes);
+ Expect.equals(96, array.lengthInBytes);
for (int i = 0; i < array.length; ++i) {
array[i] = -1;
}
- Expect.throws(() { new Uint64List.view(array.asByteArray(), -1); },
+ Expect.throws(() { new Uint64List.view(array.buffer, -1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Uint64List.view(array.asByteArray(), 0, -1); },
+ Expect.throws(() { new Uint64List.view(array.buffer, 0, -1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Uint64List.view(array.asByteArray(),
- array.lengthInBytes() + 1); },
+ Expect.throws(() { new Uint64List.view(array.buffer,
+ array.lengthInBytes + 1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Uint64List.view(array.asByteArray(),
+ Expect.throws(() { new Uint64List.view(array.buffer,
0, array.length + 1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Uint64List.view(array.asByteArray(),
+ Expect.throws(() { new Uint64List.view(array.buffer,
array.length - 1, 2); },
(e) { return e is RangeError; });
- var empty = new Uint64List.view(array.asByteArray(),
- array.lengthInBytes());
+ var empty = new Uint64List.view(array.buffer,
+ array.lengthInBytes);
Expect.isTrue(empty is List<int>);
Expect.isTrue(empty is Uint64List);
Expect.equals(0, empty.length);
- var whole = new Uint64List.view(array.asByteArray());
+ var whole = new Uint64List.view(array.buffer);
Expect.isTrue(whole is List<int>);
Expect.isTrue(whole is Uint64List);
Expect.equals(12, whole.length);
- var view = new Uint64List.view(array.asByteArray(), 8, 10);
+ var view = new Uint64List.view(array.buffer, 8, 10);
Expect.isTrue(view is List<int>);
Expect.isTrue(view is Uint64List);
Expect.equals(10, view.length);
- Expect.equals(8, view.bytesPerElement());
- Expect.equals(80, view.lengthInBytes());
+ Expect.equals(8, view.elementSizeInBytes);
+ Expect.equals(80, view.lengthInBytes);
Expect.listEquals([0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF,
0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF,
0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF,
@@ -2273,39 +2273,39 @@
static testFloat32ListViewImpl(var array) {
Expect.isTrue(array is List<int>);
Expect.equals(12, array.length);
- Expect.equals(4, array.bytesPerElement());
- Expect.equals(48, array.lengthInBytes());
+ Expect.equals(4, array.elementSizeInBytes);
+ Expect.equals(48, array.lengthInBytes);
for (int i = 0; i < array.length; ++i) {
array[i] = 0xBF800000;
}
- Expect.throws(() { new Float32List.view(array.asByteArray(), -1); },
+ Expect.throws(() { new Float32List.view(array.buffer, -1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Float32List.view(array.asByteArray(), 0, -1); },
+ Expect.throws(() { new Float32List.view(array.buffer, 0, -1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Float32List.view(array.asByteArray(),
- array.lengthInBytes() + 1); },
+ Expect.throws(() { new Float32List.view(array.buffer,
+ array.lengthInBytes + 1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Float32List.view(array.asByteArray(),
- 0, array.lengthInBytes() + 1); },
+ Expect.throws(() { new Float32List.view(array.buffer,
+ 0, array.lengthInBytes + 1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Float32List.view(array.asByteArray(),
- array.lengthInBytes() - 1, 2); },
+ Expect.throws(() { new Float32List.view(array.buffer,
+ array.lengthInBytes - 1, 2); },
(e) { return e is RangeError; });
- var empty = new Float32List.view(array.asByteArray(),
- array.lengthInBytes());
+ var empty = new Float32List.view(array.buffer,
+ array.lengthInBytes);
Expect.isTrue(empty is List<double>);
Expect.isTrue(empty is Float32List);
Expect.equals(0, empty.length);
- var whole = new Float32List.view(array.asByteArray());
+ var whole = new Float32List.view(array.buffer);
Expect.isTrue(whole is List<double>);
Expect.isTrue(whole is Float32List);
Expect.equals(12, whole.length);
- var view = new Float32List.view(array.asByteArray(), 4, 10);
+ var view = new Float32List.view(array.buffer, 4, 10);
Expect.isTrue(view is List<double>);
Expect.isTrue(view is Float32List);
Expect.equals(10, view.length);
- Expect.equals(4, view.bytesPerElement());
- Expect.equals(40, view.lengthInBytes());
+ Expect.equals(4, view.elementSizeInBytes);
+ Expect.equals(40, view.lengthInBytes);
Expect.listEquals([-1.0, -1.0, -1.0, -1.0, -1.0,
-1.0, -1.0, -1.0, -1.0, -1.0],
view);
@@ -2382,39 +2382,39 @@
static testFloat64ListViewImpl(var array) {
Expect.isTrue(array is List<int>);
Expect.equals(12, array.length);
- Expect.equals(8, array.bytesPerElement());
- Expect.equals(96, array.lengthInBytes());
+ Expect.equals(8, array.elementSizeInBytes);
+ Expect.equals(96, array.lengthInBytes);
for (int i = 0; i < array.length; ++i) {
array[i] = 0xBFF0000000000000;
}
- Expect.throws(() { new Float64List.view(array.asByteArray(), -1); },
+ Expect.throws(() { new Float64List.view(array.buffer, -1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Float64List.view(array.asByteArray(), 0, -1); },
+ Expect.throws(() { new Float64List.view(array.buffer, 0, -1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Float64List.view(array.asByteArray(),
- array.lengthInBytes() + 1); },
+ Expect.throws(() { new Float64List.view(array.buffer,
+ array.lengthInBytes + 1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Float64List.view(array.asByteArray(),
- 0, array.lengthInBytes() + 1); },
+ Expect.throws(() { new Float64List.view(array.buffer,
+ 0, array.lengthInBytes + 1); },
(e) { return e is RangeError; });
- Expect.throws(() { new Float64List.view(array.asByteArray(),
- array.lengthInBytes() - 1, 2); },
+ Expect.throws(() { new Float64List.view(array.buffer,
+ array.lengthInBytes - 1, 2); },
(e) { return e is RangeError; });
- var empty = new Float64List.view(array.asByteArray(),
- array.lengthInBytes());
+ var empty = new Float64List.view(array.buffer,
+ array.lengthInBytes);
Expect.isTrue(empty is List<double>);
Expect.isTrue(empty is Float64List);
Expect.equals(0, empty.length);
- var whole = new Float64List.view(array.asByteArray());
+ var whole = new Float64List.view(array.buffer);
Expect.isTrue(whole is List<double>);
Expect.isTrue(whole is Float64List);
Expect.equals(12, whole.length);
- var view = new Float64List.view(array.asByteArray(), 8, 10);
+ var view = new Float64List.view(array.buffer, 8, 10);
Expect.isTrue(view is List<double>);
Expect.isTrue(view is Float64List);
Expect.equals(10, view.length);
- Expect.equals(8, view.bytesPerElement());
- Expect.equals(80, view.lengthInBytes());
+ Expect.equals(8, view.elementSizeInBytes);
+ Expect.equals(80, view.lengthInBytes);
Expect.listEquals([-1.0, -1.0, -1.0, -1.0, -1.0,
-1.0, -1.0, -1.0, -1.0, -1.0],
view);
@@ -2500,7 +2500,7 @@
testUint64List();
testFloat32List();
testFloat64List();
- testByteList();
+
testInt8ListView();
testUint8ListView();
testInt16ListView();
@@ -2511,6 +2511,8 @@
testUint64ListView();
testFloat32ListView();
testFloat64ListView();
+
+ testByteList();
}
}
« no previous file with comments | « runtime/tests/vm/dart/byte_array_optimized_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698