Skip to content

Commit 60afc24

Browse files
karlklosecommit-bot@chromium.org
authored andcommitted
[infra] Convert some multi-tests to the new static error framework
This is the result of running the tool from https://dart-review.googlesource.com/c/sdk/+/124128 on the language_2 tests that contain only static multi-test annotations. Some of the results needed manual editing and in these cases I have also changed the formatting of the tests. Change-Id: I4ddd16a2c5d8576adccb0a740cb1d4aabbc001b8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/126161 Commit-Queue: Karl Klose <karlklose@google.com> Reviewed-by: Bob Nystrom <rnystrom@google.com>
1 parent b0155a7 commit 60afc24

File tree

897 files changed

+38334
-2005
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

897 files changed

+38334
-2005
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// TODO(multitest): This was automatically migrated from a multitest and may
2+
// contain strange or dead code.
3+
4+
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
5+
// for details. All rights reserved. Use of this source code is governed by a
6+
// BSD-style license that can be found in the LICENSE file.
7+
8+
// Regression test for dart2js that used to duplicate some `Object`
9+
// methods to handle `noSuchMethod`.
10+
11+
import "package:expect/expect.dart";
12+
import "compiler_annotations.dart";
13+
14+
15+
class Foo {
16+
noSuchMethod(im) => 42;
17+
}
18+
19+
@DontInline()
20+
returnFoo() {
21+
(() => 42)();
22+
return new Foo();
23+
}
24+
25+
class Bar {
26+
operator ==(other) => false;
27+
}
28+
29+
var a = [false, true, new Object(), new Bar()];
30+
31+
main() {
32+
if (a[0]) {
33+
// This `==` call will make the compiler create a selector with an
34+
// exact `TypeMask` of `Foo`. Since `Foo` is abstract, such a call
35+
// cannot happen, but we still used to generate a `==` method on
36+
// the `Object` class to handle `noSuchMethod`.
37+
print(returnFoo() == 42);
38+
} else {
39+
Expect.isFalse(a[2] == 42);
40+
}
41+
}

tests/language_2/abstract_exact_selector_test.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import "package:expect/expect.dart";
99
import "compiler_annotations.dart";
1010

11-
abstract //# 01: compile-time error
11+
abstract
1212
class Foo {
1313
noSuchMethod(im) => 42;
1414
}
@@ -17,6 +17,9 @@ abstract //# 01: compile-time error
1717
returnFoo() {
1818
(() => 42)();
1919
return new Foo();
20+
// ^^^
21+
// [analyzer] STATIC_WARNING.INSTANTIATE_ABSTRACT_CLASS
22+
// [cfe] The class 'Foo' is abstract and can't be instantiated.
2023
}
2124

