dart-sdk/tests/web_2/deferred_function_types1_test.dart
Sigmund Cherem 4bcb0950f1 [web] fix improperly migrated tests.
These tests had bugs intronduced during the the null-safety test
migration. Surprisingly the failures didn't show up on some
configurations because the tests were previosly not using the
async-helper wrapper. As a result, the test was logged as completed and
passing before it was done executing. Together this was the cause why
these tests failed in d8 and flaked in firefox.

This CL fixes both issues. A few notes:
* web_2 tests didn't have bugs, but this CL also adds asyncHelper to
  match
* it's quite possible that many of these `is` tests are optimized away
  in dart2js. I added a couple `confuse` calls when the trivial tests
  were highlighted by the analyzer directly (not based on whether or not
  dart2js optimized them away).

Change-Id: I8f58c0b0b850023764524f57201eada89a5c0d6d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332062
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2023-10-25 15:37:50 +00:00

24 lines
808 B
Dart

// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
// 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.
// @dart = 2.7
// dart2jsOptions=--strong
import 'package:async_helper/async_helper.dart';
import 'package:expect/expect.dart';
import 'deferred_function_types_lib1.dart' deferred as lib1;
import 'deferred_function_types_lib2.dart' deferred as lib2;
main() {
asyncTest(() async {
await lib1.loadLibrary();
Expect.isTrue(lib1.method1() is int Function(int));
Expect.isFalse(lib1.method1() is String Function(String));
await lib2.loadLibrary();
Expect.isFalse(lib2.method2() is int Function(int));
Expect.isTrue(lib2.method2() is String Function(String));
});
}