mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 16:41:07 +00:00
![Leaf Petersen](/assets/img/avatar_default.png)
Change-Id: Ib33169c3e0ffc870915c189404074a1dea472546 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196548 Reviewed-by: Bob Nystrom <rnystrom@google.com> Commit-Queue: Leaf Petersen <leafp@google.com>
45 lines
1 KiB
Dart
45 lines
1 KiB
Dart
// Copyright (c) 2014, 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.
|
|
//
|
|
// Dart Mint representations and type propagation issue.
|
|
// Testing Int32List and Uint32List loads.
|
|
//
|
|
// VMOptions=--optimization-counter-threshold=5 --no-use-osr --no-background-compilation
|
|
|
|
// @dart = 2.9
|
|
|
|
import 'dart:typed_data';
|
|
import "package:expect/expect.dart";
|
|
|
|
main() {
|
|
var a = new Uint32List(100);
|
|
a[2] = 3;
|
|
var res = sumIt1(a, 2);
|
|
Expect.equals(3 * 10, res);
|
|
res = sumIt1(a, 2);
|
|
Expect.equals(3 * 10, res);
|
|
var a1 = new Int32List(100);
|
|
a1[2] = 3;
|
|
res = sumIt2(a1, 2);
|
|
Expect.equals(3 * 10, res);
|
|
res = sumIt2(a1, 2);
|
|
Expect.equals(3 * 10, res);
|
|
}
|
|
|
|
sumIt1(Uint32List a, int n) {
|
|
var sum = 0;
|
|
for (int i = 0; i < 10; i++) {
|
|
sum += a[n];
|
|
}
|
|
return sum;
|
|
}
|
|
|
|
sumIt2(Int32List a, int n) {
|
|
var sum = 0;
|
|
for (int i = 0; i < 10; i++) {
|
|
sum += a[n];
|
|
}
|
|
return sum;
|
|
}
|