Skip to content

Commit

Permalink
Triage language tests for void
Browse files Browse the repository at this point in the history
Change-Id: I4fc4bc583f6fe25a0a083efc6b9cda5ef9ae5ceb
Reviewed-on: https://dart-review.googlesource.com/66521
Commit-Queue: Leaf Petersen <leafp@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
  • Loading branch information
leafpetersen authored and commit-bot@chromium.org committed Aug 3, 2018
1 parent 35a982b commit 1a83245
Show file tree
Hide file tree
Showing 94 changed files with 2,420 additions and 414 deletions.
6 changes: 6 additions & 0 deletions tests/language_2/invalid_returns/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Feature tests for invalid returns

This directory holds tests for valid and invalid returns from functions. See
the
[feature specification](https://github.com/dart-lang/sdk/blob/master/docs/language/informal/generalized-void.md) for
details, or the formal spec once integrated.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

import 'dart:async';

void main() {
test();
/*
* `return;` is an error if `flatten(T)` is not `void`, `dynamic`, or `Null`
*/
Object test() async {
return; //# none: static type warning
}

// Testing that a block bodied async function may not return FutureOr<void>
void test() async {
return /*@compile-error=unspecified*/ null as FutureOr<void>;
void main() {
test();
}
16 changes: 16 additions & 0 deletions tests/language_2/invalid_returns/async_invalid_return_01_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) 2018, 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 'dart:async';

/*
* `return;` is an error if `flatten(T)` is not `void`, `dynamic`, or `Null`
*/
Future<int> test() async {
return; //# none: static type warning
}

void main() {
test();
}
16 changes: 16 additions & 0 deletions tests/language_2/invalid_returns/async_invalid_return_02_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) 2018, 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 'dart:async';

/*
* `return;` is an error if `flatten(T)` is not `void`, `dynamic`, or `Null`
*/
FutureOr<int> test() async {
return; //# none: static type warning
}

void main() {
test();
}
16 changes: 16 additions & 0 deletions tests/language_2/invalid_returns/async_invalid_return_03_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) 2018, 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 'dart:async';

/*
* `return;` is an error if `flatten(T)` is not `void`, `dynamic`, or `Null`
*/
Future<Object> test() async {
return; //# none: static type warning
}

void main() {
test();
}
16 changes: 16 additions & 0 deletions tests/language_2/invalid_returns/async_invalid_return_04_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) 2018, 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 'dart:async';

/*
* `return;` is an error if `flatten(T)` is not `void`, `dynamic`, or `Null`
*/
FutureOr<Object> test() async {
return; //# none: static type warning
}

void main() {
test();
}
18 changes: 18 additions & 0 deletions tests/language_2/invalid_returns/async_invalid_return_05_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) 2018, 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 'dart:async';

/*
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
*/
int v = null;
void test() async {
return /*@compile-error=unspecified*/ v;
}

void main() {
test();
}
18 changes: 18 additions & 0 deletions tests/language_2/invalid_returns/async_invalid_return_06_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) 2018, 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 'dart:async';

/*
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
*/
int v = null;
Future<void> test() async {
return /*@compile-error=unspecified*/ v;
}

void main() {
test();
}
18 changes: 18 additions & 0 deletions tests/language_2/invalid_returns/async_invalid_return_07_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) 2018, 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 'dart:async';

/*
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
*/
int v = null;
FutureOr<void> test() async {
return /*@compile-error=unspecified*/ v;
}

void main() {
test();
}
18 changes: 18 additions & 0 deletions tests/language_2/invalid_returns/async_invalid_return_08_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) 2018, 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 'dart:async';

/*
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
*/
Object v = null;
void test() async {
return /*@compile-error=unspecified*/ v;
}

void main() {
test();
}
18 changes: 18 additions & 0 deletions tests/language_2/invalid_returns/async_invalid_return_09_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) 2018, 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 'dart:async';

/*
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
*/
Object v = null;
Future<void> test() async {
return /*@compile-error=unspecified*/ v;
}

void main() {
test();
}
18 changes: 18 additions & 0 deletions tests/language_2/invalid_returns/async_invalid_return_10_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) 2018, 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 'dart:async';

/*
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
*/
Object v = null;
FutureOr<void> test() async {
return /*@compile-error=unspecified*/ v;
}

void main() {
test();
}
18 changes: 18 additions & 0 deletions tests/language_2/invalid_returns/async_invalid_return_11_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) 2018, 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 'dart:async';

/*
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
*/
Future<int> v = null;
void test() async {
return /*@compile-error=unspecified*/ v;
}

void main() {
test();
}
18 changes: 18 additions & 0 deletions tests/language_2/invalid_returns/async_invalid_return_12_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) 2018, 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 'dart:async';

/*
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
*/
Future<int> v = null;
Future<void> test() async {
return /*@compile-error=unspecified*/ v;
}

void main() {
test();
}
18 changes: 18 additions & 0 deletions tests/language_2/invalid_returns/async_invalid_return_13_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) 2018, 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 'dart:async';

/*
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
*/
Future<int> v = null;
FutureOr<void> test() async {
return /*@compile-error=unspecified*/ v;
}

void main() {
test();
}
18 changes: 18 additions & 0 deletions tests/language_2/invalid_returns/async_invalid_return_14_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) 2018, 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 'dart:async';

/*
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
*/
FutureOr<int> v = null;
void test() async {
return /*@compile-error=unspecified*/ v;
}

void main() {
test();
}
18 changes: 18 additions & 0 deletions tests/language_2/invalid_returns/async_invalid_return_15_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) 2018, 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 'dart:async';

/*
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
*/
FutureOr<int> v = null;
Future<void> test() async {
return /*@compile-error=unspecified*/ v;
}

void main() {
test();
}
18 changes: 18 additions & 0 deletions tests/language_2/invalid_returns/async_invalid_return_16_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) 2018, 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 'dart:async';

/*
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
*/
FutureOr<int> v = null;
FutureOr<void> test() async {
return /*@compile-error=unspecified*/ v;
}

void main() {
test();
}
18 changes: 18 additions & 0 deletions tests/language_2/invalid_returns/async_invalid_return_17_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) 2018, 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 'dart:async';

/*
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
*/
Future<Object> v = null;
void test() async {
return /*@compile-error=unspecified*/ v;
}

void main() {
test();
}
18 changes: 18 additions & 0 deletions tests/language_2/invalid_returns/async_invalid_return_18_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) 2018, 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 'dart:async';

/*
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
*/
Future<Object> v = null;
Future<void> test() async {
return /*@compile-error=unspecified*/ v;
}

void main() {
test();
}
18 changes: 18 additions & 0 deletions tests/language_2/invalid_returns/async_invalid_return_19_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) 2018, 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 'dart:async';

/*
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
*/
Future<Object> v = null;
FutureOr<void> test() async {
return /*@compile-error=unspecified*/ v;
}

void main() {
test();
}
18 changes: 18 additions & 0 deletions tests/language_2/invalid_returns/async_invalid_return_20_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) 2018, 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 'dart:async';

/*
* `return exp;` where `exp` has static type `S` is an error if `flatten(T)` is
`void` and `flatten(S)` is not `void`, `dynamic`, or `Null`
*/
FutureOr<Object> v = null;
void test() async {
return /*@compile-error=unspecified*/ v;
}

void main() {
test();
}
Loading

0 comments on commit 1a83245

Please sign in to comment.