File: parse_number_3572.cf

package info (click to toggle)
cfengine3 3.24.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 37,552 kB
  • sloc: ansic: 163,161; sh: 10,296; python: 2,950; makefile: 1,744; lex: 784; yacc: 633; perl: 211; pascal: 157; xml: 21; sed: 13
file content (59 lines) | stat: -rw-r--r-- 1,442 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#######################################################
#
# Regression test for RedMine #3572.
#
#######################################################

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

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

bundle agent init
{
  vars:
      "digits" string => "42";
}

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

bundle agent test
{
  vars:
      "number" int => "$(init.digits)";
      "floaty" real => "$(init.digits)";

  # RedMine #3572: this stanza should make no difference, but actually
  # caused the numbers to be unexpanded, hence not "42" but literally
  # "$(init.digits)", which doesn't parse as a number !
  classes:
      "ignored" not => "any";
  # (In fact, even an empty classes stanza provoked the bug - but is
  # that even valid ?)
}


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

bundle agent check
{
  classes:
      "iok" expression => strcmp("$(test.number)", "$(init.digits)");
      "rok" expression => strcmp("$(test.floaty)", "42.000000");
      "ok" and => { "iok", "rok" };

  reports:
    DEBUG.!iok::
      "Read $(init.digits) as int $(test.number)";
    DEBUG.!rok::
      "Read $(init.digits) as real $(test.floaty)";

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