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

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

Issue 1219103002: Deal with Javascript integer limitations in heap snapshot processing to handle 64-bit target VMs. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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/tests/service/address_mapper_test.dart ('k') | no next file » | 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 import 'package:observatory/object_graph.dart';
7 import 'package:expect/expect.dart';
8 import 'dart:typed_data';
9
10 testRoundTrip(final int n) {
11 var bytes = [];
12 var remaining = n;
13 while (remaining > 127) {
14 bytes.add(remaining & 127);
15 remaining = remaining >> 7;
16 }
17 bytes.add(remaining + 128);
18
19 print("Encoded $n as $bytes");
20
21 var typedBytes = new ByteData.view(new Uint8List.fromList(bytes).buffer);
22 var stream = new ReadStream([typedBytes]);
23 stream.readUnsigned();
24
25 Expect.equals(n == 0, stream.isZero);
26
27 Expect.equals((n >> 0) & 0xFFFFFFF, stream.low);
28 Expect.equals((n >> 28) & 0xFFFFFFF, stream.mid);
29 Expect.equals((n >> 56) & 0xFFFFFFF, stream.high);
30
31 const kMaxUint32 = (1 << 32) - 1;
32 if (n > kMaxUint32) {
33 Expect.equals(kMaxUint32, stream.clampedUint32);
34 } else {
35 Expect.equals(n, stream.clampedUint32);
36 }
37
38 Expect.equals(bytes.length, stream.position);
39 }
40
41 main() {
42 const kMaxUint64 = (1 << 64) - 1;
43
44 var n = 3;
45 while (n < kMaxUint64) {
46 testRoundTrip(n);
47 n <<= 1;
48 }
49
50 n = 5;
51 while (n < kMaxUint64) {
52 testRoundTrip(n);
53 n <<= 1;
54 }
55 }
OLDNEW
« no previous file with comments | « runtime/observatory/tests/service/address_mapper_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698