mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
[tests, dart2js] Fix test using minified type names
1. Add `Object` and `Map` to the very short list of names that are unminified in the app. 2. Tweak test to avoid testing minified name. Change-Id: Ide0cedc2950b5392eb6963403a48c0f89cd1b50a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332368 Commit-Queue: Stephen Adams <sra@google.com> Reviewed-by: Sigmund Cherem <sigmund@google.com>
This commit is contained in:
parent
8ee403e86c
commit
cb52932c72
8 changed files with 20 additions and 21 deletions
|
@ -1799,25 +1799,27 @@ class FragmentEmitter {
|
|||
/// This global maps minified names for selected classes (some important
|
||||
/// core classes, and some native classes) to their unminified names.
|
||||
js.Property emitMangledGlobalNames() {
|
||||
List<js.Property> names = [];
|
||||
|
||||
CommonElements commonElements = _closedWorld.commonElements;
|
||||
// We want to keep the original names for the most common core classes when
|
||||
// calling toString on them.
|
||||
List<ClassEntity> nativeClassesNeedingUnmangledName = [
|
||||
List<ClassEntity> commonClassesNeedingUnmangledName = [
|
||||
commonElements.intClass,
|
||||
commonElements.doubleClass,
|
||||
commonElements.numClass,
|
||||
commonElements.stringClass,
|
||||
commonElements.boolClass,
|
||||
commonElements.nullClass,
|
||||
commonElements.listClass
|
||||
commonElements.listClass,
|
||||
commonElements.objectClass,
|
||||
commonElements.mapClass,
|
||||
];
|
||||
// TODO(floitsch): this should probably be on a per-fragment basis.
|
||||
nativeClassesNeedingUnmangledName.forEach((element) {
|
||||
names.add(js.Property(
|
||||
js.quoteName(_namer.className(element)), js.string(element.name)));
|
||||
});
|
||||
|
||||
List<js.Property> names = [
|
||||
for (final element in commonClassesNeedingUnmangledName)
|
||||
js.Property(
|
||||
js.quoteName(_namer.className(element)), js.string(element.name))
|
||||
];
|
||||
|
||||
return js.Property(
|
||||
js.string(MANGLED_GLOBAL_NAMES), js.ObjectInitializer(names));
|
||||
|
|
|
@ -16,9 +16,10 @@ main() {
|
|||
check(fn('int', ''), () => 1); // closure.
|
||||
|
||||
var s = new Xyzzy().runtimeType.toString();
|
||||
if (s.length <= 3) return; // dart2js --minify has minified names.
|
||||
|
||||
Expect.equals('Xyzzy', s, 'runtime type of plain class prints as class name');
|
||||
if (!s.startsWith('minified')) {
|
||||
Expect.equals(
|
||||
'Xyzzy', s, 'runtime type of plain class prints as class name');
|
||||
}
|
||||
|
||||
check(fn('void', 'String, dynamic'), check);
|
||||
|
||||
|
|
|
@ -17,8 +17,7 @@ main() {
|
|||
var typeLiteralToString = "${b}";
|
||||
Expect.equals(runtimeTypeToString, typeLiteralToString);
|
||||
|
||||
if ('$Object' == 'Object') {
|
||||
// `true` if non-minified.
|
||||
if (!runtimeTypeToString.contains('minified:')) {
|
||||
Expect.equals("Foo<num>", runtimeTypeToString);
|
||||
Expect.equals("Foo<num>", typeLiteralToString);
|
||||
}
|
||||
|
|
|
@ -16,8 +16,7 @@ main() {
|
|||
local2(int i) => i;
|
||||
|
||||
var toString = '${local1.runtimeType}';
|
||||
if ('$Object' == 'Object') {
|
||||
// `true` if non-minified.
|
||||
if (!toString.contains('minified:')) {
|
||||
Expect.equals("Closure0Args", toString);
|
||||
}
|
||||
print(toString);
|
||||
|
|
|
@ -16,8 +16,7 @@ main() {
|
|||
local2<T>(t) => t;
|
||||
|
||||
var toString = '${local1.runtimeType}';
|
||||
if ('$Object' == 'Object') {
|
||||
// `true` if non-minified.
|
||||
if (!toString.contains('minified:')) {
|
||||
Expect.equals("Closure", toString);
|
||||
}
|
||||
print(toString);
|
||||
|
|
|
@ -17,7 +17,7 @@ test<Q>() {
|
|||
local2(int i) => i;
|
||||
|
||||
var toString = '${local1.runtimeType}';
|
||||
if ('$Object' == 'Object') {
|
||||
if (!toString.contains('minified:')) {
|
||||
// `true` if non-minified.
|
||||
Expect.equals("Closure", toString);
|
||||
}
|
||||
|
|
|
@ -10,8 +10,7 @@ main() {
|
|||
T id<T>(T t) => t;
|
||||
int Function(int) x = id;
|
||||
var toString = "${x.runtimeType}";
|
||||
if ('$Object' == 'Object') {
|
||||
// `true` if non-minified.
|
||||
if (!toString.contains('minified:')) {
|
||||
// The signature of `id` is not otherwise needed so the instantiation
|
||||
// wrapper doesn't have a function type.
|
||||
// The type parameter is present since it is required because `==`
|
||||
|
|
|
@ -37,7 +37,7 @@ foo<Y>(int x) {
|
|||
|
||||
void main() {
|
||||
var name = '${Wrap}';
|
||||
if ('$Object' != 'Object') return; // minified
|
||||
if (name.contains('minified:')) return; // minified
|
||||
|
||||
Expect.equals(
|
||||
'Wrap<(int) => ((int) => void) => (int) => void>',
|
||||
|
|
Loading…
Reference in a new issue