mirror of
https://github.com/dart-lang/sdk
synced 2024-09-19 15:01:29 +00:00
b998b10f3e
Change-Id: I3a31632ce28fb87a410b759d092c7ebc9393574d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128306 Commit-Queue: Bob Nystrom <rnystrom@google.com> Auto-Submit: Bob Nystrom <rnystrom@google.com> Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
50 lines
1.3 KiB
Dart
50 lines
1.3 KiB
Dart
// Copyright (c) 2017, 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=--optimization_counter_threshold=10 --no-background-compilation
|
|
|
|
// Test for dart:typed_data (in particular, ByteData.get/setUint64 and
|
|
// UInt64List) with limited 64-bit integers.
|
|
|
|
import 'dart:typed_data';
|
|
import "package:expect/expect.dart";
|
|
|
|
testByteData() {
|
|
ByteData data = new ByteData(17);
|
|
|
|
data.setInt64(5, -0x1122334455667788);
|
|
Expect.equals(-0x1122334455667788, data.getUint64(5));
|
|
|
|
data.setUint32(5, 0x10203040);
|
|
Expect.equals(0x10203040aa998878, data.getUint64(5));
|
|
|
|
data.setUint64(3, -1);
|
|
Expect.equals(-1, data.getInt64(3));
|
|
|
|
data.setUint64(7, 0x7fedcba987654321);
|
|
Expect.equals(0x7fedcba987654321, data.getInt64(7));
|
|
}
|
|
|
|
testUint64List() {
|
|
Uint64List u64 = new Uint64List(3);
|
|
Int64List i64 = new Int64List.view(u64.buffer);
|
|
|
|
i64[0] = 0x7fffffffffffffff;
|
|
i64[1] = -1;
|
|
i64[2] = 42;
|
|
|
|
Expect.equals(0x7fffffffffffffff, u64[0]);
|
|
Expect.equals(-1, u64[1]);
|
|
Expect.equals(42, u64[2]);
|
|
|
|
u64[0] = -900000000000000;
|
|
Expect.equals(-900000000000000, i64[0]);
|
|
}
|
|
|
|
main() {
|
|
for (int i = 0; i < 20; i++) {
|
|
testByteData();
|
|
testUint64List();
|
|
}
|
|
}
|