Skip to content

Commit

Permalink
Migrate language_2/unsorted to NNBD.
Browse files Browse the repository at this point in the history
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
munificent authored and commit-bot@chromium.org committed Jun 26, 2020
1 parent 1ab82de commit d4154ac
Show file tree
Hide file tree
Showing 150 changed files with 20,007 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/language/unsorted/ackermann_test.dart
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();
}
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());
}
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());
}
46 changes: 46 additions & 0 deletions tests/language/unsorted/allocate_large_object_test.dart
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();
}
24 changes: 24 additions & 0 deletions tests/language/unsorted/allocate_test.dart
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();
}
Loading

0 comments on commit d4154ac

Please sign in to comment.