blob: b2bc6fa5f57dd6e36cd27cbbb697acf46fba8530 [file] [log] [blame]
// 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.
/// @assertion The grammar of types is extended to allow any type to be suffixed
/// with a ? (e.g. int?) indicating the nullable version of that type.
///
/// @description Check that any type can be suffixed with a ? indicating the
/// nullable version of that type. Test different valid cases
/// @author sgrekhov@unipro.ru
// Requirements=nnbd-weak
import "../../../Utils/expect.dart";
int ? testInt(int ? i) => i == null ? i ?? 0 : i;
int ?
testInt2(int
? i) => i == null ? i ??
0 : i;
main() {
var x = null;
int ? a = x ??= 3 > 0 ? x ?? 1: x ?? 2;
Expect.equals(1, a);
Expect.equals(testInt(a), a);
}