Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit fdf4e36

Browse files
nshahancommit-bot@chromium.org
authored and
commit-bot@chromium.org
committed
[test_runner] Use sound null safety js files
The bootstrapping was still loading the wrong version of the sdk and pre-compiled packages when running tests for DDC. Update constant_null_safety_mode_test to test a constant that is defined within the sdk itself in addition to one defined in the test. Change-Id: I8938ed92d866cfca0ce42567f03bed5f3dd9f10c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154121 Reviewed-by: Bob Nystrom <rnystrom@google.com> Commit-Queue: Nicholas Shahan <nshahan@google.com>
1 parent 742692d commit fdf4e36

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

pkg/test_runner/lib/src/browser.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,10 @@ String dartdevcHtml(String testName, String testNameAlias, String testJSDir,
152152
Compiler compiler, NnbdMode mode, bool nonNullAsserts) {
153153
var testId = pathToJSIdentifier(testName);
154154
var testIdAlias = pathToJSIdentifier(testNameAlias);
155-
var isKernel = compiler == Compiler.dartdevk;
156155
var isNnbd = mode != NnbdMode.legacy;
157156
var isNnbdStrong = mode == NnbdMode.strong;
158-
var sdkPath = isKernel ? 'kernel/amd/dart_sdk' : 'js/amd/dart_sdk';
159-
var pkgDir = isKernel ? 'pkg_kernel' : 'pkg';
157+
var sdkPath = isNnbdStrong ? 'sound/amd/dart_sdk' : 'kernel/amd/dart_sdk';
158+
var pkgDir = isNnbdStrong ? 'pkg_sound' : 'pkg_kernel';
160159
var packagePaths = testPackages
161160
.map((p) => ' "$p": "/root_build/gen/utils/dartdevc/$pkgDir/$p",')
162161
.join("\n");

tests/language/nnbd/constant_null_safety_mode_test.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,18 @@ import 'package:expect/expect.dart';
77
main() {
88
const trueInWeakMode = <Null>[] is List<int>;
99
Expect.equals(isWeakMode, trueInWeakMode);
10+
11+
// The following tests use the Uri.pathSegments() to access a constant list
12+
// that is defined in the SDK and verify the type associated with it does not
13+
// allow null when running with sound null safety.
14+
var emptyUri = Uri(pathSegments: []);
15+
dynamic stringList = emptyUri.pathSegments.toList();
16+
if (isStrongMode) {
17+
Expect.throwsTypeError(() {
18+
stringList.add(null);
19+
});
20+
} else {
21+
stringList.add(null);
22+
Expect.listEquals([null], stringList);
23+
}
1024
}

0 commit comments

Comments
 (0)