mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
* change from build_runner to dart2js * add internalBootstrapBrowserTest to some of the tests * add internalBootstrapBrowserTest to all remaining tests * make tests build in paralel. Total time dropped from 586 to 177 seconds for 8 core MacBook * change isolates with pool * fixing analysis errors * skipping canvaskit tests for ios-safari * copy image files to the build directory * adding internalBootstrapBrowserTest to newly added tests * add internalBootstrapBrowserTest to faling path iterator test * necessary changes to make chrome windows work * in windows test in chrome instead of edge. our edge code was for legacy edge * do not run golden unit tests on Windows LUCI bots for now * addressing reviewer comments. Adding a method for deciding when to run integration tests. * remove lines that I forgot to remove * fixing analysis error. add issue for todo * add bootstap to a test file * adding bootstrap to another test * add internalBootstrapBrowserTest to a golden test * return test result in bat file. use archieve package to unzip * fixing logs for chrome_installer * use archieve and archieve entity instead of dynamic * adding comments for windows platform archieve part * addressing reviewer comments * change readme file
94 lines
3.8 KiB
Dart
94 lines
3.8 KiB
Dart
// 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.
|
|
|
|
import 'dart:typed_data';
|
|
import 'package:test/bootstrap/browser.dart';
|
|
import 'package:test/test.dart';
|
|
import 'package:ui/src/engine.dart';
|
|
|
|
void main() {
|
|
internalBootstrapBrowserTest(() => testMain);
|
|
}
|
|
|
|
void testMain() {
|
|
group('Float Int conversions', (){
|
|
test('Should convert signbit to 2\'s compliment', () {
|
|
expect(signBitTo2sCompliment(0), 0);
|
|
expect(signBitTo2sCompliment(0x7fffffff).toUnsigned(32), 0x7fffffff);
|
|
expect(signBitTo2sCompliment(0x80000000), 0);
|
|
expect(signBitTo2sCompliment(0x8f000000).toUnsigned(32), 0xf1000000);
|
|
expect(signBitTo2sCompliment(0x8fffffff).toUnsigned(32), 0xf0000001);
|
|
expect(signBitTo2sCompliment(0xffffffff).toUnsigned(32), 0x80000001);
|
|
expect(signBitTo2sCompliment(0x8f000000), -251658240);
|
|
expect(signBitTo2sCompliment(0x8fffffff), -268435455);
|
|
expect(signBitTo2sCompliment(0xffffffff), -2147483647);
|
|
});
|
|
|
|
test('Should convert 2s compliment to signbit', () {
|
|
expect(twosComplimentToSignBit(0), 0);
|
|
expect(twosComplimentToSignBit(0x7fffffff), 0x7fffffff);
|
|
expect(twosComplimentToSignBit(0), 0);
|
|
expect(twosComplimentToSignBit(0xf1000000).toRadixString(16), 0x8f000000.toRadixString(16));
|
|
expect(twosComplimentToSignBit(0xf0000001), 0x8fffffff);
|
|
expect(twosComplimentToSignBit(0x80000001), 0xffffffff);
|
|
expect(twosComplimentToSignBit(0x81234561), 0xfedcba9f);
|
|
expect(twosComplimentToSignBit(-5), 0x80000005);
|
|
});
|
|
|
|
test('Should convert float to bits', () {
|
|
Float32List floatList = Float32List(1);
|
|
floatList[0] = 0;
|
|
expect(float2Bits(floatList, 0), 0);
|
|
floatList[0] = 0.1;
|
|
expect(float2Bits(floatList, 0).toUnsigned(32).toRadixString(16), 0x3dcccccd.toRadixString(16));
|
|
floatList[0] = 123456.0;
|
|
expect(float2Bits(floatList, 0).toUnsigned(32).toRadixString(16), 0x47f12000.toRadixString(16));
|
|
floatList[0] = -0.1;
|
|
expect(float2Bits(floatList, 0).toUnsigned(32).toRadixString(16), 0xbdcccccd.toRadixString(16));
|
|
floatList[0] = -123456.0;
|
|
expect(float2Bits(floatList, 0).toUnsigned(32).toRadixString(16), 0xc7f12000.toRadixString(16));
|
|
});
|
|
});
|
|
group('Comparison', () {
|
|
test('Should compare equality based on ulps', () {
|
|
// If number of floats between a=1.1 and b are below 16, equals should
|
|
// return true.
|
|
final double a = 1.1;
|
|
int aBits = floatAs2sCompliment(a);
|
|
double b = twosComplimentAsFloat(aBits + 1);
|
|
expect(almostEqualUlps(a, b), true);
|
|
b = twosComplimentAsFloat(aBits + 15);
|
|
expect(almostEqualUlps(a, b), true);
|
|
b = twosComplimentAsFloat(aBits + 16);
|
|
expect(almostEqualUlps(a, b), false);
|
|
|
|
// Test between variant of equalUlps.
|
|
b = twosComplimentAsFloat(aBits + 1);
|
|
expect(almostBequalUlps(a, b), true);
|
|
b = twosComplimentAsFloat(aBits + 1);
|
|
expect(almostBequalUlps(a, b), true);
|
|
b = twosComplimentAsFloat(aBits + 2);
|
|
expect(almostBequalUlps(a, b), false);
|
|
});
|
|
|
|
test('Should compare 2 coordinates based on ulps', () {
|
|
double a = 1.1;
|
|
int aBits = floatAs2sCompliment(a);
|
|
double b = twosComplimentAsFloat(aBits + 1);
|
|
expect(approximatelyEqual(5.0, a, 5.0, b), true);
|
|
b = twosComplimentAsFloat(aBits + 16);
|
|
expect(approximatelyEqual(5.0, a, 5.0, b), true);
|
|
|
|
// Increase magnitude which should start checking with ulps rather than
|
|
// fltEpsilon.
|
|
a = 3000000.1;
|
|
aBits = floatAs2sCompliment(a);
|
|
b = twosComplimentAsFloat(aBits + 1);
|
|
expect(approximatelyEqual(5.0, a, 5.0, b), true);
|
|
b = twosComplimentAsFloat(aBits + 16);
|
|
expect(approximatelyEqual(5.0, a, 5.0, b), false);
|
|
});
|
|
});
|
|
}
|