#######################################################
#
# Test readintlist() issue 364
#
#######################################################

body common control
{
      inputs => { "../../default.sub.cf" };
      bundlesequence  => { default("$(this.promise_filename)") };   
      version => "1.0";
}

bundle agent init
{
  files:
      "$(G.testfile)"
      delete => init_delete;
      
      "$(G.testfile)"
      create => "true",
      edit_line => init_fill_in;
}

bundle edit_line init_fill_in
{
  insert_lines:
      "123 456 789";
}

body delete init_delete
{
      dirlinks => "delete";
      rmdirs   => "true";
}

#######################################################

bundle agent test
{
  vars:
      "nums" ilist => readintlist("$(G.testfile)","NoComment","\s+",5,100);
      "sum" real => sum("nums");
}

#######################################################

bundle agent check
{
  vars:
      "nums" ilist => { @{test.nums} };

  classes:
      "ok_list" not => strcmp("won't match", "$(nums)");
      "ok123" expression => strcmp("123", "$(nums)");
      "ok456" expression => strcmp("456", "$(nums)");
      "ok789" expression => strcmp("789", "$(nums)");
      "ok" and => { "ok_list", "ok123", "ok456", "ok789",
		    islessthan("$(test.sum)", "1368.1"),
		    isgreaterthan("$(test.sum)", "1367.9")
      };

  reports:
    DEBUG::
      "nums: $(nums)";
      "sum: $(test.sum)";
    ok::
      "$(this.promise_filename) Pass";

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