Skip to content

Commit d4154ac

Browse files
munificentcommit-bot@chromium.org
authored andcommitted
Migrate language_2/unsorted to NNBD.
Change-Id: Iad2963c7f9c184b089dc6d15aa4442f58d194bc2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151983 Reviewed-by: Nicholas Shahan <[email protected]> Commit-Queue: Bob Nystrom <[email protected]> Auto-Submit: Bob Nystrom <[email protected]>
1 parent 1ab82de commit d4154ac

File tree

150 files changed

+20007
-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.

150 files changed

+20007
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
// Dart version of two-argument Ackermann-Peter function.
5+
6+
import "package:expect/expect.dart";
7+
8+
class AckermannTest {
9+
static int ack(int m, int n) {
10+
return m == 0
11+
? n + 1
12+
: ((n == 0) ? ack(m - 1, 1) : ack(m - 1, ack(m, n - 1)));
13+
}
14+
15+
static testMain() {
16+
Expect.equals(253, ack(3, 5));
17+
}
18+
}
19+
20+
main() {
21+
AckermannTest.testMain();
22+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright (c) 2017, 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+
class A {
6+
void foo() {}
7+
}
8+
9+
abstract class I {
10+
void foo([x]);
11+
}
12+
13+
class /*@compile-error=unspecified*/ B extends A implements I {
14+
// This class declaration violates soundness, since it allows `new
15+
// B().foo(42)`, which would lead to invalid arguments being passed to A.foo.
16+
}
17+
18+
void f(B b) {
19+
b.foo();
20+
}
21+
22+
main() {
23+
f(new B());
24+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright (c) 2017, 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+
// This test exercises a corner case of override checking that is safe from a
6+
// soundness perspective, but which we haven't decided whether or not to allow
7+
// from a usability perspective.
8+
9+
class A {
10+
void foo() {}
11+
}
12+
13+
abstract class I {
14+
void foo([x]);
15+
}
16+
17+
abstract class B extends A implements I {
18+
// If this class were concrete, there would be a problem, since `new
19+
// B().foo(42)` would be statically allowed, but would lead to invalid
20+
// arguments being passed to A.foo. But since the class is abstract, there is
21+
// no problem.
22+
}
23+
24+
class C extends B {
25+
void foo([x]) {
26+
super.foo();
27+
}
28+
}
29+
30+
void f(B b) {
31+
b.foo(42);
32+
}
33+
34+
main() {
35+
f(new C());
36+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
import "package:expect/expect.dart";
6+
7+
class A {
8+
int a;
9+
double? d1;
10+
double? d2;
11+
double? d3;
12+
double? d4;
13+
double? d5;
14+
double? d6;
15+
double? d7;
16+
double? d8;
17+
double? d9;
18+
double? d10;
19+
double? d11;
20+
double? d12;
21+
double? d13;
22+
double? d14;
23+
static var s;
24+
25+
static foo() {
26+
return s;
27+
}
28+
29+
A(this.a) {}
30+
31+
value() {
32+
return a + foo();
33+
}
34+
}
35+
36+
class AllocateLargeObject {
37+
static testMain() {
38+
var a = new A(1);
39+
A.s = 4;
40+
Expect.equals(5, a.value());
41+
}
42+
}
43+
44+
main() {
45+
AllocateLargeObject.testMain();
46+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
import "package:expect/expect.dart";
6+
7+
class MyAllocate {
8+
const MyAllocate([int value = 0]) : value_ = value;
9+
int getValue() {
10+
return value_;
11+
}
12+
13+
final int value_;
14+
}
15+
16+
class AllocateTest {
17+
static testMain() {
18+
Expect.equals(900, (new MyAllocate(900)).getValue());
19+
}
20+
}
21+
22+
main() {
23+
AllocateTest.testMain();
24+
}

0 commit comments

Comments
 (0)