dart-sdk/tests/web_2/deferred/multiple_default_arg_test.dart
Sigmund Cherem 912005267d [web] rename suite dart2js -> web.
Change-Id: I46be49b2effec3e38a3dc44cd45cfe736f77fa78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182680
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2021-02-04 23:11:32 +00:00

54 lines
1.8 KiB
Dart

// Copyright (c) 2017, 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
/// This test is indirectly testing invariants of the generated code of dart2js.
/// It ensures that indices to metadata information from **multiple** deferred
/// fragments is kept separate, but that when they are loaded (and the metadata
/// array is merged) all accesses to the metadata array is done correctly.
///
/// This kind of metadata is generated when using Function.apply to
/// store default values and parameter names.
import 'multiple_default_arg_lib1.dart' deferred as lib1;
import 'multiple_default_arg_lib2.dart' deferred as lib2;
import 'multiple_default_arg_lib3.dart' deferred as lib3;
import 'package:expect/expect.dart';
import 'package:async_helper/async_helper.dart';
main() {
asyncTest(() async {
await lib1.loadLibrary();
await lib2.loadLibrary();
Expect.equals(
Function.apply(lib1.myFunction1, [], {#argumentName1: () => "A"}),
"A - 2");
Expect.equals(
Function.apply(lib2.myFunction2, [], {#argumentName4: () => "B"}),
"3 - B");
await lib3.loadLibrary();
Expect.equals(
Function.apply(
lib3.myFunction3, ["x", "y"], {#argumentName4: () => "C"}),
"x y 3b - C");
Expect.equals(
Function.apply(lib3.myFunction3, ["x", "y"], {}), "x y 3b - 4b");
Expect.equals(Function.apply(lib3.myFunction4, ["x", "y"], {}), 5);
Expect.equals(
Function.apply(
lib3.myFunction4, ["x", "y"], {#argumentName5: new lib3.X(4)}),
4);
Expect.equals(
Function.apply(
lib3.myFunction4, ["x", "y"], {#argumentName5: lib3.value3}),
3);
});
}