#######################################################
#
# Don't delete a line, set a class
# Region editing, include_start_delimiter and include_end_delimiter
#
#######################################################
body common control
{
  inputs => { "../../default.sub.cf" };
  bundlesequence => { default("$(this.promise_filename)") };
  version => "1.0";
}

#######################################################
bundle agent init
{
  vars:
    "states" slist => { "actual", "expected" };

    "actual"
      string => "header
header
BEGIN
    One potato
    Two potato
    Three potatoe
    Four
END
trailer
trailer";

    "expected"
      string => "header
header
BEGIN
    One potato
    Two potato
    Three potatoe
    Four
END
trailer
trailer";

  files:
    "$(G.testfile).$(states)"
      create => "true",
      edit_line => init_insert("$(init.$(states))"),
      edit_defaults => init_empty;
}

bundle edit_line init_insert(str)
{
  insert_lines:
    "$(str)";
}

body edit_defaults init_empty
{
  empty_file_before_editing => "true";
}

#######################################################
bundle agent test
{
  vars:
    "tstr" string => "    Three potatoe  ";

  # NOTE, DOES NOT MATCH!
  files:
    "$(G.testfile).actual" edit_line => test_delete("$(test.tstr)");
}

bundle edit_line test_delete(str)
{
  delete_lines:
    "$(str)"
      classes => test_class("ok"),
      select_region => test_select;
}

body select_region test_select
{
  select_start => "BEGIN";
  select_end => "END";
  include_start_delimiter => "true";
  include_end_delimiter => "true";
}

body classes test_class(a)
{
  promise_kept => { "$(a)" };
}

#######################################################
bundle agent check
{
  reports:
    ok::
      "$(this.promise_filename) Pass";

    !ok::
      "$(this.promise_filename) FAIL";
}

### PROJECT_ID: core
### CATEGORY_ID: 27
