{
  "schema": "https://bars.commonsware.com/conformance/schema/render-fixture.schema.json",
  "version": "0.1.0",
  "cases": [
    {
      "name": "sum-integers",
      "spotlight": true,
      "description": "Sums a list of integers; a whole-number total renders without a decimal point.",
      "template": "{{ xs | sum }}",
      "context": {
        "xs": [
          1,
          2,
          3
        ]
      },
      "expect": {
        "kind": "output",
        "expectedOutput": "6"
      }
    },
    {
      "name": "sum-fractional",
      "description": "A non-whole total renders with its fractional part.",
      "template": "{{ xs | sum }}",
      "context": {
        "xs": [
          1.5,
          2.0
        ]
      },
      "expect": {
        "kind": "output",
        "expectedOutput": "3.5"
      }
    },
    {
      "name": "sum-numeric-strings",
      "description": "Numeric strings are coerced to numbers before summing.",
      "template": "{{ xs | sum }}",
      "context": {
        "xs": [
          "1",
          "2",
          "3"
        ]
      },
      "expect": {
        "kind": "output",
        "expectedOutput": "6"
      }
    },
    {
      "name": "sum-by-property",
      "spotlight": true,
      "description": "With a property argument, the property of each struct is summed.",
      "template": "{{ items | sum: \"n\" }}",
      "context": {
        "items": [
          {
            "n": 2
          },
          {
            "n": 3
          }
        ]
      },
      "expect": {
        "kind": "output",
        "expectedOutput": "5"
      }
    },
    {
      "name": "sum-empty-list",
      "description": "Summing an empty list yields zero.",
      "template": "{{ xs | sum }}",
      "context": {
        "xs": []
      },
      "expect": {
        "kind": "output",
        "expectedOutput": "0"
      }
    },
    {
      "name": "sum-non-numeric-is-null",
      "description": "A non-numeric element means the list does not match the transform's shape, so the result is null.",
      "template": "{{ xs | sum }}",
      "context": {
        "xs": [
          1,
          "abc",
          3
        ]
      },
      "expect": {
        "kind": "output",
        "expectedOutput": "null"
      }
    },
    {
      "name": "sum-property-missing-is-null",
      "description": "A struct missing the requested property yields a non-numeric value, so the result is null.",
      "template": "{{ items | sum: \"n\" }}",
      "context": {
        "items": [
          {
            "n": 2
          },
          {
            "m": 3
          }
        ]
      },
      "expect": {
        "kind": "output",
        "expectedOutput": "null"
      }
    },
    {
      "name": "sum-property-non-struct-is-null",
      "description": "With a property, a non-struct element cannot supply the value, so the result is null.",
      "template": "{{ xs | sum: \"n\" }}",
      "context": {
        "xs": [
          1,
          2
        ]
      },
      "expect": {
        "kind": "output",
        "expectedOutput": "null"
      }
    },
    {
      "name": "sum-non-list-is-null",
      "description": "sum operates only on lists; a string input yields null.",
      "template": "{{ x | sum }}",
      "context": {
        "x": "hi"
      },
      "expect": {
        "kind": "output",
        "expectedOutput": "null"
      }
    },
    {
      "name": "sum-boolean-element-is-null",
      "description": "A boolean element is neither numeric nor a numeric string, so the result is null.",
      "template": "{{ xs | sum }}",
      "context": {
        "xs": [
          true
        ]
      },
      "expect": {
        "kind": "output",
        "expectedOutput": "null"
      }
    },
    {
      "name": "sum-two-args-is-error",
      "description": "More than one argument is an arity error.",
      "template": "{{ xs | sum: \"a\" \"b\" }}",
      "context": {
        "xs": [
          1
        ]
      },
      "expect": {
        "kind": "error",
        "errorCode": "KB-2002"
      }
    }
  ]
}
