emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/dart-mode 07a9e76 189/192: Add failing font-lock test


From: ELPA Syncer
Subject: [nongnu] elpa/dart-mode 07a9e76 189/192: Add failing font-lock test
Date: Sun, 29 Aug 2021 11:02:15 -0400 (EDT)

branch: elpa/dart-mode
commit 07a9e76e7aa3b7f5e2b936e4d76461898a34d248
Author: Brady Trainor <mail@bradyt.net>
Commit: Brady Trainor <mail@bradyt.net>

    Add failing font-lock test
---
 test/credit.txt                          |  3 +++
 test/faceup/stagehand/server.dart        | 34 ++++++++++++++++++++++++++++++++
 test/faceup/stagehand/server.dart.faceup | 34 ++++++++++++++++++++++++++++++++
 test/test-font-lock.el                   |  4 ++++
 4 files changed, 75 insertions(+)

diff --git a/test/credit.txt b/test/credit.txt
index 66155bb..655a18b 100644
--- a/test/credit.txt
+++ b/test/credit.txt
@@ -4,6 +4,9 @@ from https://dart.dev/samples.
 The source code samples in the faceup/core/ directory were copied from
 https://github.com/dart-lang/sdk. The following is copied from its LICENSE 
file.
 
+The source code samples in the faceup/stagehand/ directory were copied from
+https://github.com/dart-lang/stagehand. The following is copied from its 
LICENSE file.
+
 Copyright 2012, the Dart project authors. All rights reserved.
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are
diff --git a/test/faceup/stagehand/server.dart 
b/test/faceup/stagehand/server.dart
new file mode 100644
index 0000000..53b132e
--- /dev/null
+++ b/test/faceup/stagehand/server.dart
@@ -0,0 +1,34 @@
+import 'dart:io';
+
+import 'package:args/args.dart';
+import 'package:shelf/shelf.dart' as shelf;
+import 'package:shelf/shelf_io.dart' as io;
+
+// For Google Cloud Run, set _hostname to '0.0.0.0'.
+const _hostname = 'localhost';
+
+main(List<String> args) async {
+  var parser = ArgParser()..addOption('port', abbr: 'p');
+  var result = parser.parse(args);
+
+  // For Google Cloud Run, we respect the PORT environment variable
+  var portStr = result['port'] ?? Platform.environment['PORT'] ?? '8080';
+  var port = int.tryParse(portStr);
+
+  if (port == null) {
+    stdout.writeln('Could not parse port value "$portStr" into a number.');
+    // 64: command line usage error
+    exitCode = 64;
+    return;
+  }
+
+  var handler = const shelf.Pipeline()
+      .addMiddleware(shelf.logRequests())
+      .addHandler(_echoRequest);
+
+  var server = await io.serve(handler, _hostname, port);
+  print('Serving at http://${server.address.host}:${server.port}');
+}
+
+shelf.Response _echoRequest(shelf.Request request) =>
+    shelf.Response.ok('Request for "${request.url}"');
diff --git a/test/faceup/stagehand/server.dart.faceup 
b/test/faceup/stagehand/server.dart.faceup
new file mode 100644
index 0000000..eaa4054
--- /dev/null
+++ b/test/faceup/stagehand/server.dart.faceup
@@ -0,0 +1,34 @@
+«b:import» «s:'dart:io'»;
+
+«b:import» «s:'package:args/args.dart'»;
+«b:import» «s:'package:shelf/shelf.dart'» «b:as» shelf;
+«b:import» «s:'package:shelf/shelf_io.dart'» «b:as» io;
+
+«m:// »«x:For Google Cloud Run, set _hostname to '0.0.0.0'.
+»«k:const» «v:_hostname» = «s:'localhost'»;
+
+«f:main»(«t:List»<«t:String»> «v:args») «k:async» {
+  «k:var» «v:parser» = «t:ArgParser»()..addOption(«s:'port'», abbr: «s:'p'»);
+  «k:var» «v:result» = parser.parse(args);
+
+  «m:// »«x:For Google Cloud Run, we respect the PORT environment variable
+»  «k:var» «v:portStr» = result[«s:'port'»] ?? 
«t:Platform».environment[«s:'PORT'»] ?? «s:'8080'»;
+  «k:var» «v:port» = «t:int».tryParse(portStr);
+
+  «k:if» (port == «c:null») {
+    stdout.writeln(«s:'Could not parse port value "»«v:$portStr»«s:" into a 
number.'»);
+    «m:// »«x:64: command line usage error
+»    exitCode = «c:64»;
+    «k:return»;
+  }
+
+  «k:var» «v:handler» = «k:const» shelf.«t:Pipeline»()
+      .addMiddleware(shelf.logRequests())
+      .addHandler(_echoRequest);
+
+  «k:var» «v:server» = «k:await» io.serve(handler, _hostname, port);
+  print(«s:'Serving at 
http://»«v:${server.address.host}»«s::»«v:${server.port}»«s:'»);
+}
+
+shelf.«t:Response» «f:_echoRequest»(shelf.«t:Request» «v:request») =>
+    shelf.«t:Response».ok(«s:'Request for "»«v:${request.url}»«s:"'»);
diff --git a/test/test-font-lock.el b/test/test-font-lock.el
index dad6b23..2c4de62 100644
--- a/test/test-font-lock.el
+++ b/test/test-font-lock.el
@@ -36,6 +36,10 @@
   :expected-result :failed
   (should (dart-font-lock-test-apps "faceup/issues/factory.dart")))
 
+(ert-deftest dart-font-lock-false-positive-test ()
+  :expected-result :failed
+  (should (dart-font-lock-test-apps "faceup/stagehand/server.dart")))
+
 (ert-deftest dart-font-lock-generic-method-test ()
   :expected-result :failed
   (should (dart-font-lock-test-apps "faceup/issues/generic-method.dart")))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]