[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 1da4344 32/60: Update url-str-parser
From: |
Junpeng Qiu |
Subject: |
[elpa] master 1da4344 32/60: Update url-str-parser |
Date: |
Tue, 25 Oct 2016 17:45:14 +0000 (UTC) |
branch: master
commit 1da4344fbd1dd588ec03b841c39d3c204a12fe63
Author: Junpeng Qiu <address@hidden>
Commit: Junpeng Qiu <address@hidden>
Update url-str-parser
---
examples/url-str-parser-tests.el | 48 ++++++++++++++++++++++++++++++++++++++
examples/url-str-parser.el | 11 +++------
2 files changed, 51 insertions(+), 8 deletions(-)
diff --git a/examples/url-str-parser-tests.el b/examples/url-str-parser-tests.el
new file mode 100644
index 0000000..92bca94
--- /dev/null
+++ b/examples/url-str-parser-tests.el
@@ -0,0 +1,48 @@
+;;; url-str-parser-tests.el --- Tests for url-str-parser -*- lexical-binding:
t; -*-
+
+;; Copyright (C) 2016 Junpeng Qiu
+
+;; Author: Junpeng Qiu <address@hidden>
+;; Keywords:
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+
+(require 'ert)
+(require 'url-str-parser)
+
+(ert-deftest test-url-str ()
+ (should
+ (equal
+ (url-str-parse "foo=bar&a%21=b+c")
+ '(("foo" Just . "bar")
+ ("a!" Just . "b c"))))
+ (should
+ (equal
+ (url-str-parse "foo=&a%21=b+c")
+ '(("foo" Just . "")
+ ("a!" Just . "b c"))))
+ (should
+ (equal
+ (url-str-parse "foo&a%21=b+c")
+ '(("foo" . Nothing)
+ ("a!" Just . "b c")))))
+
+(provide 'url-str-parser-tests)
+;;; url-str-parser-tests.el ends here
diff --git a/examples/url-str-parser.el b/examples/url-str-parser.el
index f08c2fd..926c6df 100644
--- a/examples/url-str-parser.el
+++ b/examples/url-str-parser.el
@@ -31,7 +31,8 @@
(defun url-str-pair ()
(cons
(parsec-many1-as-string (url-str-char))
- (parsec-make-maybe (parsec-and (parsec-ch ?=) (parsec-many-as-string
(url-str-char))))))
+ (parsec-optional-maybe
+ (parsec-and (parsec-ch ?=) (parsec-many-as-string (url-str-char))))))
(defun url-str-char ()
(parsec-or (parsec-re "[a-zA-z0-9$_.!*'(),-]")
@@ -48,14 +49,8 @@
16))))
(defun url-str-parse (input)
- (with-temp-buffer
- (insert input)
- (goto-char (point-min))
+ (parsec-with-input input
(url-str-query)))
-(url-str-parse "foo=bar&a%21=b+c")
-(url-str-parse "foo=&a%21=b+c")
-(url-str-parse "foo&a%21=b+c")
-
(provide 'url-str-parser)
;;; url-str-parser.el ends here
- [elpa] master fd77961 25/60: Add a few simple API, (continued)
- [elpa] master fd77961 25/60: Add a few simple API, Junpeng Qiu, 2016/10/25
- [elpa] master 12d2ad6 24/60: Bug fixes, Junpeng Qiu, 2016/10/25
- [elpa] master adf4706 20/60: Add many-till, notFollowedBy and fix others, Junpeng Qiu, 2016/10/25
- [elpa] master 32809ad 30/60: Add parsec-error-new-2, Junpeng Qiu, 2016/10/25
- [elpa] master 3503e4a 13/60: Rename for easier understanding, Junpeng Qiu, 2016/10/25
- [elpa] master 4fb2abe 29/60: Update simple-csv-parser, Junpeng Qiu, 2016/10/25
- [elpa] master fa2e6f1 27/60: Add gitignore, Junpeng Qiu, 2016/10/25
- [elpa] master a06220c 42/60: Update README, Junpeng Qiu, 2016/10/25
- [elpa] master f7e8629 26/60: Add tests, Junpeng Qiu, 2016/10/25
- [elpa] master bc11325 50/60: Add file examples/.nosearch, Junpeng Qiu, 2016/10/25
- [elpa] master 1da4344 32/60: Update url-str-parser,
Junpeng Qiu <=
- [elpa] master 89dd2ac 54/60: Fix some wording in README, Junpeng Qiu, 2016/10/25
- [elpa] master 55515ca 48/60: Add missing dependencies, Junpeng Qiu, 2016/10/25
- [elpa] master 2e9f962 59/60: Add new package parsec to externals-list, Junpeng Qiu, 2016/10/25
- [elpa] master 3827d26 36/60: Add docs for user-interface functions & combinators, Junpeng Qiu, 2016/10/25
- [elpa] master 8c108be 56/60: Add parsec-peek and parsec-peek-p, Junpeng Qiu, 2016/10/25
- [elpa] master 6001a70 12/60: Refine and add more parsec API, Junpeng Qiu, 2016/10/25
- [elpa] master da878fa 18/60: Use parsec-query for other return values, Junpeng Qiu, 2016/10/25
- [elpa] master 054a753 06/60: Rename to parsec, Junpeng Qiu, 2016/10/25
- [elpa] master 2cce1e3 37/60: Rename parsec-from-just to parsec-from-maybe, Junpeng Qiu, 2016/10/25
- [elpa] master cdb8c0d 47/60: Remove unused symbols, Junpeng Qiu, 2016/10/25