Skip to content

Commit 67539c2

Browse files
munificentcommit-bot@chromium.org
authored andcommitted
Migrate language_2/regress to NNBD.
Change-Id: I318742cd4303d70c0625c9efd98bb01087aa5de4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150466 Commit-Queue: Bob Nystrom <[email protected]> Reviewed-by: Erik Ernst <[email protected]>
1 parent 84d3f36 commit 67539c2

File tree

304 files changed

+7762
-0
lines changed

Some content is hidden

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

304 files changed

+7762
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// Regression test for r24720.
6+
7+
import 'package:expect/expect.dart';
8+
9+
class A<T> {}
10+
11+
class B extends A<int> {
12+
B() : this.foo();
13+
B.foo();
14+
}
15+
16+
main() {
17+
Expect.isTrue(new B() is B);
18+
Expect.isTrue(new B() is A<int>);
19+
Expect.isFalse(new B() is A<String>);
20+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// Regression test for dart2js that used to miscompile
6+
// [A.visitInvokeDynamicMethod].
7+
8+
import "package:expect/expect.dart";
9+
10+
var a = 2;
11+
12+
class Tupe {
13+
const Tupe();
14+
get instructionType => a == 2 ? this : new A();
15+
refine(a, b) => '$a$b';
16+
}
17+
18+
class Node {
19+
final selector = null;
20+
var inputs = {"a": const Tupe(), "b": const Tupe()};
21+
bool isCallOnInterceptor = false;
22+
23+
getDartReceiver() {
24+
return isCallOnInterceptor ? inputs["a"] : inputs["b"];
25+
}
26+
}
27+
28+
class A {
29+
visitInvokeDynamicMethod(node) {
30+
var receiverType = node.getDartReceiver().instructionType;
31+
return receiverType.refine(node.selector, node.selector);
32+
}
33+
}
34+
35+
main() {
36+
Expect.equals(
37+
'nullnull', [new A()].last.visitInvokeDynamicMethod(new Node()));
38+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import "package:expect/expect.dart";
6+
7+
// Regression test for dart2js that used to miscompile [A.foo].
8+
9+
var global = 54;
10+
11+
class A {
12+
int a = 0;
13+
int b = 42;
14+
final int c = global;
15+
foo() {
16+
int start = a - 1;
17+
a = 54;
18+
if (b == 42) {
19+
b = 32;
20+
} else {
21+
b = 42;
22+
}
23+
Expect.equals(-1, start);
24+
}
25+
26+
bar() {
27+
int start = a - c - 1;
28+
a = 42;
29+
if (b == 42) {
30+
b = 32;
31+
} else {
32+
b = 42;
33+
}
34+
Expect.equals(-55, start);
35+
}
36+
}
37+
38+
main() {
39+
new A().foo();
40+
new A().bar();
41+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// Regression test for dart2js that used to miscompile classes
6+
// extending HashMap, because HashMap is patched.
7+
8+
import "package:expect/expect.dart";
9+
10+
import 'dart:collection';
11+
12+
class Foo extends Expando {}
13+
14+
main() {
15+
Expect.isNull(new Foo()[new Object()]);
16+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// Regression test for https://code.google.com/p/dart/issues/detail?id=10581.
6+
7+
import 'package:expect/expect.dart';
8+
9+
abstract class AxesObject {
10+
Update();
11+
}
12+
13+
String result = '';
14+
15+
class Point2DObject extends AxesObject {
16+
Update() {
17+
result += 'P';
18+
}
19+
}
20+
21+
class BestFitObject extends AxesObject {
22+
Update() {
23+
result += 'B';
24+
}
25+
}
26+
27+
class Foo {
28+
AddAxesObject(type) {
29+
AxesObject? a = null;
30+
switch (type) {
31+
case 100:
32+
a = new Point2DObject();
33+
break;
34+
case 200:
35+
a = new BestFitObject();
36+
break;
37+
}
38+
if (a != null) {
39+
a.Update();
40+
}
41+
}
42+
43+
AddAxesObject2(type) {
44+
AxesObject? a = null;
45+
if (type == 100) {
46+
a = new Point2DObject();
47+
} else if (type == 200) {
48+
a = new BestFitObject();
49+
}
50+
if (a != null) {
51+
a.Update();
52+
}
53+
}
54+
}
55+
56+
main() {
57+
var f = new Foo();
58+
f.AddAxesObject(100);
59+
f.AddAxesObject(200);
60+
f.AddAxesObject2(100);
61+
f.AddAxesObject2(200);
62+
Expect.equals('PBPB', result);
63+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import "package:expect/expect.dart";
6+
7+
void main() {
8+
Expect.equals('', useParameterInClosure(1));
9+
Expect.equals(43, updateParameterInClosure(1)());
10+
}
11+
12+
String useParameterInClosure(arg1, {int? arg2}) {
13+
if (arg1 is Map) {
14+
return arg1.keys.map((key) => arg1[key]).first;
15+
} else {
16+
return '';
17+
}
18+
}
19+
20+
Function updateParameterInClosure(arg1) {
21+
if (arg1 is Map) {
22+
return () => arg1 = 42;
23+
} else {
24+
return () => arg1 = arg1 + 42;
25+
}
26+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import "package:expect/expect.dart";
6+
7+
class B<T> {}
8+
9+
class A<T> {
10+
var field;
11+
A(this.field);
12+
asTypeVariable() => field as T;
13+
asBOfT() => field as B<T>;
14+
}
15+
16+
main() {
17+
Expect.equals(42, new A<int>(42).asTypeVariable());
18+
Expect.throwsTypeError(() => new A<String>(42).asTypeVariable());
19+
20+
var b = new B<int>();
21+
Expect.equals(b, new A<int>(b).asBOfT());
22+
Expect.throwsTypeError(() => new A<String>(b).asBOfT());
23+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import "package:expect/expect.dart";
6+
7+
class C {
8+
foo(int y) {
9+
return y;
10+
}
11+
}
12+
13+
main() {
14+
for (var b in [
15+
[false, 'pig']
16+
]) {
17+
var c;
18+
if (b[0] as bool) c = new C();
19+
Expect.throwsNoSuchMethodError(() => print(c.foo(b[1])));
20+
}
21+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
library regress_10996_lib;
6+
7+
var a = 3;
8+
var b = 4;
9+
var c = 5;
10+
var d = 6;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import "package:expect/expect.dart";
6+
import "regress10996_lib.dart" as lib;
7+
8+
foo(a, [b]) {
9+
return a + b + lib.a + lib.b;
10+
}
11+
12+
bar(c, {d}) {
13+
return c + d + lib.c + lib.d;
14+
}
15+
16+
main() {
17+
Expect.equals(1 + 2 + 3 + 4, foo(1, 2));
18+
Expect.equals(7 + 8 + 3 + 4, foo(7, 8));
19+
Expect.equals(3 + 4 + 5 + 6, bar(3, d: 4));
20+
Expect.equals(7 + 8 + 5 + 6, bar(7, d: 8));
21+
}

0 commit comments

Comments
 (0)