Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit cfeb1d6

Browse files
joshualittcommit-bot@chromium.org
authored andcommitted
[dart2js] Port some tests to nnbd #5.
Change-Id: Ic9912d94e1248df70a92e2504af87d42d5ca0528 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152617 Commit-Queue: Joshua Litt <[email protected]> Reviewed-by: Mayank Patke <[email protected]>
1 parent b19fefa commit cfeb1d6

20 files changed

+72
-94
lines changed

tests/dart2js/panda_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import "package:expect/expect.dart";
88
import 'panda_lib.dart' as p;
99

1010
void main() {
11-
p.Panda x = new p.Panda();
11+
p.Panda? x = new p.Panda();
1212
Expect.isTrue(x is p.Panda);
1313
x = null;
1414
Expect.isFalse(x is p.Panda);

tests/dart2js/regress_40349_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ dynamic x = Wrapper<int>();
2121

2222
class A<E> {
2323
int _foo = 0;
24-
List<E> list = [null];
24+
List<E?> list = [null];
2525

2626
@pragma('dart2js:tryInline')
2727
void internalMethod(E value) {

tests/dart2js/regress_null_aware_test.dart

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,11 @@
55
// Regression test for failure on CFE null-aware encoding.
66

77
class Class {
8-
Map<String, Set<String>> map;
8+
Map<String, Set<String>>? map;
99

10-
List<String> method(String node, Set<String> set) =>
11-
set.add(node)
12-
? [
13-
node,
14-
...?map[node]
15-
?.expand((node) => method(node, set))
16-
?.toList()
17-
]
18-
: [];
10+
List<String> method(String node, Set<String> set) => set.add(node)
11+
? [node, ...?map![node]?.expand((node) => method(node, set))?.toList()]
12+
: [];
1913
}
2014

2115
main(args) {

tests/dart2js/return_setter_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
import "package:expect/expect.dart";
66

77
class A {
8-
int foo;
8+
int? foo;
99

10-
static int invocations;
10+
static int? invocations;
1111

1212
static bar() {
1313
Expect.equals(0, invocations);
14-
invocations++;
14+
invocations = invocations! + 1;
1515
return 2;
1616
}
1717
}

tests/dart2js/runtime_type_closure_equals1_test.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// dart2jsOptions=--strong
6-
75
import 'package:expect/expect.dart';
86

97
class Class<T> {
@@ -19,5 +17,5 @@ main() {
1917

2018
Expect.isTrue(local1a.runtimeType == local1b.runtimeType);
2119
Expect.isFalse(local1a.runtimeType == local2.runtimeType);
22-
new Class();
20+
Class();
2321
}

tests/dart2js/runtime_type_closure_equals2_test.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,20 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// dart2jsOptions=--strong
6-
75
import 'package:expect/expect.dart';
86

97
class Class<T> {
108
Class();
119
}
1210

1311
main() {
14-
T local1a<T>() => null;
12+
T local1a<T>() => throw 'unreachable';
1513

16-
T local1b<T>() => null;
14+
T local1b<T>() => throw 'unreachable';
1715

1816
T local2<T>(T t, String s) => t;
1917

2018
Expect.isTrue(local1a.runtimeType == local1b.runtimeType);
2119
Expect.isFalse(local1a.runtimeType == local2.runtimeType);
22-
new Class();
20+
Class();
2321
}

tests/dart2js/runtime_type_closure_equals3_test.dart

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// dart2jsOptions=--strong
6-
75
import 'package:expect/expect.dart';
86

9-
String method() => null;
7+
String method() => throw 'unreachable';
108

119
class Class1<T> {
1210
Class1();
1311

1412
method() {
15-
T local1a() => null;
13+
T local1a() => throw 'unreachable';
1614

17-
T local1b() => null;
15+
T local1b() => throw 'unreachable';
1816

1917
T local2(T t, String s) => t;
2018

@@ -29,6 +27,6 @@ class Class2<T> {
2927
}
3028

3129
main() {
32-
new Class1<int>().method();
33-
new Class2<int>();
30+
Class1<int>().method();
31+
Class2<int>();
3432
}

tests/dart2js/runtime_type_closure_equals4_test.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// dart2jsOptions=--strong
6-
75
import 'package:expect/expect.dart';
86

97
class Class1<T> {
@@ -21,9 +19,9 @@ class Class2<T> {
2119
}
2220

2321
main() {
24-
var c = new Class1<int>();
22+
var c = Class1<int>();
2523

2624
Expect.isTrue(c.method1a.runtimeType == c.method1b.runtimeType);
2725
Expect.isFalse(c.method1a.runtimeType == c.method2.runtimeType);
28-
new Class2<int>();
26+
Class2<int>();
2927
}

tests/dart2js/runtime_type_closure_equals5_test.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// dart2jsOptions=--strong
6-
75
import 'package:expect/expect.dart';
86

97
class Class1<T> {
108
Class1();
119

12-
T method1a() => null;
10+
T method1a() => throw 'unreachable';
1311

14-
T method1b() => null;
12+
T method1b() => throw 'unreachable';
1513

1614
T method2(T t, String s) => t;
1715
}
@@ -21,9 +19,9 @@ class Class2<T> {
2119
}
2220

2321
main() {
24-
var c = new Class1<int>();
22+
var c = Class1<int>();
2523

2624
Expect.isTrue(c.method1a.runtimeType == c.method1b.runtimeType);
2725
Expect.isFalse(c.method1a.runtimeType == c.method2.runtimeType);
28-
new Class2<int>();
26+
Class2<int>();
2927
}

tests/dart2js/runtime_type_closure_equals6_test.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// dart2jsOptions=--strong
6-
75
import 'package:expect/expect.dart';
86

97
method1a() => null;
@@ -19,5 +17,5 @@ class Class<T> {
1917
main() {
2018
Expect.isTrue(method1a.runtimeType == method1b.runtimeType);
2119
Expect.isFalse(method1a.runtimeType == method2.runtimeType);
22-
new Class<int>();
20+
Class<int>();
2321
}

0 commit comments

Comments
 (0)