bb92055c47
Some of them use dart:io and/or bigints so they have been disabled on browsers and JS command-line tests. BUG= R=kmillikin@google.com Review URL: https://codereview.chromium.org/2548833002 .
34 lines
953 B
Dart
34 lines
953 B
Dart
import 'dart:math';
|
|
import 'package:kernel/type_propagation/canonicalizer.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
Random random = new Random(12345);
|
|
|
|
main() {
|
|
test('Uint31PairMap randomized tests', runTest);
|
|
}
|
|
|
|
runTest() {
|
|
const int trials = 1000;
|
|
const int insertions = 1000;
|
|
const int uniqueKeys = 900;
|
|
for (int trial = 0; trial < trials; ++trial) {
|
|
int nextValue = 1;
|
|
Map<Point<int>, int> trusted = <Point<int>, int>{};
|
|
Uint31PairMap candidate = new Uint31PairMap();
|
|
for (int i = 0; i < insertions; ++i) {
|
|
int x = random.nextInt(uniqueKeys);
|
|
int y = random.nextInt(uniqueKeys);
|
|
Point key = new Point(x, y);
|
|
int trustedValue = trusted[key];
|
|
int candidateValue = candidate.lookup(x, y);
|
|
expect(candidateValue, equals(trustedValue));
|
|
if (trustedValue == null) {
|
|
int newValue = nextValue++;
|
|
trusted[key] = newValue;
|
|
candidate.put(newValue);
|
|
}
|
|
}
|
|
}
|
|
}
|