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 |
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 ]