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

Side by Side Diff: runtime/observatory/tests/service/typed_data_test.dart

Issue 1157003003: Add TypedData instance kinds. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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 unified diff | Download patch
« no previous file with comments | « runtime/observatory/lib/src/service/object.dart ('k') | runtime/vm/json_stream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
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.
4 // VMOptions=--compile-all --error_on_bad_type --error_on_bad_override
5
6 library typed_data_test;
7
8 import 'dart:typed_data';
9 import 'package:observatory/service_io.dart';
10 import 'package:unittest/unittest.dart';
11 import 'test_helper.dart';
12
13 var int8List;
14 var int16List;
15 var int32List;
16 var int64List;
17
18 var uint8List;
19 var uint16List;
20 var uint32List;
21 var uint64List;
22 var uint8ClampedList;
23
24 var float32List;
25 var float64List;
26
27 var int32x4;
28 var float32x4;
29 var float64x2;
30 var int32x4List;
31 var float32x4List;
32 var float64x2List;
33
34 void script() {
35 int8List = new Int8List(2);
36 int8List[0] = -1;
37 int8List[1] = -2;
38 int16List = new Int16List(2);
39 int16List[0] = -3;
40 int16List[1] = -4;
41 int32List = new Int32List(2);
42 int32List[0] = -5;
43 int32List[1] = -6;
44 int64List = new Int64List(2);
45 int64List[0] = -7;
46 int64List[1] = -8;
47
48 uint8List = new Uint8List(2);
49 uint8List[0] = 1;
50 uint8List[1] = 2;
51 uint16List = new Uint16List(2);
52 uint16List[0] = 3;
53 uint16List[1] = 4;
54 uint32List = new Uint32List(2);
55 uint32List[0] = 5;
56 uint32List[1] = 6;
57 uint64List = new Uint64List(2);
58 uint64List[0] = 7;
59 uint64List[1] = 8;
60 uint8ClampedList = new Uint8ClampedList(2);
61 uint8ClampedList[0] = 9;
62 uint8ClampedList[1] = 10;
63
64 float32List = new Float32List(2);
65 float32List[0] = 4.25;
66 float32List[1] = 8.50;
67 float64List = new Float64List(2);
68 float64List[0] = 16.25;
69 float64List[1] = 32.50;
70
71 int32x4 = new Int32x4(1, 2, 3, 4);
72 float32x4 = new Float32x4(1.0, 2.0, 4.0, 8.0);
73 float64x2 = new Float64x2(16.0, 32.0);
74 int32x4List = new Int32x4List(2);
75 float32x4List = new Float32x4List(2);
76 float64x2List = new Float64x2List(2);
77 }
78
79 var tests = [
80
81 (Isolate isolate) async {
82 script();
83 var lib = await isolate.rootLibrary.load();
84
85 // Pre-load all the fields so we don't use await below and get better
86 // stacktraces.
87 for (var v in lib.variables) {
88 await v.load();
89 await v.staticValue.load();
90 }
91
92 expectTypedData(name, expectedValue) {
93 var variable = lib.variables.singleWhere((v) => v.name == name);
94 var actualValue = variable.staticValue.typedElements;
95 if (expectedValue is Int32x4List) {
96 expect(actualValue.length, equals(expectedValue.length));
97 for (var i = 0; i < actualValue.length; i++) {
98 expect(actualValue[i].x, equals(expectedValue[i].x));
99 expect(actualValue[i].y, equals(expectedValue[i].y));
100 expect(actualValue[i].z, equals(expectedValue[i].z));
101 expect(actualValue[i].w, equals(expectedValue[i].w));
102 }
103 } else if (expectedValue is Float32x4List) {
104 expect(actualValue.length, equals(expectedValue.length));
105 for (var i = 0; i < actualValue.length; i++) {
106 expect(actualValue[i].x, equals(expectedValue[i].x));
107 expect(actualValue[i].y, equals(expectedValue[i].y));
108 expect(actualValue[i].z, equals(expectedValue[i].z));
109 expect(actualValue[i].w, equals(expectedValue[i].w));
110 }
111 } else if (expectedValue is Float64x2List) {
112 expect(actualValue.length, equals(expectedValue.length));
113 for (var i = 0; i < actualValue.length; i++) {
114 expect(actualValue[i].x, equals(expectedValue[i].x));
115 expect(actualValue[i].y, equals(expectedValue[i].y));
116 }
117 } else {
118 expect(actualValue, equals(expectedValue));
119 }
120 }
121 expectTypedData("int8List", int8List);
122 expectTypedData("int16List", int16List);
123 expectTypedData("int32List", int32List);
124 expectTypedData("int64List", int64List);
125 expectTypedData("uint8List", uint8List);
126 expectTypedData("uint16List", uint16List);
127 expectTypedData("uint32List", uint32List);
128 expectTypedData("uint64List", uint64List);
129 expectTypedData("uint8ClampedList", uint8ClampedList);
130 expectTypedData("float32List", float32List);
131 expectTypedData("float64List", float64List);
132 expectTypedData("int32x4List", int32x4List);
133 expectTypedData("float32x4List", float32x4List);
134 expectTypedData("float64x2List", float64x2List);
135 },
136
137 ];
138
139 main(args) => runIsolateTests(args, tests, testeeBefore: script);
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/service/object.dart ('k') | runtime/vm/json_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698