Rename --checked to --enable-asserts (#1964)

Keep the old flag as an alias, run with checked mode if either is set.
Behavior will be weird for cases like `--checked --no-enable-asserts` but
it's not worth the extra complexity to track that down.

Update tests using the flag.

Use consistent single quotes in the files that were being edited anyway.
diff --git a/lib/src/command/global_run.dart b/lib/src/command/global_run.dart
index 75f37f6..0b9dd14 100644
--- a/lib/src/command/global_run.dart
+++ b/lib/src/command/global_run.dart
@@ -13,28 +13,28 @@
 
 /// Handles the `global run` pub command.
 class GlobalRunCommand extends PubCommand {
-  String get name => "run";
+  String get name => 'run';
   String get description =>
-      "Run an executable from a globally activated package.\n"
+      'Run an executable from a globally activated package.\n'
       "NOTE: We are currently optimizing this command's startup time.";
-  String get invocation => "pub global run <package>:<executable> [args...]";
+  String get invocation => 'pub global run <package>:<executable> [args...]';
   bool get allowTrailingOptions => false;
 
   GlobalRunCommand() {
-    argParser.addFlag("checked",
-        abbr: "c", help: "Enable runtime type checks and assertions.");
-    argParser.addOption("mode", help: "Deprecated option", hide: true);
+    argParser.addFlag('enable-asserts', help: 'Enable assert statements.');
+    argParser.addFlag('checked', abbr: 'c', hide: true);
+    argParser.addOption('mode', help: 'Deprecated option', hide: true);
   }
 
   Future run() async {
     if (argResults.rest.isEmpty) {
-      usageException("Must specify an executable to run.");
+      usageException('Must specify an executable to run.');
     }
 
     var package;
     var executable = argResults.rest[0];
-    if (executable.contains(":")) {
-      var parts = split1(executable, ":");
+    if (executable.contains(':')) {
+      var parts = split1(executable, ':');
       package = parts[0];
       executable = parts[1];
     } else {
@@ -48,12 +48,12 @@
           'package.');
     }
 
-    if (argResults.wasParsed("mode")) {
-      log.warning("The --mode flag is deprecated and has no effect.");
+    if (argResults.wasParsed('mode')) {
+      log.warning('The --mode flag is deprecated and has no effect.');
     }
 
     var exitCode = await globals.runExecutable(package, executable, args,
-        checked: argResults["checked"]);
+        checked: argResults['enable-asserts'] || argResults['checked']);
     await flushThenExit(exitCode);
   }
 }
diff --git a/lib/src/command/run.dart b/lib/src/command/run.dart
index 9afe392..c017a96 100644
--- a/lib/src/command/run.dart
+++ b/lib/src/command/run.dart
@@ -14,20 +14,20 @@
 
 /// Handles the `run` pub command.
 class RunCommand extends PubCommand {
-  String get name => "run";
-  String get description => "Run an executable from a package.";
-  String get invocation => "pub run <executable> [args...]";
+  String get name => 'run';
+  String get description => 'Run an executable from a package.';
+  String get invocation => 'pub run <executable> [args...]';
   bool get allowTrailingOptions => false;
 
   RunCommand() {
-    argParser.addFlag("checked",
-        abbr: "c", help: "Enable runtime type checks and assertions.");
-    argParser.addOption("mode", help: "Deprecated option", hide: true);
+    argParser.addFlag('enable-asserts', help: 'Enable assert statements.');
+    argParser.addFlag('checked', abbr: 'c', hide: true);
+    argParser.addOption('mode', help: 'Deprecated option', hide: true);
   }
 
   Future run() async {
     if (argResults.rest.isEmpty) {
-      usageException("Must specify an executable to run.");
+      usageException('Must specify an executable to run.');
     }
 
     var package = entrypoint.root.name;
@@ -36,14 +36,14 @@
 
     // A command like "foo:bar" runs the "bar" script from the "foo" package.
     // If there is no colon prefix, default to the root package.
-    if (executable.contains(":")) {
-      var components = split1(executable, ":");
+    if (executable.contains(':')) {
+      var components = split1(executable, ':');
       package = components[0];
       executable = components[1];
 
       if (p.split(executable).length > 1) {
         usageException(
-            "Cannot run an executable in a subdirectory of a dependency.");
+            'Cannot run an executable in a subdirectory of a dependency.');
       }
     } else if (onlyIdentifierRegExp.hasMatch(executable)) {
       // "pub run foo" means the same thing as "pub run foo:foo" as long as
@@ -51,16 +51,16 @@
       package = executable;
     }
 
-    if (argResults.wasParsed("mode")) {
-      log.warning("The --mode flag is deprecated and has no effect.");
+    if (argResults.wasParsed('mode')) {
+      log.warning('The --mode flag is deprecated and has no effect.');
     }
 
     // The user may pass in an executable without an extension, but the file
     // to actually execute will always have one.
-    if (p.extension(executable) != ".dart") executable += ".dart";
+    if (p.extension(executable) != '.dart') executable += '.dart';
 
     var snapshotPath = p.join(
-        entrypoint.cachePath, "bin", package, "$executable.snapshot.dart2");
+        entrypoint.cachePath, 'bin', package, '$executable.snapshot.dart2');
 
     // Don't ever compile snapshots for mutable packages, since their code may
     // change later on.
@@ -69,7 +69,7 @@
             !entrypoint.packageGraph.isPackageMutable(package));
 
     var exitCode = await runExecutable(entrypoint, package, executable, args,
-        checked: argResults['checked'],
+        checked: argResults['enable-asserts'] || argResults['checked'],
         snapshotPath: useSnapshot ? snapshotPath : null,
         recompile: entrypoint.precompileExecutables);
     await flushThenExit(exitCode);
diff --git a/lib/src/executable.dart b/lib/src/executable.dart
index ced7de3..e381888 100644
--- a/lib/src/executable.dart
+++ b/lib/src/executable.dart
@@ -22,7 +22,7 @@
 ///
 /// Arguments from [args] will be passed to the spawned Dart application.
 ///
-/// If [checked] is true, the program is run in checked mode.
+/// If [checked] is true, the program is run with assertions enabled.
 ///
 /// If [packagesFile] is passed, it's used as the package config file path for
 /// the executable. Otherwise, `entrypoint.packagesFile` is used.
@@ -117,7 +117,7 @@
   return p.absolute(fullPath);
 }
 
-/// Like [runSnapshot], but runs [recompile] if [path] doesn't exist yet.
+/// Like [_runSnapshot], but runs [recompile] if [path] doesn't exist yet.
 ///
 /// Returns `null` if [path] doesn't exist and isn't generated by [recompile].
 Future<int> _runOrCompileSnapshot(String path, Iterable<String> args,
@@ -130,7 +130,7 @@
     if (!fileExists(path)) return null;
   }
 
-  return await runSnapshot(path, args,
+  return await _runSnapshot(path, args,
       recompile: recompile, packagesFile: packagesFile, checked: checked);
 }
 
@@ -141,12 +141,12 @@
 /// expected to regenerate a snapshot at [path], after which the snapshot will
 /// be re-run.
 ///
-/// If [checked] is set, runs the snapshot in checked mode.
+/// If [checked] is set, runs the snapshot with assertions enabled.
 ///
 /// Returns the snapshot's exit code.
 ///
 /// This doesn't do any validation of the snapshot's SDK version.
-Future<int> runSnapshot(String path, Iterable<String> args,
+Future<int> _runSnapshot(String path, Iterable<String> args,
     {Future<void> recompile(),
     String packagesFile,
     bool checked = false}) async {
diff --git a/lib/src/global_packages.dart b/lib/src/global_packages.dart
index e6fa3e0..58df59a 100644
--- a/lib/src/global_packages.dart
+++ b/lib/src/global_packages.dart
@@ -373,7 +373,7 @@
   /// recompiled if the SDK has been upgraded since it was first compiled and
   /// then run. Otherwise, it will be run from source.
   ///
-  /// If [checked] is true, the program is run in checked mode.
+  /// If [checked] is true, the program is run with assertions enabled.
   ///
   /// Returns the exit code from the executable.
   Future<int> runExecutable(
diff --git a/test/global/run/errors_if_outside_bin_test.dart b/test/global/run/errors_if_outside_bin_test.dart
index 9104ba7..43d3732 100644
--- a/test/global/run/errors_if_outside_bin_test.dart
+++ b/test/global/run/errors_if_outside_bin_test.dart
@@ -22,8 +22,8 @@
 Cannot run an executable in a subdirectory of a global package.
 
 Usage: pub global run <package>:<executable> [args...]
--h, --help            Print this usage information.
--c, --[no-]checked    Enable runtime type checks and assertions.
+-h, --help                   Print this usage information.
+    --[no-]enable-asserts    Enable assert statements.
 
 Run "pub help" to see global options.
 """, exitCode: exit_codes.USAGE);
diff --git a/test/global/run/missing_executable_arg_test.dart b/test/global/run/missing_executable_arg_test.dart
index e1f2b9c..614cf3f 100644
--- a/test/global/run/missing_executable_arg_test.dart
+++ b/test/global/run/missing_executable_arg_test.dart
@@ -10,14 +10,14 @@
 
 main() {
   test('fails if no executable was given', () {
-    return runPub(args: ["global", "run"], error: """
+    return runPub(args: ['global', 'run'], error: '''
             Must specify an executable to run.
 
             Usage: pub global run <package>:<executable> [args...]
-            -h, --help            Print this usage information.
-            -c, --[no-]checked    Enable runtime type checks and assertions.
+            -h, --help                   Print this usage information.
+                --[no-]enable-asserts    Enable assert statements.
 
             Run "pub help" to see global options.
-            """, exitCode: exit_codes.USAGE);
+            ''', exitCode: exit_codes.USAGE);
   });
 }
diff --git a/test/global/run/runs_script_in_checked_mode_test.dart b/test/global/run/runs_script_in_checked_mode_test.dart
index 86af689..b01b228 100644
--- a/test/global/run/runs_script_in_checked_mode_test.dart
+++ b/test/global/run/runs_script_in_checked_mode_test.dart
@@ -8,17 +8,18 @@
 import '../../test_pub.dart';
 
 main() {
-  test('runs a script in checked mode', () async {
+  test('runs a script with assertions enabled', () async {
     await servePackages((builder) {
-      builder.serve("foo", "1.0.0", contents: [
-        d.dir("bin", [d.file("script.dart", "main() { assert(false); }")])
+      builder.serve('foo', '1.0.0', contents: [
+        d.dir('bin', [d.file('script.dart', 'main() { assert(false); }')])
       ]);
     });
 
-    await runPub(args: ["global", "activate", "foo"]);
+    await runPub(args: ['global', 'activate', 'foo']);
 
-    var pub = await pubRun(global: true, args: ["--checked", "foo:script"]);
-    expect(pub.stderr, emitsThrough(contains("Failed assertion")));
+    var pub =
+        await pubRun(global: true, args: ['--enable-asserts', 'foo:script']);
+    expect(pub.stderr, emitsThrough(contains('Failed assertion')));
     await pub.shouldExit(255);
   });
 }
diff --git a/test/run/errors_if_no_executable_is_given_test.dart b/test/run/errors_if_no_executable_is_given_test.dart
index c7991eb..a33610b 100644
--- a/test/run/errors_if_no_executable_is_given_test.dart
+++ b/test/run/errors_if_no_executable_is_given_test.dart
@@ -13,14 +13,14 @@
   test('Errors if the executable does not exist.', () async {
     await d.dir(appPath, [d.appPubspec()]).create();
 
-    await runPub(args: ["run"], error: """
+    await runPub(args: ['run'], error: '''
 Must specify an executable to run.
 
 Usage: pub run <executable> [args...]
--h, --help            Print this usage information.
--c, --[no-]checked    Enable runtime type checks and assertions.
+-h, --help                   Print this usage information.
+    --[no-]enable-asserts    Enable assert statements.
 
 Run "pub help" to see global options.
-""", exitCode: exit_codes.USAGE);
+''', exitCode: exit_codes.USAGE);
   });
 }
diff --git a/test/run/errors_if_path_in_dependency_test.dart b/test/run/errors_if_path_in_dependency_test.dart
index 2037b2c..1c2b129 100644
--- a/test/run/errors_if_path_in_dependency_test.dart
+++ b/test/run/errors_if_path_in_dependency_test.dart
@@ -13,22 +13,22 @@
   test(
       'Errors if the executable is in a subdirectory in a '
       'dependency.', () async {
-    await d.dir("foo", [d.libPubspec("foo", "1.0.0")]).create();
+    await d.dir('foo', [d.libPubspec('foo', '1.0.0')]).create();
 
     await d.dir(appPath, [
       d.appPubspec({
-        "foo": {"path": "../foo"}
+        'foo': {'path': '../foo'}
       })
     ]).create();
 
-    await runPub(args: ["run", "foo:sub/dir"], error: """
+    await runPub(args: ['run', 'foo:sub/dir'], error: '''
 Cannot run an executable in a subdirectory of a dependency.
 
 Usage: pub run <executable> [args...]
--h, --help            Print this usage information.
--c, --[no-]checked    Enable runtime type checks and assertions.
+-h, --help                   Print this usage information.
+    --[no-]enable-asserts    Enable assert statements.
 
 Run "pub help" to see global options.
-""", exitCode: exit_codes.USAGE);
+''', exitCode: exit_codes.USAGE);
   });
 }
diff --git a/test/run/runs_the_script_in_checked_mode_test.dart b/test/run/runs_the_script_in_checked_mode_test.dart
index 228ce33..68ec58f 100644
--- a/test/run/runs_the_script_in_checked_mode_test.dart
+++ b/test/run/runs_the_script_in_checked_mode_test.dart
@@ -8,16 +8,16 @@
 import '../test_pub.dart';
 
 main() {
-  test('runs the script in checked mode with "--checked"', () async {
+  test('runs the script with assertions enabled', () async {
     await d.dir(appPath, [
       d.appPubspec(),
-      d.dir("bin", [d.file("script.dart", "main() { assert(false); }")])
+      d.dir('bin', [d.file('script.dart', 'main() { assert(false); }')])
     ]).create();
 
     await pubGet();
     await runPub(
-        args: ["run", "--checked", "bin/script"],
-        error: contains("Failed assertion"),
+        args: ['run', '--enable-asserts', 'bin/script'],
+        error: contains('Failed assertion'),
         exitCode: 255);
   });
 }
diff --git a/test/run/runs_the_script_in_unchecked_mode_test.dart b/test/run/runs_the_script_in_unchecked_mode_test.dart
index 9f69be2..588a8db 100644
--- a/test/run/runs_the_script_in_unchecked_mode_test.dart
+++ b/test/run/runs_the_script_in_unchecked_mode_test.dart
@@ -7,21 +7,21 @@
 import '../descriptor.dart' as d;
 import '../test_pub.dart';
 
-const SCRIPT = """
+const SCRIPT = '''
 main() {
   assert(false);
   print("no checks");
 }
-""";
+''';
 
 main() {
-  test('runs the script in unchecked mode by default', () async {
+  test('runs the script without assertions by default', () async {
     await d.dir(appPath, [
       d.appPubspec(),
-      d.dir("bin", [d.file("script.dart", SCRIPT)])
+      d.dir('bin', [d.file('script.dart', SCRIPT)])
     ]).create();
 
     await pubGet();
-    await runPub(args: ["run", "bin/script"], output: contains("no checks"));
+    await runPub(args: ['run', 'bin/script'], output: contains('no checks'));
   });
 }