blob: 1103f7ef9ded60df1fbbe2a9239617052af413d5 [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);
}