Files
sdk/pkg/kernel/test/binary/library_flags_test.dart
T
Johnni Winther ae03b57cbb [cfe] Remove .isNonNullableByDefault from package:kernel
This removes the .isNonNullableByDefault properties and similar from
the AST nodes in package:kernel. NNBD is now always enabled so these
properties are trivial.

TEST=existing

Change-Id: I75ca0551ac4b5910ea63530dd0c9c2e68bd01aff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366320
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-05-15 08:31:38 +00:00

63 lines
2.2 KiB
Dart

// Copyright (c) 2019, 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 'utils.dart';
/// Test that library flags are serialized and read correctly.
void main() {
void setSynthetic(Library lib, bool isSynthetic) {
lib.isSynthetic = isSynthetic;
}
void verifySynthetic(Library lib, bool isSynthetic) {
if (lib.isSynthetic != isSynthetic) {
throw "Serialized and re-read library had change in synthetic flag.";
}
}
void setNonNullableByDefaultCompiledMode(Library lib,
NonNullableByDefaultCompiledMode nonNullableByDefaultCompiledMode) {
lib.nonNullableByDefaultCompiledMode = nonNullableByDefaultCompiledMode;
}
void verifyNonNullableByDefaultCompiledMode(Library lib,
NonNullableByDefaultCompiledMode nonNullableByDefaultCompiledMode) {
if (lib.nonNullableByDefaultCompiledMode !=
nonNullableByDefaultCompiledMode) {
throw "Serialized and re-read library had change in "
"nonNullableByDefaultCompiledMode flag.";
}
}
int combination = 0;
for (bool isSynthetic in [true, false]) {
for (bool isNonNullableByDefault in [true, false]) {
for (NonNullableByDefaultCompiledMode nonNullableByDefaultCompiledMode
in [
NonNullableByDefaultCompiledMode.Weak,
NonNullableByDefaultCompiledMode.Strong,
NonNullableByDefaultCompiledMode.Agnostic,
]) {
combination++;
print("Checking combination #$combination ("
"isSynthetic: $isSynthetic; "
"isNonNullableByDefault: $isNonNullableByDefault; "
"nonNullableByDefaultCompiledMode:"
" $nonNullableByDefaultCompiledMode");
Uri uri = Uri.parse("foo://bar.dart");
Library lib = new Library(uri, fileUri: uri);
setSynthetic(lib, isSynthetic);
setNonNullableByDefaultCompiledMode(
lib, nonNullableByDefaultCompiledMode);
Library lib2 = libRoundTrip(lib);
verifySynthetic(lib2, isSynthetic);
verifyNonNullableByDefaultCompiledMode(
lib2, nonNullableByDefaultCompiledMode);
}
}
}
print("Done: Everything looks good.");
}