-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pan: support default/fallback value for built-in function value()
- Loading branch information
Showing
10 changed files
with
106 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# @expect="/nlist[@name="profile"]/long[@name="a"]=0 and /nlist[@name="profile"]/long[@name="value"]=0 and /nlist[@name="profile"]/long[@name="default"]=1" | ||
# @format=pan | ||
# | ||
object template value2; | ||
|
||
variable SOMETHING = dict("key", "abc"); | ||
|
||
"/a" = 0; | ||
"/value" = value("/a", 1); | ||
"/default" = value("/nopath", 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# @expect="/nlist[@name='profile']/boolean[@name='undef']='true' and /nlist[@name='profile']/boolean[@name='null']='true'" | ||
# @format=pan | ||
# | ||
object template value3; | ||
|
||
"/undef" = !is_defined(value("/nopath", undef)); | ||
"/null" = is_null(value("/nopath", null)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# @expect="/nlist[@name='profile']/nlist[@name='var']/string[@name='key']='abc' and /nlist[@name='profile']/nlist[@name='othervar']/string[@name='key']='xyz' and /nlist[@name='profile']/nlist[@name='origvar']/string[@name='key']='abc'" | ||
# @format=pan | ||
# | ||
object template value4; | ||
|
||
variable SOMETHING = dict("key", "abc"); | ||
|
||
"/var" = value("/nopath", SOMETHING); | ||
# test copy of variable | ||
"/othervar" = { | ||
t = value("/nopath", SOMETHING); | ||
# modify the value, should not modify the original variable | ||
t['key'] = 'xyz'; | ||
t; | ||
}; | ||
"/origvar" = SOMETHING; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# @expect="/nlist[@name='profile']/string[@name='self']='myself'" | ||
# @format=pan | ||
# | ||
object template value5; | ||
|
||
"/self" = "myself"; | ||
"/self" = value("/nopath", SELF); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# @expect=org.quattor.pan.exceptions.EvaluationException | ||
object template value6; | ||
|
||
# reraise Syntax error as Evaluation error | ||
"/a" = value(list(1)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# @expect=org.quattor.pan.exceptions.EvaluationException | ||
object template value7; | ||
|
||
"/a" = value("/nopath"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# @expect=org.quattor.pan.exceptions.EvaluationException | ||
object template value8; | ||
|
||
"/a" = value("/nopath", garbage); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# @expect="/nlist[@name="profile"]/long[@name="undef"]=0 and /nlist[@name="profile"]/long[@name="value"]=5" | ||
# @format=pan | ||
# | ||
object template value9; | ||
|
||
bind "/undef" = long = 0; | ||
|
||
"/undef" = undef; | ||
"/value" = value("/undef", 5); |