Skip to content

Commit

Permalink
Reformat tests/language/assert/.
Browse files Browse the repository at this point in the history
Change-Id: I333977cf5738c39f6754c7ecbab8eea8751e761c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/399861
Reviewed-by: Lasse Nielsen <[email protected]>
Auto-Submit: Bob Nystrom <[email protected]>
Commit-Queue: Bob Nystrom <[email protected]>
  • Loading branch information
munificent authored and Commit Queue committed Dec 12, 2024
1 parent 6bd57e4 commit 6f66c12
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 177 deletions.
45 changes: 8 additions & 37 deletions tests/language/assert/initializer_const_error2_runtime_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// TODO(multitest): This was automatically migrated from a multitest and may
// contain strange or dead code.

// 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.
Expand All @@ -15,73 +12,47 @@ class C {
final int x;
// Const constructors.
const C.cc01(this.x, y) : assert(x < y);
const C.cc02(x, y)
: x = x,
assert(x < y);
const C.cc03(x, y)
: assert(x < y),
x = x;
const C.cc04(this.x, y)
: assert(x < y),
super();
const C.cc05(x, y)
: x = x,
assert(x < y),
super();
const C.cc06(x, y)
: assert(x < y),
x = x,
super();
const C.cc07(x, y)
: assert(x < y),
x = x,
assert(y > x),
super();
const C.cc02(x, y) : x = x, assert(x < y);
const C.cc03(x, y) : assert(x < y), x = x;
const C.cc04(this.x, y) : assert(x < y), super();
const C.cc05(x, y) : x = x, assert(x < y), super();
const C.cc06(x, y) : assert(x < y), x = x, super();
const C.cc07(x, y) : assert(x < y), x = x, assert(y > x), super();
const C.cc08(this.x, y) : assert(x < y, "$x < $y");
const C.cc09(this.x, y) : assert(x < y,);
const C.cc10(this.x, y) : assert(x < y, "$x < $y",);
const C.cc09(this.x, y) : assert(x < y);
const C.cc10(this.x, y) : assert(x < y, "$x < $y");
}

main() {
const x = 3;
{

const C.cc01(2, x);
}
{

const C.cc02(2, x);
}
{

const C.cc03(2, x);
}
{

const C.cc04(2, x);
}
{

const C.cc05(2, x);
}
{

const C.cc06(2, x);
}
{

const C.cc07(2, x);
}
{

const C.cc08(2, x);
}
{

const C.cc09(2, x);
}
{

const C.cc10(2, x);
}
}
118 changes: 49 additions & 69 deletions tests/language/assert/initializer_const_error2_test.dart
Original file line number Diff line number Diff line change
@@ -1,124 +1,104 @@
// 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.
// VMOptions=--enable-asserts
// dart2jsOptions=--enable-asserts
//
// Test of asserts in initializer lists.

// Test of asserts in initializer lists.
import "package:expect/expect.dart";

class C {
final int x;
// Const constructors.
const C.cc01(this.x, y) : assert(x < y);
const C.cc02(x, y)
: x = x,
assert(x < y);
const C.cc03(x, y)
: assert(x < y),
x = x;
const C.cc04(this.x, y)
: assert(x < y),
super();
const C.cc05(x, y)
: x = x,
assert(x < y),
super();
const C.cc06(x, y)
: assert(x < y),
x = x,
super();
const C.cc07(x, y)
: assert(x < y),
x = x,
assert(y > x),
super();
const C.cc02(x, y) : x = x, assert(x < y);
const C.cc03(x, y) : assert(x < y), x = x;
const C.cc04(this.x, y) : assert(x < y), super();
const C.cc05(x, y) : x = x, assert(x < y), super();
const C.cc06(x, y) : assert(x < y), x = x, super();
const C.cc07(x, y) : assert(x < y), x = x, assert(y > x), super();
const C.cc08(this.x, y) : assert(x < y, "$x < $y");
const C.cc09(this.x, y) : assert(x < y,);
const C.cc10(this.x, y) : assert(x < y, "$x < $y",);
const C.cc09(this.x, y) : assert(x < y);
const C.cc10(this.x, y) : assert(x < y, "$x < $y");
}

