1####################################################### 2# 3# Test nth() 4# 5####################################################### 6 7body common control 8{ 9 inputs => { "../../default.cf.sub" }; 10 bundlesequence => { default("$(this.promise_filename)") }; 11 version => "1.0"; 12} 13 14####################################################### 15 16bundle agent init 17{ 18 vars: 19 "results" slist => { 20 "starting list = 1", 21 "starting list = 2", 22 "starting list = 3", 23 "starting list = one", 24 "starting list = two", 25 "starting list = three", 26 "starting list = long string", 27 "starting list = four", 28 "starting list = fix", 29 "starting list = six", 30 "starting list = one", 31 "starting list = two", 32 "starting list = three", 33 "element #0 of the test list: 1", 34 "element #1 of the test list: 2", 35 "element #10 of the test list: one", 36 "element #11 of the test list: two", 37 "element #2 of the test list: 3", 38 "element #6 of the test list: long string", 39 "element #-1 of the test list: three", 40 "element #-13 of the test list: 1", 41 "element #-6 of the test list: four", 42 }; 43 44 files: 45 "$(G.testfile).expected" 46 create => "true", 47 edit_defaults => init_empty, 48 edit_line => init_insert; 49} 50 51body edit_defaults init_empty 52{ 53 empty_file_before_editing => "true"; 54 edit_backup => "false"; 55} 56 57bundle edit_line init_insert 58{ 59 insert_lines: 60 "$(init.results)"; 61} 62 63####################################################### 64 65bundle agent test 66{ 67 vars: 68 "test" slist => { 69 1,2,3, 70 "one", "two", "three", 71 "long string", 72 "four", "fix", "six", 73 "one", "two", "three", 74 }; 75 76 "nth" slist => { 1, 2, 6, 10, 11, 1000, "-1", "-13", "-6", "-1000" }; 77 78 "test[$(nth)]" string => nth("test", $(nth)); 79 "test[0]" string => nth("test", 0); 80 81 files: 82 "$(G.testfile).actual" 83 create => "true", 84 edit_line => test_insert; 85} 86 87bundle edit_line test_insert 88{ 89 insert_lines: 90 "starting list = $(test.test)"; 91 "element #$(test.nth) of the test list: $(test.test[$(test.nth)])"; 92 "element #0 of the test list: $(test.test[0])"; 93} 94 95####################################################### 96 97bundle agent check 98{ 99 methods: 100 "any" usebundle => sorted_check_diff("$(G.testfile).actual", 101 "$(G.testfile).expected", 102 "$(this.promise_filename)"); 103} 104