f8086c81ae
Collects files from `package:async_helper` and `tests/language` that are generally useful, so that all test-related helpers are in `package:expect`. Moves the two libraries from `package:async_helper` into `package:expect`, and the `tests/language/static_type_helper.dart` file too. Deprecates `async_minitest.dart`, to follow `minitest.dart`, expecting the Flutter use of it to have been fixed to not break on deprecation (I believe Flutter no longer breaks builds on deprecations at all). Patch 1 is the actual change. Patch 2+4+8 is changing all existing references to the files. Patch 6 ignores deprecation in files still using `async_minitest.dart`. 3+5+7+9 are updating this text to make the numbers match. Then it's just test-expectations and small tweaks from there. Change-Id: I1b665135b5fef9b9a0c3b340ffe9daf874d0174c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373120 Reviewed-by: Nate Bosch <nbosch@google.com> Reviewed-by: Devon Carew <devoncarew@google.com> Commit-Queue: Lasse Nielsen <lrn@google.com>
121 lines
2.3 KiB
Dart
121 lines
2.3 KiB
Dart
// Copyright (c) 2012, 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.
|
|
|
|
// Test that parameters keep their names in the output.
|
|
|
|
import "package:expect/async_helper.dart";
|
|
import "package:expect/expect.dart";
|
|
import '../helpers/compiler_helper.dart';
|
|
|
|
const String TEST_ONE = r"""
|
|
class A { }
|
|
class B { }
|
|
|
|
main() {
|
|
A();
|
|
B();
|
|
}
|
|
""";
|
|
|
|
const String TEST_TWO = r"""
|
|
class A { }
|
|
class B extends A { }
|
|
|
|
main() {
|
|
A();
|
|
B();
|
|
String c = '';
|
|
print(c);
|
|
}
|
|
""";
|
|
|
|
const String TEST_THREE = r"""
|
|
class B extends A { }
|
|
class A { }
|
|
|
|
main() {
|
|
String c = '';
|
|
print(c);
|
|
B();
|
|
A();
|
|
}
|
|
""";
|
|
|
|
const String TEST_FOUR = r"""
|
|
var g = 0;
|
|
class A {
|
|
@pragma('dart2js:noElision')
|
|
var x = g++;
|
|
}
|
|
|
|
class B extends A {
|
|
@pragma('dart2js:noElision')
|
|
var y = g++;
|
|
@pragma('dart2js:noElision')
|
|
var z = g++;
|
|
}
|
|
|
|
main() {
|
|
B();
|
|
}
|
|
""";
|
|
|
|
const String TEST_FIVE = r"""
|
|
class A {
|
|
@pragma('dart2js:noElision')
|
|
var a;
|
|
A(a) : this.a = a {}
|
|
}
|
|
|
|
main() {
|
|
A(3);
|
|
}
|
|
""";
|
|
|
|
twoClasses() async {
|
|
String generated = await compileAll(TEST_ONE);
|
|
Expect.isTrue(generated.contains('A: function A()'));
|
|
Expect.isTrue(generated.contains('B: function B()'));
|
|
}
|
|
|
|
subClass() async {
|
|
checkOutput(String generated) {
|
|
Expect.isTrue(generated
|
|
.contains(RegExp(r'_inheritMany\([$A-Z]+\.Object, .*, [$A-Z]+\.A]')));
|
|
Expect.isTrue(
|
|
generated.contains(RegExp(r'_inherit\([$A-Z]+\.B, [$A-Z]+\.A\)')));
|
|
}
|
|
|
|
checkOutput(await compileAll(TEST_TWO));
|
|
checkOutput(await compileAll(TEST_THREE));
|
|
}
|
|
|
|
fieldTest() async {
|
|
String generated = await compileAll(TEST_FOUR);
|
|
Expect.isTrue(generated.contains(RegExp(r'B: function B\(t0, t1, t2\) {'
|
|
r'\s*this.y = t0;'
|
|
r'\s*this.z = t1;'
|
|
r'\s*this.x = t2;')));
|
|
}
|
|
|
|
constructor1() async {
|
|
String generated = await compileAll(TEST_FIVE);
|
|
Expect.isTrue(generated.contains(new RegExp(r"new [$A-Z]+\.A\(a\);")),
|
|
'--------------------\n$generated\n');
|
|
}
|
|
|
|
main() {
|
|
runTests() async {
|
|
await twoClasses();
|
|
await subClass();
|
|
await fieldTest();
|
|
await constructor1();
|
|
}
|
|
|
|
asyncTest(() async {
|
|
print('--test from kernel------------------------------------------------');
|
|
await runTests();
|
|
});
|
|
}
|