main() {
const x = 3;
{
const x = 1;
const C.cc01(2, x);
// ^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
// ^
// [cfe] Constant evaluation error:
// [error column 5, length 18]
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
// ^
// [cfe] Constant evaluation error:
}
{
const x = 1;
const C.cc02(2, x);
// ^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
// ^
// [cfe] Constant evaluation error:
// [error column 5, length 18]
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
// ^
// [cfe] Constant evaluation error:
}
{
const x = 1;
const C.cc03(2, x);
// ^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
// ^
// [cfe] Constant evaluation error:
// [error column 5, length 18]
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
// ^
// [cfe] Constant evaluation error:
}
{
const x = 1;
const C.cc04(2, x);
// ^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
// ^
// [cfe] Constant evaluation error:
// [error column 5, length 18]
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
// ^
// [cfe] Constant evaluation error:
}
{
const x = 1;
const C.cc05(2, x);
// ^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
// ^
// [cfe] Constant evaluation error:
// [error column 5, length 18]
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
// ^
// [cfe] Constant evaluation error:
}
{
const x = 1;
const C.cc06(2, x);
// ^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
// ^
// [cfe] Constant evaluation error:
// [error column 5, length 18]
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
// ^
// [cfe] Constant evaluation error:
}
{
const x = 1;
const C.cc07(2, x);
// ^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
// ^
// [cfe] Constant evaluation error:
// [error column 5, length 18]
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
// ^
// [cfe] Constant evaluation error:
}
{
const x = 1;
const C.cc08(2, x);
// ^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
// ^
// [cfe] Constant evaluation error:
// [error column 5, length 18]
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
// ^
// [cfe] Constant evaluation error:
}
{
const x = 1;
const C.cc09(2, x);
// ^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
// ^
// [cfe] Constant evaluation error:
// [error column 5, length 18]
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
// ^
// [cfe] Constant evaluation error:
}
{
const x = 1;
const C.cc10(2, x);
// ^^^^^^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
// ^
// [cfe] Constant evaluation error:
// [error column 5, length 18]
// [analyzer] COMPILE_TIME_ERROR.CONST_EVAL_THROWS_EXCEPTION
// ^
// [cfe] Constant evaluation error:
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// TODO(multitest): This was automatically migrated from a multitest and may
// contain strange or dead code.

// 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.
Expand All @@ -11,9 +8,7 @@ class C {
const C(this.x);
// The expression is not a potentially constant expression.
// This is a compile-time error even in production mode.
const C.bc03(this.x, y)

;
const C.bc03(this.x, y);
}

main() {
Expand Down
10 changes: 4 additions & 6 deletions tests/language/assert/initializer_const_error_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ class C {
const C(this.x);
// The expression is not a potentially constant expression.
// This is a compile-time error even in production mode.
const C.bc03(this.x, y)
: assert(check(x, y))
// ^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.INVALID_CONSTANT
// [cfe] Method invocation is not a constant expression.
;
const C.bc03(this.x, y) : assert(check(x, y));
// ^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.INVALID_CONSTANT
// [cfe] Method invocation is not a constant expression.
}

main() {
Expand Down
21 changes: 0 additions & 21 deletions tests/language/assert/initializer_const_function_runtime_test.dart

This file was deleted.

10 changes: 4 additions & 6 deletions tests/language/assert/initializer_const_function_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ class C {

// Functions as parameters to assert are no longer supported in Dart 2.0, so
// this is now a static type error.
const C.bc01(this.x, y)
: assert(staticTrue)
// ^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_BOOL_EXPRESSION
// [cfe] A value of type 'bool Function()' can't be assigned to a variable of type 'bool'.
;
const C.bc01(this.x, y) : assert(staticTrue);
// ^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.NON_BOOL_EXPRESSION
// [cfe] A value of type 'bool Function()' can't be assigned to a variable of type 'bool'.
}

main() {
Expand Down
Loading

0 comments on commit 6f66c12

Please sign in to comment.