tasks: - name: "String interpretation" vars: a_string: "A string" a_dictionary: {"a": "dictionary"} a_list: ["a", "list"] assert: that: # Note that a string is classed as also being "iterable" and "sequence", but not "mapping" - a_string is string and a_string is iterable and a_string is sequence and a_string is not mapping
# Note that a dictionary is classed as not being a "string", but is "iterable", "sequence" and "mapping" - a_dictionary is not string and a_dictionary is iterable and a_dictionary is mapping
# Note that a list is classed as not being a "string" or "mapping" but is "iterable" and "sequence" - a_list is not string and a_list is not mapping and a_list is iterable
- name: "Number interpretation" vars: a_float: 1.01 a_float_as_string: "1.01" an_integer: 1 an_integer_as_string: "1" assert: that: # Both a_float and an_integer are "number", but each has their own type as well - a_float is number and a_float is float - an_integer is number and an_integer is integer
# Both a_float_as_string and an_integer_as_string are not numbers - a_float_as_string is not number and a_float_as_string is string - an_integer_as_string is not number and a_float_as_string is string
# a_float or a_float_as_string when cast to a float and then to a string should match the same value cast only to a string - a_float | float | string == a_float | string - a_float_as_string | float | string == a_float_as_string | string
# Likewise an_integer and an_integer_as_string when cast to an integer and then to a string should match the same value cast only to an integer - an_integer | int | string == an_integer | string - an_integer_as_string | int | string == an_integer_as_string | string
# However, a_float or a_float_as_string cast as an integer and then a string does not match the same value cast to a string - a_float | int | string != a_float | string - a_float_as_string | int | string != a_float_as_string | string
# Again, Likewise an_integer and an_integer_as_string cast as a float and then a string does not match the same value cast to a string - an_integer | float | string != an_integer | string - an_integer_as_string | float | string != an_integer_as_string | string
- name: "Native Boolean interpretation" loop: - yes - true - True - TRUE - no - No - NO - false - False - FALSE assert: that: # Note that while other values may be cast to boolean values, these are the only ones that are natively considered boolean # Note also that `yes` is the only case-sensitive variant of these values. - item is boolean