Bump to 1.14.1
[platform/upstream/augeas.git] / tests / modules / pass_mixed_recursion.aug
1 module Pass_Mixed_Recursion =
2
3 (* Test that using a recursive lens as part of another lens works *)
4
5 let rec r = [ key "a" . r ] | [ key "a" . store "x" ]
6
7 (* Star a recursive lens *)
8 let star = r*
9
10 test star get "aax" = { "a" { "a" = "x" } }
11 test star put "aax" after rm "/nothing" = "aax"
12
13 test star get "axax" = { "a" = "x" } { "a" = "x" }
14 test star put "axaaxax" after rm "/a[2]" = "axax"
15
16 (* Use a starred recursive lens in a more complicated construct *)
17 let top = [ label "top" . r* . value "high" ]
18
19 test top get "axaax" = { "top" = "high" { "a" = "x" } { "a" { "a" = "x" } } }
20 test top put "axaax" after rm "/top/a[1]" = "aax"
21
22 (* Use a recursive lens in a union *)
23 let union = (r | [ key "b" . store /[a-z]/ ])*
24
25 test union get "aaxbyax" =
26   { "a" { "a" = "x" } } { "b" = "y" } { "a" = "x" }
27 test union put "aaxbyax" after
28   set "/b[2]" "z" = "aaxbyaxbz"
29 test union put "aaxbyax" after
30   set "/b[2]" "z"; rm "/b[1]" = "aaxaxbz"