Provides unit tests and examples for the Build lens.
Test_Build | Provides unit tests and examples for the Build lens. |
GENERIC CONSTRUCTIONS | |
brackets | Test brackets |
brackets | |
LIST CONSTRUCTIONS | |
list | |
list | |
list | |
opt_list | |
opt_list | |
LABEL OPERATIONS | |
xchg | |
xchg | |
xchgs | |
xchgs | |
SUBNODE CONSTRUCTIONS | |
key_value_line | |
key_value_line | |
key_value_line_comment | |
key_value_line_comment | |
key_value | |
key_value | |
key_ws_value | |
key_ws_value | |
flag | |
flag | |
flag_line | |
flag_line | |
BLOCK CONSTRUCTIONS | |
block_entry | The block entry used for testing |
block | The block used for testing |
block | Simple test for block |
block | Simple test for block with newlines |
block | Simple test for block two indented entries |
block | Test block with a comment |
block | Test block with comments and newlines |
block | Test defaults for blocks |
named_block | The named block used for testing |
named_block | Simple test for named_block |
logrotate_block | A minimalistic logrotate block |
logrotate_block | |
COMBINATORICS | |
combine_two | A minimalistic combination lens |
combine_two | Should parse ab |
combine_two | Should parse ba |
combine_two | Should not parse a |
combine_two | Should not parse b |
combine_two | Should not parse aa |
combine_two | Should not parse bb |
combine_two_opt | A minimalistic optional combination lens |
combine_two_opt | Should parse ab |
combine_two_opt | Should parse ba |
combine_two_opt | Should parse a |
combine_two_opt | Should parse b |
combine_two_opt | Should not parse aa |
combine_two_opt | Should not parse bb |
combine_three | A minimalistic optional combination lens |
combine_three | Should not parse ab |
combine_three | Should not parse ba |
combine_three | Should not parse a |
combine_three | Should not parse b |
combine_three | Should not parse aa |
combine_three | Should not parse bbc |
combine_three | Should parse abc |
combine_three | Should parse cab |
combine_three_opt | A minimalistic optional combination lens |
combine_three_opt | Should parse ab |
combine_three_opt | Should parse ba |
combine_three_opt | Should parse a |
combine_three_opt | Should parse b |
combine_three_opt | Should not parse aa |
combine_three_opt | Should not parse bbc |
combine_three_opt | Should parse abc |
combine_three_opt | Should parse cab |
test block get " {test=1}" = { "test" = "1" }
Simple test for block
test block get " {\n test=1\n}" = { "test" = "1" }
Simple test for block with newlines
test block get " {\n test=1 \n test=2 \n}" = { "test" = "1" } { "test" = "2" }
Simple test for block two indented entries
test block get " { # This is a comment\n}" = { "#comment" = "This is a comment" }
Test block with a comment
test block get " { # This is a comment\n# Another comment\n}" = { "#comment" = "This is a comment" } { "#comment" = "Another comment" }
Test block with comments and newlines
test named_block get "foo {test=1}\n" = { "foo" { "test" = "1" } }
Simple test for named_block
let logrotate_block = let entry = [ key Rx.word ] in let filename = [ label "file" . store /\/[^,#= \n\t{}]+/ ] in let filename_sep = del /[ \t\n]+/ " " in let filenames = Build.opt_list filename filename_sep in [ label "rule" . filenames . Build.block entry ]
A minimalistic logrotate block
Test brackets
let brackets = [ Build.brackets Sep.lbracket Sep.rbracket (key Rx.word) ]
let list = Build.list [ key Rx.word ] Sep.space
let opt_list = Build.opt_list [ key Rx.word ] Sep.space
let xchg = [ Build.xchg Rx.space " " "space" ]
let xchgs = [ Build.xchgs " " "space" ]
let key_value_line = Build.key_value_line Rx.word Sep.equal (store Rx.word)
let key_value_line_comment = Build.key_value_line_comment Rx.word Sep.equal (store Rx.word) Util.comment
let key_value = Build.key_value Rx.word Sep.equal (store Rx.word)
let key_ws_value = Build.key_ws_value Rx.word
let flag = Build.flag Rx.word
let flag_line = Build.flag_line Rx.word
The block entry used for testing
let block_entry = Build.key_value "test" Sep.equal (store Rx.word)
The block used for testing
let block = Build.block block_entry
The named block used for testing
let named_block = Build.named_block "foo" block_entry
A minimalistic logrotate block
let logrotate_block = let entry = [ key Rx.word ] in let filename = [ label "file" . store /\/[^,#= \n\t{}]+/ ] in let filename_sep = del /[ \t\n]+/ " " in let filenames = Build.opt_list filename filename_sep in [ label "rule" . filenames . Build.block entry ]
A minimalistic combination lens
let combine_two = let entry (k:string) = [ key k ] in Build.combine_two (entry "a") (entry "b")
A minimalistic optional combination lens
let combine_two_opt = let entry (k:string) = [ key k ] in Build.combine_two_opt (entry "a") (entry "b")
A minimalistic optional combination lens
let combine_three = let entry (k:string) = [ key k ] in Build.combine_three (entry "a") (entry "b") (entry "c")
A minimalistic optional combination lens
let combine_three_opt = let entry (k:string) = [ key k ] in Build.combine_three_opt (entry "a") (entry "b") (entry "c")