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

#######################################################
bundle agent init
{
  meta:
    "test_soft_fail"
      string => "!linux",
      meta => { "redmine7950" };

  vars:
    "a" slist => { "a", "b", "c", "d", "e", "f", "g" };
    "b" slist => {};
}

#######################################################
bundle agent test
{
  meta:
    # for some reason, shuffle() produces different results on 64bit RHEL 4
    # and Debian 4 than everywhere else
    "test_soft_fail"
      string => "((centos_4|centos_5|debian_4).64_bit)|windows",
      meta => { "CFE-2301,ENT-10254" };

  vars:
    "lists" slist => { "a", "b" };
    "seeds" slist => { "skruf", "cormorant", "dollhouse" };
    "shuffle_$(lists)_$(seeds)" slist => shuffle("init.$(lists)", $(seeds));

    "shuffle_inline_$(seeds)"
      slist => shuffle('["a", "b", "delta", "farmer"]', $(seeds));
}

#######################################################
bundle agent check
{
  methods:
    "check"
      usebundle => dcs_check_state(
        test,
        "$(this.promise_filename).expected.json",
        $(this.promise_filename)
      );
}
