045813c1f3
Basic assert statements, inline functions in the future. AssertBlocks are not supported with const functions. Change-Id: Ic831fc4d76db0403a30577b9d00c629237148581 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192800 Reviewed-by: Jake Macdonald <jakemac@google.com> Reviewed-by: Dmitry Stefantsov <dmitryas@google.com> Commit-Queue: Kallen Tu <kallentu@google.com>
23 lines
578 B
Dart
23 lines
578 B
Dart
// Copyright (c) 2021, 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.
|
|
|
|
// Tests assert statements with const functions.
|
|
|
|
// SharedOptions=--enable-experiment=const-functions
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
const var1 = fn();
|
|
// ^^^^
|
|
// [analyzer] COMPILE_TIME_ERROR.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
|
int fn() {
|
|
int x = 0;
|
|
assert(x == 0, "fail");
|
|
return x;
|
|
}
|
|
|
|
void main() {
|
|
Expect.equals(var1, 0);
|
|
}
|