[augeas-devel] augeas: master - * tests/modules/pass_strip_quotes.aug: test quote stripping

David Lutterkort lutter at fedoraproject.org
Tue Sep 1 18:09:22 UTC 2009


Gitweb:        http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=f218d05899362615124cfab574cef888b3cefff2
Commit:        f218d05899362615124cfab574cef888b3cefff2
Parent:        86b4f3ef43d45a92ffff190caf11945b38afd5aa
Author:        David Lutterkort <lutter at redhat.com>
AuthorDate:    Tue Aug 25 15:55:32 2009 -0700
Committer:     David Lutterkort <lutter at redhat.com>
CommitterDate: Mon Aug 31 14:39:13 2009 -0700

* tests/modules/pass_strip_quotes.aug: test quote stripping

The tests strips optional quotes and puts them back (or creates them) as
needed, only depending on the value of the tree node.
---
 tests/modules/pass_strip_quotes.aug |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/tests/modules/pass_strip_quotes.aug b/tests/modules/pass_strip_quotes.aug
new file mode 100644
index 0000000..7e24b31
--- /dev/null
+++ b/tests/modules/pass_strip_quotes.aug
@@ -0,0 +1,26 @@
+(* Demonstrate how quotes can be stripped from values.            *)
+(* Values can be enclosed in single or double quotes, if they     *)
+(* contain spaces they _have_ to be enclosed in quotes. Since     *)
+(* everything's regular, we can't actually match a closing quote  *)
+(* to the opening quote, so "hello' will be accepted, too.        *)
+
+module Pass_strip_quotes =
+
+  let nuttin = del /(""|'')?/ "''"
+  let bare = del /["']?/ "" . store /[a-zA-Z0-9]+/ . del /["']?/ ""
+  let quoted = del /["']/ "'" . store /.*[ \t].*/ . del /["']/ "'"
+
+  let lns = [ label "foo" . bare ]
+    | [ label "foo" . quoted ]
+    | [ label "foo" . nuttin ]
+
+  test lns get "'hello'" = { "foo" = "hello" }
+  test lns get "'hello world'" = { "foo" = "hello world" }
+
+  let hw = "'hello world'"
+  let set_hw = set "/foo" "hello world"
+  test lns put "hello" after set_hw = hw
+  test lns put "'hello world'" after set "/foo" "hello" = "'hello'"
+
+  test lns put "" after set_hw = hw
+  test lns put "\"\"" after set_hw = hw




More information about the augeas-devel mailing list