-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate language_2/unsorted to NNBD.
Change-Id: Iad2963c7f9c184b089dc6d15aa4442f58d194bc2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151983 Reviewed-by: Nicholas Shahan <nshahan@google.com> Commit-Queue: Bob Nystrom <rnystrom@google.com> Auto-Submit: Bob Nystrom <rnystrom@google.com>
- Loading branch information
1 parent
1ab82de
commit d4154ac
Showing
150 changed files
with
20,007 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (c) 2011, 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. | ||
// Dart version of two-argument Ackermann-Peter function. | ||
|
||
import "package:expect/expect.dart"; | ||
|
||
class AckermannTest { | ||
static int ack(int m, int n) { | ||
return m == 0 | ||
? n + 1 | ||
: ((n == 0) ? ack(m - 1, 1) : ack(m - 1, ack(m, n - 1))); | ||
} | ||
|
||
static testMain() { | ||
Expect.equals(253, ack(3, 5)); | ||
} | ||
} | ||
|
||
main() { | ||
AckermannTest.testMain(); | ||
} |
24 changes: 24 additions & 0 deletions
24
tests/language/unsorted/additional_interface_adds_optional_args_concrete_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) 2017, 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. | ||
|
||
class A { | ||
void foo() {} | ||
} | ||
|
||
abstract class I { | ||
void foo([x]); | ||
} | ||
|
||
class /*@compile-error=unspecified*/ B extends A implements I { | ||
// This class declaration violates soundness, since it allows `new | ||
// B().foo(42)`, which would lead to invalid arguments being passed to A.foo. | ||
} | ||
|
||
void f(B b) { | ||
b.foo(); | ||
} | ||
|
||
main() { | ||
f(new B()); | ||
} |
36 changes: 36 additions & 0 deletions
36
tests/language/unsorted/additional_interface_adds_optional_args_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (c) 2017, 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. | ||
|
||
// This test exercises a corner case of override checking that is safe from a | ||
// soundness perspective, but which we haven't decided whether or not to allow | ||
// from a usability perspective. | ||
|
||
class A { | ||
void foo() {} | ||
} | ||
|
||
abstract class I { | ||
void foo([x]); | ||
} | ||
|
||
abstract class B extends A implements I { | ||
// If this class were concrete, there would be a problem, since `new | ||
// B().foo(42)` would be statically allowed, but would lead to invalid | ||
// arguments being passed to A.foo. But since the class is abstract, there is | ||
// no problem. | ||
} | ||
|
||
class C extends B { | ||
void foo([x]) { | ||
super.foo(); | ||
} | ||
} | ||
|
||
void f(B b) { | ||
b.foo(42); | ||
} | ||
|
||
main() { | ||
f(new C()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) 2011, 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. | ||
|
||
import "package:expect/expect.dart"; | ||
|
||
class A { | ||
int a; | ||
double? d1; | ||
double? d2; | ||
double? d3; | ||
double? d4; | ||
double? d5; | ||
double? d6; | ||
double? d7; | ||
double? d8; | ||
double? d9; | ||
double? d10; | ||
double? d11; | ||
double? d12; | ||
double? d13; | ||
double? d14; | ||
static var s; | ||
|
||
static foo() { | ||
return s; | ||
} | ||
|
||
A(this.a) {} | ||
|
||
value() { | ||
return a + foo(); | ||
} | ||
} | ||
|
||
class AllocateLargeObject { | ||
static testMain() { | ||
var a = new A(1); | ||
A.s = 4; | ||
Expect.equals(5, a.value()); | ||
} | ||
} | ||
|
||
main() { | ||
AllocateLargeObject.testMain(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) 2011, 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. | ||
|
||
import "package:expect/expect.dart"; | ||
|
||
class MyAllocate { | ||
const MyAllocate([int value = 0]) : value_ = value; | ||
int getValue() { | ||
return value_; | ||
} | ||
|
||
final int value_; | ||
} | ||
|
||
class AllocateTest { | ||
static testMain() { | ||
Expect.equals(900, (new MyAllocate(900)).getValue()); | ||
} | ||
} | ||
|
||
main() { | ||
AllocateTest.testMain(); | ||
} |
Oops, something went wrong.