Skip to content

Conformance Examples 0.1.0 — Render: int-float-parity

render-parity-integer-literal

An integer JSON literal renders as its plain digits.

Template

{{ /n }}

Context

{
    "n": 2
}

Output

2

render-parity-whole-double-literal

A whole-valued double JSON literal (2.0) renders identically to the integer 2, per ECMA-262 Number::toString: kBars does not distinguish int from float at the render boundary.

Template

{{ /n }}

Context

{
    "n": 2.0
}

Output

2

eq-parity-integer-vs-whole-double

Equality treats 2 and 2.0 as the same numeric value; the int/float distinction is not observable via ==.

Template

{{ a == b }}

Context

{
    "a": 2,
    "b": 2.0
}

Output

true

ne-parity-integer-vs-different-double

!= still distinguishes numerically different values regardless of which side is an integer literal and which is a decimal literal.

Template

{{ a != b }}

Context

{
    "a": 2,
    "b": 2.5
}

Output

true

truthy-parity-nonzero-integer

A nonzero integer is truthy.

Template

{{#if n }}T{{else}}F{{/if}}

Context

{
    "n": 2
}

Output

T

truthy-parity-nonzero-whole-double

A nonzero whole-valued double is truthy, matching the integer case: truthiness does not observe the int/float distinction.

Template

{{#if n }}T{{else}}F{{/if}}

Context

{
    "n": 2.0
}

Output

T

falsy-parity-zero-integer

Integer 0 is falsy.

Template

{{#if n }}T{{else}}F{{/if}}

Context

{
    "n": 0
}

Output

F

falsy-parity-zero-double

0.0 is falsy, matching the integer 0 case: truthiness does not observe the int/float distinction, even at zero.

Template

{{#if n }}T{{else}}F{{/if}}

Context

{
    "n": 0.0
}

Output

F

Source fixture: render/int-float-parity.json