Skip to content

Commit

Permalink
Version 3.3.0-68.0.dev
Browse files Browse the repository at this point in the history
Merge 73de586 into dev
  • Loading branch information
Dart CI committed Oct 27, 2023
2 parents 2133efd + 73de586 commit 050a16a
Show file tree
Hide file tree
Showing 40 changed files with 394 additions and 509 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
13 changes: 9 additions & 4 deletions tests/language/function_subtype/bound_closure7_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,18 @@ void main() {
Expect.isTrue(f is Foo<Foo<int>>);
Expect.isFalse(f is Foo<int>);
Expect.isFalse(f is Foo<Object>);
Expect.throwsTypeError(() => f(f));
Expect.throwsTypeError(() => f(42));
if (!dart2jsProductionMode) {
Expect.throwsTypeError(() => f(f));
Expect.throwsTypeError(() => f(42));
}

Foo<Foo<int>> bazInt = baz; // implicit instantiation baz<int>
f = bazInt;
Expect.isTrue(f(bar));
Expect.isFalse(f is Foo<int>);
Expect.throwsTypeError(() => f(f));
Expect.throwsTypeError(() => f(42));

if (!dart2jsProductionMode) {
Expect.throwsTypeError(() => f(f));
Expect.throwsTypeError(() => f(42));
}
}
2 changes: 1 addition & 1 deletion tests/language/function_subtype/checked0_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class C<T> {
void test(String nameOfT, bool expectedResult) {
check(bool expectedResult, f()) {
if (!expectedResult) {
Expect.throwsTypeError(f);
if (!dart2jsProductionMode) Expect.throwsTypeError(f);
} else {
f();
}
Expand Down
20 changes: 14 additions & 6 deletions tests/language/identity/closure2_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,21 @@ var myIdentical = identical;

main() {
// Mint (2^63).
// TODO(rnystrom): Figure out how to change this to work on the web.
Expect.isTrue(myIdentical(0x8000000000000000, 0x8000000000000000));
Expect.isFalse(myIdentical(0x8000000000000000, 0x8000000000000001));

// Different types.
Expect.isFalse(myIdentical(42, 42.0));
if (!webNumbers) {
Expect.isFalse(myIdentical(0x8000000000000000, 0x8000000000000000 + 1));

// NaN handling.
Expect.isTrue(myIdentical(double.nan, double.nan));
// Different types.
Expect.isFalse(myIdentical(42, 42.0));

// NaN handling.
Expect.isTrue(myIdentical(double.nan, double.nan));
} else {
// Web numbers have less precision, conflate int and double values, and have
// an incorrect implementation of `identical` for NaNs.
Expect.isTrue(myIdentical(0x8000000000000000, 0x8000000000000000 + 1));
Expect.isTrue(myIdentical(42, 42.0));
Expect.isFalse(myIdentical(double.nan, double.nan));
}
}
3 changes: 3 additions & 0 deletions tests/language/identity/closure_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,7 @@ main() {
// Null handling.
Expect.isFalse(myIdentical(42, null));
Expect.isTrue(myIdentical(null, null));

// Assigning to the variable prevents dart2js from optimizing calls.
myIdentical = identical;
}
16 changes: 16 additions & 0 deletions tests/language/identity/nan_identical_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@ double createOtherNAN() {
}

main() {
if (webNumbers) {
// (1) The web compilers elect to generate smaller, faster code for
// `identical` using `===`, with the result that `identical(NaN, NaN)` is
// false.
//
// (2) In JavaScript different NaN values are treated the same by
// `Object.is`, and can only be distinguished by writing the bits into typed
// data, making it costly to compare NaN values.

// Validate current behaviour so we will be alerted if (1) changes.
Expect.isFalse(checkIdentical(double.nan, -double.nan));
Expect.isFalse(checkIdentical(double.nan, double.nan));
Expect.isFalse(checkIdentical(-double.nan, -double.nan));
return;
}

var otherNAN = createOtherNAN();
for (int i = 0; i < 100; i++) {
Expect.isFalse(checkIdentical(double.nan, -double.nan));
Expand Down
7 changes: 4 additions & 3 deletions tests/language/type_object/runtime_type_function_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
23 changes: 0 additions & 23 deletions tests/lib/html/element_animate_omit_timing_test.dart

This file was deleted.

19 changes: 8 additions & 11 deletions tests/lib/html/fileapi_directory_reader_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ library fileapi;
import 'dart:async';
import 'dart:html';

import 'package:async_helper/async_helper.dart';
import 'package:async_helper/async_minitest.dart';

class FileAndDir {
Expand All @@ -16,20 +15,18 @@ class FileAndDir {
FileAndDir(this.file, this.dir);
}

late FileSystem fs;

main() async {
getFileSystem() async {
fs = await window.requestFileSystem(100);
}

// Do the boilerplate to get several files and directories created to then
// test the functions that use those items.
Future doDirSetup(String testName) async {
await getFileSystem();

var file = await fs.root!.createFile('file_$testName') as FileEntry;
var dir = await fs.root!.createDirectory('dir_$testName') as DirectoryEntry;
final fs = await window.requestFileSystem(100);
// Prepend this file name to prevent collisions among tests runnning on the
// same browser.
const prefix = 'fileapi_directory_reader_';
var file =
await fs.root!.createFile('${prefix}file_$testName') as FileEntry;
var dir = await fs.root!.createDirectory('${prefix}dir_$testName')
as DirectoryEntry;
return new Future.value(new FileAndDir(file, dir));
}

Expand Down
53 changes: 20 additions & 33 deletions tests/lib/html/fileapi_directory_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,28 @@
// 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.

library fileapi;

import 'dart:async';
import 'dart:html';

import 'package:async_helper/async_helper.dart';
import 'package:async_helper/async_minitest.dart';

class FileAndDir {
FileEntry file;
DirectoryEntry dir;
FileAndDir(this.file, this.dir);
}

late FileSystem fs;

main() async {
getFileSystem() async {
fs = await window.requestFileSystem(100);
}

if (FileSystem.supported) {
await getFileSystem();

test('directoryDoesntExist', () async {
try {
await fs.root!.getDirectory('directory2');
} on DomException catch (error) {
expect(DomException.NOT_FOUND, error.name);
}
});

test('directoryCreate', () async {
var entry = await fs.root!.createDirectory('directory3');
expect(entry.name, equals('directory3'));
});
}
main() {
if (!FileSystem.supported) return;
// Prepend this file name to prevent collisions among tests runnning on the
// same browser.
const prefix = 'fileapi_directory_';

test('directoryDoesntExist', () async {
final fs = await window.requestFileSystem(100);
try {
await fs.root!.getDirectory('${prefix}directory2');
} on DomException catch (error) {
expect(DomException.NOT_FOUND, error.name);
}
});

test('directoryCreate', () async {
final fs = await window.requestFileSystem(100);
var entry = await fs.root!.createDirectory('${prefix}directory3');
expect(entry.name, equals('${prefix}directory3'));
});
}
95 changes: 44 additions & 51 deletions tests/lib/html/fileapi_entry_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
// 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.

library fileapi;

import 'dart:async';
import 'dart:html';

import 'package:async_helper/async_helper.dart';
import 'package:async_helper/async_minitest.dart';

class FileAndDir {
Expand All @@ -16,62 +13,58 @@ class FileAndDir {
FileAndDir(this.file, this.dir);
}

late FileSystem fs;

main() async {
getFileSystem() async {
return await window.requestFileSystem(100).then((FileSystem fileSystem) {
fs = fileSystem;
});
}
main() {
if (!FileSystem.supported) return;
// Prepend this file name to prevent collisions among tests runnning on the
// same browser.
const prefix = 'fileapi_entry_';

// Do the boilerplate to get several files and directories created to then
// test the functions that use those items.
Future doDirSetup(String testName) async {
await getFileSystem();

var file = await fs.root!.createFile('file_$testName') as FileEntry;
var dir = await fs.root!.createDirectory('dir_$testName') as DirectoryEntry;
Future doDirSetup(FileSystem fs, String testName) async {
var file =
await fs.root!.createFile('${prefix}file_$testName') as FileEntry;
var dir = await fs.root!.createDirectory('${prefix}dir_$testName')
as DirectoryEntry;
return new Future.value(new FileAndDir(file, dir));
}

if (FileSystem.supported) {
test('copy_move', () async {
var fileAndDir = await doDirSetup('copyTo');
var entry =
await fileAndDir.file.copyTo(fileAndDir.dir, name: 'copiedFile');
expect(entry.isFile, true, reason: "Expected File");
expect(entry.name, 'copiedFile');
test('copy_move', () async {
final fs = await window.requestFileSystem(100);
var fileAndDir = await doDirSetup(fs, 'copyTo');
var entry =
await fileAndDir.file.copyTo(fileAndDir.dir, name: 'copiedFile');
expect(entry.isFile, true, reason: "Expected File");
expect(entry.name, 'copiedFile');

// getParent
fileAndDir = await doDirSetup('getParent');
entry = await fileAndDir.file.getParent();
expect(entry.name, '');
expect(entry.isDirectory, true, reason: "Expected Directory");
// getParent
fileAndDir = await doDirSetup(fs, 'getParent');
entry = await fileAndDir.file.getParent();
expect(entry.name, '');
expect(entry.isDirectory, true, reason: "Expected Directory");

// moveTo
fileAndDir = await doDirSetup('moveTo');
entry = await fileAndDir.file.moveTo(fileAndDir.dir, name: 'movedFile');
expect(entry.name, 'movedFile');
expect(entry.fullPath, '/dir_moveTo/movedFile');
// moveTo
fileAndDir = await doDirSetup(fs, 'moveTo');
entry = await fileAndDir.file.moveTo(fileAndDir.dir, name: 'movedFile');
expect(entry.name, 'movedFile');
expect(entry.fullPath, '/${prefix}dir_moveTo/movedFile');

try {
entry = await fs.root!.getFile('file4');
fail("File file4 should not exist.");
} on DomException catch (error) {
expect(DomException.NOT_FOUND, error.name);
}
try {
entry = await fs.root!.getFile('${prefix}file4');
fail("File ${prefix}file4 should not exist.");
} on DomException catch (error) {
expect(DomException.NOT_FOUND, error.name);
}

// remove
fileAndDir = await doDirSetup('remove');
expect('file_remove', fileAndDir.file.name);
await fileAndDir.file.remove();
try {
var entry = await fileAndDir.dir.getFile(fileAndDir.file.name);
fail("file not removed");
} on DomException catch (error) {
expect(DomException.NOT_FOUND, error.name);
}
});
}
// remove
fileAndDir = await doDirSetup(fs, 'remove');
expect('${prefix}file_remove', fileAndDir.file.name);
await fileAndDir.file.remove();
try {
await fileAndDir.dir.getFile(fileAndDir.file.name);
fail("file not removed");
} on DomException catch (error) {
expect(DomException.NOT_FOUND, error.name);
}
});
}
Loading

0 comments on commit 050a16a

Please sign in to comment.