{
  "schema": "https://bars.commonsware.com/conformance/schema/render-fixture.schema.json",
  "version": "0.1.0",
  "cases": [
    {
      "name": "if-doubled-adjacent-if-same-key",
      "description": "Two adjacent {{#if}} blocks over the same key render independently; the second is unaffected by the first.",
      "template": "{{#if flag }}A{{/if}}{{#if flag }}B{{/if}}",
      "context": {
        "flag": true
      },
      "expect": {
        "kind": "output",
        "expectedOutput": "AB"
      }
    },
    {
      "name": "if-else-after-else-if-rejected",
      "description": "{{else}} appearing before {{else if}} (or more strictly, {{else if}} after {{else}}) is a parse error.",
      "template": "{{#if a }}A{{else}}Z{{else if b }}B{{/if}}",
      "context": {
        "a": false,
        "b": true
      },
      "expect": {
        "kind": "error"
      }
    },
    {
      "name": "if-else-if-all-falsy-no-else-emits-nothing",
      "description": "Every arm falsy and no else arm: nothing is emitted.",
      "template": "[{{#if a }}A{{else if b }}B{{else if c }}C{{/if}}]",
      "context": {
        "a": false,
        "b": 0,
        "c": ""
      },
      "expect": {
        "kind": "output",
        "expectedOutput": "[]"
      }
    },
    {
      "name": "if-else-if-all-falsy-with-else-renders-else",
      "description": "Every arm falsy with an else arm present: the else body renders.",
      "template": "{{#if a }}A{{else if b }}B{{else if c }}C{{else}}Z{{/if}}",
      "context": {
        "a": false,
        "b": 0,
        "c": ""
      },
      "expect": {
        "kind": "output",
        "expectedOutput": "Z"
      }
    },
    {
      "name": "if-else-if-first-arm-wins",
      "description": "First arm truthy: its body renders and later arms are skipped.",
      "template": "{{#if a }}A{{else if b }}B{{else if c }}C{{else}}Z{{/if}}",
      "context": {
        "a": true,
        "b": true,
        "c": true
      },
      "expect": {
        "kind": "output",
        "expectedOutput": "A"
      }
    },
    {
      "name": "if-else-if-inside-unless-rejected",
      "description": "{{else if}} is only legal inside {{#if}}; it must be a parse error inside {{#unless}}.",
      "template": "{{#unless a }}A{{else if b }}B{{/unless}}",
      "context": {
        "a": false,
        "b": true
      },
      "expect": {
        "kind": "error"
      }
    },
    {
      "name": "if-else-if-second-arm-wins-when-first-falsy",
      "description": "First arm falsy, second arm truthy: second arm's body renders.",
      "template": "{{#if a }}A{{else if b }}B{{else if c }}C{{else}}Z{{/if}}",
      "context": {
        "a": false,
        "b": true,
        "c": true
      },
      "expect": {
        "kind": "output",
        "expectedOutput": "B"
      }
    },
    {
      "name": "if-else-if-third-arm-wins-when-first-two-falsy",
      "description": "First two arms falsy, third truthy: third arm's body renders.",
      "template": "{{#if a }}A{{else if b }}B{{else if c }}C{{else}}Z{{/if}}",
      "context": {
        "a": false,
        "b": false,
        "c": true
      },
      "expect": {
        "kind": "output",
        "expectedOutput": "C"
      }
    },
    {
      "name": "if-empty-array-is-falsy",
      "description": "An empty JsonArray is falsy: the else arm renders.",
      "template": "{{#if items }}yes{{else}}no{{/if}}",
      "context": {
        "items": []
      },
      "expect": {
        "kind": "output",
        "expectedOutput": "no"
      }
    },
    {
      "name": "if-empty-object-is-truthy",
      "description": "An empty JsonObject is truthy (matches Handlebars): the body renders.",
      "template": "{{#if obj }}yes{{else}}no{{/if}}",
      "context": {
        "obj": {}
      },
      "expect": {
        "kind": "output",
        "expectedOutput": "yes"
      }
    },
    {
      "name": "if-empty-string-is-falsy",
      "description": "An empty string is falsy: the else arm renders.",
      "template": "{{#if s }}yes{{else}}no{{/if}}",
      "context": {
        "s": ""
      },
      "expect": {
        "kind": "output",
        "expectedOutput": "no"
      }
    },
    {
      "name": "if-false-no-else-emits-nothing",
      "description": "Identifier resolves to false and there is no else arm: emits nothing.",
      "template": "[{{#if flag }}yes{{/if}}]",
      "context": {
        "flag": false
      },
      "expect": {
        "kind": "output",
        "expectedOutput": "[]"
      }
    },
    {
      "name": "if-false-with-else-renders-else",
      "description": "Identifier resolves to false and an else arm is present: the else arm renders.",
      "template": "{{#if flag }}yes{{else}}no{{/if}}",
      "context": {
        "flag": false
      },
      "expect": {
        "kind": "output",
        "expectedOutput": "no"
      }
    },
    {
      "name": "if-jsonnull-is-falsy",
      "description": "An explicit JsonNull value is falsy.",
      "template": "{{#if flag }}yes{{else}}no{{/if}}",
      "context": {
        "flag": null
      },
      "expect": {
        "kind": "output",
        "expectedOutput": "no"
      }
    },
    {
      "name": "if-missing-key-treated-as-falsy",
      "description": "A missing key resolves to null and is treated as falsy: the else arm renders.",
      "template": "{{#if absent }}yes{{else}}no{{/if}}",
      "context": {
        "flag": true
      },
      "expect": {
        "kind": "output",
        "expectedOutput": "no"
      }
    },
    {
      "name": "if-multiple-spaces-between-else-and-if",
      "description": "Whitespace between 'else' and 'if' is permitted (spaces and tabs).",
      "template": "{{#if a }}A{{else  if b }}B{{/if}}",
      "context": {
        "a": false,
        "b": true
      },
      "expect": {
        "kind": "output",
        "expectedOutput": "B"
      }
    },
    {
      "name": "if-nested-inside-each-with-parent-pointer",
      "description": "Sanity: {{#if}} inside {{#each}} can address the current item and a parent value.",
      "template": "{{#each items }}{{#if active }}[{{ this/name }}]{{/if}}{{/each}}",
      "context": {
        "items": [
          {
            "name": "a",
            "active": true
          },
          {
            "name": "b",
            "active": false
          },
          {
            "name": "c",
            "active": true
          }
        ]
      },
      "expect": {
        "kind": "output",
        "expectedOutput": "[a][c]"
      }
    },
    {
      "name": "if-true-renders-body",
      "description": "Identifier resolves to true: the body renders.",
      "template": "{{#if flag }}yes{{/if}}",
      "context": {
        "flag": true
      },
      "expect": {
        "kind": "output",
        "expectedOutput": "yes"
      }
    },
    {
      "name": "if-zero-is-falsy",
      "description": "The number 0 is falsy: the else arm renders.",
      "template": "{{#if n }}yes{{else}}no{{/if}}",
      "context": {
        "n": 0
      },
      "expect": {
        "kind": "output",
        "expectedOutput": "no"
      }
    }
  ]
}
