[augeas-devel] augeas: master - Test for using a recursive lens inside other lenses

David Lutterkort lutter at fedoraproject.org
Tue Jan 26 02:22:22 UTC 2010


Gitweb:        http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=f154cabdffacebe39767902d83d03dc68f1e1240
Commit:        f154cabdffacebe39767902d83d03dc68f1e1240
Parent:        12aeafa9ae5af64bc687a3e5dca05a7822946d4c
Author:        David Lutterkort <lutter at redhat.com>
AuthorDate:    Mon Jan 25 17:33:22 2010 -0800
Committer:     David Lutterkort <lutter at redhat.com>
CommitterDate: Mon Jan 25 18:20:44 2010 -0800

Test for using a recursive lens inside other lenses

---
 tests/modules/pass_mixed_recursion.aug |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/tests/modules/pass_mixed_recursion.aug b/tests/modules/pass_mixed_recursion.aug
new file mode 100644
index 0000000..c49ac48
--- /dev/null
+++ b/tests/modules/pass_mixed_recursion.aug
@@ -0,0 +1,30 @@
+module Pass_Mixed_Recursion =
+
+(* Test that using a recursive lens as part of another lens works *)
+
+let rec r = [ key "a" . r ] | [ key "a" . store "x" ]
+
+(* Star a recursive lens *)
+let star = r*
+
+test star get "aax" = { "a" { "a" = "x" } }
+test star put "aax" after rm "/nothing" = "aax"
+
+test star get "axax" = { "a" = "x" } { "a" = "x" }
+test star put "axaaxax" after rm "/a[2]" = "axax"
+
+(* Use a starred recursive lens in a more complicated construct *)
+let top = [ label "top" . r* . value "high" ]
+
+test top get "axaax" = { "top" = "high" { "a" = "x" } { "a" { "a" = "x" } } }
+test top put "axaax" after rm "/top/a[1]" = "aax"
+
+(* Use a recursive lens in a union *)
+let union = (r | [ key "b" . store /[a-z]/ ])*
+
+test union get "aaxbyax" =
+  { "a" { "a" = "x" } } { "b" = "y" } { "a" = "x" }
+test union put "aaxbyax" after
+  set "/b[2]" "z" = "aaxbyaxbz"
+test union put "aaxbyax" after
+  set "/b[2]" "z"; rm "/b[1]" = "aaxaxbz"




More information about the augeas-devel mailing list