Skip to content

Conformance Examples 0.1.0 — Render: equality-operators

eq-bool-bool-truthy

Rule (1) boolean side: both true under truthiness; equal.

Template

{{ a == b }}

Context

{
    "a": true,
    "b": true
}

Output

true

eq-bool-bool-mixed

Rule (1) boolean side: true vs. false under truthiness; not equal.

Template

{{ a == b }}

Context

{
    "a": true,
    "b": false
}

Output

false

eq-bool-vs-truthy-string

Rule (1) wins over rule (2): when one side is boolean, both reduce to truthiness. 'x' is truthy, true is truthy: equal.

Template

{{ a == "x" }}

Context

{
    "a": true
}

Output

true

eq-bool-vs-empty-string

Rule (1) wins over rule (2): false is falsy and '' is falsy: equal.

Template

{{ a == "" }}

Context

{
    "a": false
}

Output

true

ne-bool-bool

Rule (1) boolean side, != negation.

Template

{{ a != b }}

Context

{
    "a": true,
    "b": false
}

Output

true

eq-string-string

Rule (2) string side: identical string contents are equal.

Template

{{ a == "hello" }}

Context

{
    "a": "hello"
}

Output

true

eq-string-number-same-text

Rule (2) string side: the number renders as '42' and equals the string '42'.

Template

{{ a == 42 }}

Context

{
    "a": "42"
}

Output

true

ne-string-number-different-text

Rule (2) string side: '42' != '7' as strings.

Template

{{ a != 7 }}

Context

{
    "a": "42"
}

Output

true

eq-string-null

Rule (2) string side: when one operand is the string 'null', the other (null) renders to the literal 'null' via renderString(); equal.

Template

{{ a == null }}

Context

{
    "a": "null"
}

Output

true

eq-numeric-int-int

Rule (3) numeric: both operands numeric integers; equal.

Template

{{ a == 42 }}

Context

{
    "a": 42
}

Output

true

eq-numeric-int-vs-double

Rule (3) numeric: integer 42 and decimal 42.0 compare equal as Double.

Template

{{ a == 42.0 }}

Context

{
    "a": 42
}

Output

true

ne-numeric-int-int

Rule (3) numeric, != negation.

Template

{{ a != 7 }}

Context

{
    "a": 42
}

Output

true

eq-structural-null-null

Rule (4) structural: explicit JsonNull on both sides; equal.

Template

{{ a == b }}

Context

{
    "a": null,
    "b": null
}

Output

true

eq-structural-missing-missing

Rule (4) structural: both identifiers missing; resolution yields null on both sides; null == null is true.

Template

{{ a == b }}

Context

{}

Output

true

eq-structural-array-array

Rule (4) structural: identical JsonArrays compare equal via kotlinx-serialization structural equality.

Template

{{ a == b }}

Context

{
    "a": [
        1,
        2
    ],
    "b": [
        1,
        2
    ]
}

Output

true

eq-structural-object-object

Rule (4) structural: identical JsonObjects compare equal.

Template

{{ a == b }}

Context

{
    "a": {
        "x": 1
    },
    "b": {
        "x": 1
    }
}

Output

true

ne-structural-array-different

Rule (4) structural: differing arrays.

Template

{{ a != b }}

Context

{
    "a": [
        1,
        2
    ],
    "b": [
        1,
        3
    ]
}

Output

true

eq-block-if

Equality operator inside an #if expression slot.

Template

{{#if a == "yes" }}MATCH{{else}}MISS{{/if}}

Context

{
    "a": "yes"
}

Output

MATCH

eq-negative-numbers

Equality with negative numeric values.

Template

{{ a == -42 }}

Context

{
    "a": -42
}

Output

true

ne-negative-vs-positive

Inequality between negative and positive numbers.

Template

{{ a != -5 }}

Context

{
    "a": 5
}

Output

true

eq-boolean-left-string-right

Rule (1) wins: left is boolean, right is string.

Template

{{ a == b }}

Context

{
    "a": true,
    "b": "hello"
}

Output

true

eq-string-left-boolean-right

Rule (1) wins: left is string, right is boolean (order matters for branch coverage).

Template

{{ a == b }}

Context

{
    "a": "nonempty",
    "b": false
}

Output

false

ne-numeric-both

!= with both operands numeric.

Template

{{ 5 != 10 }}

Context

{}

Output

true

eq-numeric-left-string-literal-right

Rule (2) wins: numeric 42 compared with string '42'.

Template

{{ 42 == "42" }}

Context

{}

Output

true

eq-numeric-vs-null

Rule (4) structural fallback when one side is numeric and the other is JsonNull: neither boolean nor string applies; numeric/structural rule returns false because the right side is not numeric and JsonPrimitive(5) != JsonNull structurally.

Template

{{ a == b }}

Context

{
    "a": 5,
    "b": null
}

Output

false

Source fixture: render/equality-operators.json