1####################################################### 2# 3# Test regextract 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 "text" string => "node-01-10.0"; 20 21 classes: 22 "parsed_text" expression => regextract("^\w+-(\d+)-(\d+\.\d+)", "$(text)", "pair"); 23 24 reports: 25 DEBUG.!parsed_text:: 26 "Failed to parse $(text)"; 27} 28 29####################################################### 30 31bundle agent test 32{ 33 vars: 34 "lefts" string => "$(init.pair[1])"; 35 "lefti" int => "$(init.pair[1])"; 36 "rights" string => "$(init.pair[2])"; 37 "rightr" real => "$(init.pair[2])"; 38} 39 40 41####################################################### 42 43bundle agent check 44{ 45 classes: 46 "sok" expression => strcmp("$(test.lefts):$(test.rights)", "01:10.0"); 47 "iok" expression => strcmp("$(test.lefti)", "1"); 48 "rok" expression => strcmp("$(test.rightr)", "10.000000"); 49 "ok" and => { "sok", "iok", "rok" }; 50 51 reports: 52 DEBUG.!iok:: 53 "Parsed integer '$(test.lefti)' isn't 1"; 54 DEBUG.!rok:: 55 "Parsed real '$(test.rightr)' isn't 10.000000"; 56 DEBUG.!sok:: 57 "Parsed numbers '$(test.lefts)' and '$(test.rights)' aren't '01' and '10.0'"; 58 59 ok:: 60 "$(this.promise_filename) Pass"; 61 !ok:: 62 "$(this.promise_filename) FAIL"; 63} 64