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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/observatory/tests/service/address_mapper_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/observatory/tests/service/read_stream_test.dart
diff --git a/runtime/observatory/tests/service/read_stream_test.dart b/runtime/observatory/tests/service/read_stream_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5bd2689bcfa9829ad91bd877fac532052bad7488
--- /dev/null
+++ b/runtime/observatory/tests/service/read_stream_test.dart
@@ -0,0 +1,55 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// VMOptions=--compile_all --error_on_bad_type --error_on_bad_override
+
+import 'package:observatory/object_graph.dart';
+import 'package:expect/expect.dart';
+import 'dart:typed_data';
+
+testRoundTrip(final int n) {
+ var bytes = [];
+ var remaining = n;
+ while (remaining > 127) {
+ bytes.add(remaining & 127);
+ remaining = remaining >> 7;
+ }
+ bytes.add(remaining + 128);
+
+ print("Encoded $n as $bytes");
+
+ var typedBytes = new ByteData.view(new Uint8List.fromList(bytes).buffer);
+ var stream = new ReadStream([typedBytes]);
+ stream.readUnsigned();
+
+ Expect.equals(n == 0, stream.isZero);
+
+ Expect.equals((n >> 0) & 0xFFFFFFF, stream.low);
+ Expect.equals((n >> 28) & 0xFFFFFFF, stream.mid);
+ Expect.equals((n >> 56) & 0xFFFFFFF, stream.high);
+
+ const kMaxUint32 = (1 << 32) - 1;
+ if (n > kMaxUint32) {
+ Expect.equals(kMaxUint32, stream.clampedUint32);
+ } else {
+ Expect.equals(n, stream.clampedUint32);
+ }
+
+ Expect.equals(bytes.length, stream.position);
+}
+
+main() {
+ const kMaxUint64 = (1 << 64) - 1;
+
+ var n = 3;
+ while (n < kMaxUint64) {
+ testRoundTrip(n);
+ n <<= 1;
+ }
+
+ n = 5;
+ while (n < kMaxUint64) {
+ testRoundTrip(n);
+ n <<= 1;
+ }
+}
« 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