2225
class Bar {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// TODO(multitest): This was automatically migrated from a multitest and may
2+
// contain strange or dead code.
3+
4+
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
5+
// for details. All rights reserved. Use of this source code is governed by a
6+
// BSD-style license that can be found in the LICENSE file.
7+
// Dart test program for constructors and initializers.
8+
9+
// Exercises issue 2282, factory constructors in abstract classes should
10+
// not emit a static type warning
11+
12+
class B extends A1 {
13+
B() {}
14+
method() {}
15+
}
16+
17+
abstract class A1 {
18+
A1() {}
19+
method(); // Abstract.
20+
factory A1.make() {
21+
return new B();
22+
}
23+
}
24+
25+
class A2 {
26+
// Intentionally abstract method.
27+
28+
A2.make() {}
29+
}
30+
31+
main() {
32+
new A1.make();
33+
34+
}

tests/language_2/abstract_factory_constructor_test.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,17 @@ abstract class A1 {
2020
}
2121

2222
class A2 {
23+
// ^
24+
// [cfe] The non-abstract class 'A2' is missing implementations for these members:
25+
2326
// Intentionally abstract method.
24-
method(); //# 00: compile-time error
27+
method();
28+
//^^^^^^^^^
29+
// [analyzer] STATIC_WARNING.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER
2530
A2.make() {}
2631
}
2732

2833
main() {
2934
new A1.make();
30-
new A2.make(); //# 00: continued
35+
new A2.make();
3136
}

tests/language_2/abstract_getter_test.dart

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,21 @@ import "package:expect/expect.dart";
77
// Test to ensure that an abstract getter is not mistaken for a field.
88

99
class Foo {
10+
// ^
11+
// [cfe] The non-abstract class 'Foo' is missing implementations for these members:
12+
1013
// Intentionally abstract:
11-
get i; //# 01: compile-time error
14+
get i;
15+
//^^^^^^
16+
// [analyzer] STATIC_WARNING.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER
1217
}
1318

1419
class Bar {}
1520

1621
checkIt(f) {
17-
Expect.throwsNoSuchMethodError(() => f.i = 'hi'); // //# 01: continued
18-
Expect.throwsNoSuchMethodError(() => print(f.i)); // //# 01: continued
19-
Expect.throwsNoSuchMethodError(() => print(f.i())); // //# 01: continued
22+
Expect.throwsNoSuchMethodError(() => f.i = 'hi');
23+
Expect.throwsNoSuchMethodError(() => print(f.i));
24+
Expect.throwsNoSuchMethodError(() => print(f.i()));
2025
}
2126

2227
main() {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// TODO(multitest): This was automatically migrated from a multitest and may
2+
// contain strange or dead code.
3+
4+
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
5+
// for details. All rights reserved. Use of this source code is governed by a
6+
// BSD-style license that can be found in the LICENSE file.
7+
8+
import "package:expect/expect.dart";
9+
10+
main() {
11+
var b = new B();
12+
Expect.equals(42, b.foo());
13+
}
14+
15+
class A {
16+
17+
18+
}
19+
20+
class B extends A {
21+
foo() => 42;
22+
bar() => 87;
23+
}

tests/language_2/abstract_syntax_test.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,15 @@ main() {
1010
}
1111

1212
class A {
13-
foo(); // //# 00: compile-time error
14-
static bar(); // //# 01: syntax error
13+
// ^
14+
// [cfe] The non-abstract class 'A' is missing implementations for these members:
15+
foo();
16+
//^^^^^^
17+
// [analyzer] STATIC_WARNING.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER
18+
static bar();
19+
// ^
20+
// [analyzer] SYNTACTIC_ERROR.MISSING_FUNCTION_BODY
21+
// [cfe] Expected a function body or '=>'.
1522
}
1623

1724
class B extends A {
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// TODO(multitest): This was automatically migrated from a multitest and may
2+
// contain strange or dead code.
3+
4+
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
5+
// for details. All rights reserved. Use of this source code is governed by a
6+
// BSD-style license that can be found in the LICENSE file.
7+
8+
import "package:expect/expect.dart";
9+
10+
void f(num callback(num x)) {}
11+
12+
Object intToObject(int x) => null;
13+
Object numToObject(num x) => null;
14+
Object objectToObject(Object x) => null;
15+
int intToInt(int x) => null;
16+
int numToInt(num x) => null;
17+
int objectToInt(Object x) => null;
18+
num intToNum(int x) => null;
19+
num numToNum(num x) => null;
20+
num objectToNum(Object x) => null;
21+
22+
main() {
23+
// Unrelated types (not assignable)
24+
25+
26+
27+
// Assignable but fails at runtime.
28+
var intToObject2 = intToObject;
29+
Expect.throwsTypeError(() => f(intToObject2));
30+
var intToNum2 = intToNum;
31+
32+
var numToObject2 = numToObject;
33+
34+
35+
// Ok
36+
37+
38+
39+
40+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// TODO(multitest): This was automatically migrated from a multitest and may
2+
// contain strange or dead code.
3+
4+
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
5+
// for details. All rights reserved. Use of this source code is governed by a
6+
// BSD-style license that can be found in the LICENSE file.
7+
8+
import "package:expect/expect.dart";
9+
10+
void f(num callback(num x)) {}
11+
12+
Object intToObject(int x) => null;
13+
Object numToObject(num x) => null;
14+
Object objectToObject(Object x) => null;
15+
int intToInt(int x) => null;
16+
int numToInt(num x) => null;
17+
int objectToInt(Object x) => null;
18+
num intToNum(int x) => null;
19+
num numToNum(num x) => null;
20+
num objectToNum(Object x) => null;
21+
22+
main() {
23+
// Unrelated types (not assignable)
24+
25+
26+
27+
// Assignable but fails at runtime.
28+
var intToObject2 = intToObject;
29+
30+
var intToNum2 = intToNum;
31+
Expect.throwsTypeError(() => f(intToNum2));
32+
var numToObject2 = numToObject;
33+
34+
35+
// Ok
36+
37+
38+
39+
40+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// TODO(multitest): This was automatically migrated from a multitest and may
2+
// contain strange or dead code.
3+
4+
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
5+
// for details. All rights reserved. Use of this source code is governed by a
6+
// BSD-style license that can be found in the LICENSE file.
7+
8+
import "package:expect/expect.dart";
9+
10+
void f(num callback(num x)) {}
11+
12+
Object intToObject(int x) => null;
13+
Object numToObject(num x) => null;
14+
Object objectToObject(Object x) => null;
15+
int intToInt(int x) => null;
16+
int numToInt(num x) => null;
17+
int objectToInt(Object x) => null;
18+
num intToNum(int x) => null;
19+
num numToNum(num x) => null;
20+
num objectToNum(Object x) => null;
21+
22+
main() {
23+
// Unrelated types (not assignable)
24+
25+
26+
27+
// Assignable but fails at runtime.
28+
var intToObject2 = intToObject;
29+
30+
var intToNum2 = intToNum;
31+
32+
var numToObject2 = numToObject;
33+
Expect.throwsTypeError(() => f(numToObject2));
34+
35+
// Ok
36+
37+
38+
39+
40+
}

0 commit comments

Comments
 (0)