blob: 7349dc7398edc33d288013bb86bae535dce679f1 [file] [log] [blame]
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.6
import 'package:test/test.dart';
import 'package:ui/ui.dart';
// The biggest integer value that can be represented in JavaScript is 1 << 53.
// However, the 1 << 53 expression cannot be used in JavaScript because that
// would apply the bitwise shift to a "number" (i.e. float64), which is
// meaningless. Instead, a decimal literal is used here.
const int _kBiggestExactJavaScriptInt = 9007199254740992;
void main() {
test('hashValues can hash lots of huge values effectively', () {
expect(
hashValues(
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
),
496984395,
);
// Hash a slightly smaller number to verify that the hash code is different.
expect(
hashValues(
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt - 1,
),
455584273,
);
});
test('hashList can hash lots of huge values effectively', () {
expect(
hashList(<int>[
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
]),
496984395,
);
// Hash a slightly smaller number to verify that the hash code is different.
expect(
hashList(<int>[
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt,
_kBiggestExactJavaScriptInt - 1,
]),
455584273,
);
});
}