blob: 5e8a07364de27c23439f4ab5a723fe4e746218b1 [file] [log] [blame]
cue eval -ic bounds.cue
cmp stdout expect-stdout-cue
-- frontmatter.toml --
title = "Bounds"
description = ""
-- text.md --
Bounds define a lower bound, upper bound, or inequality for a certain value.
They work on numbers, strings, bytes and null.
The bound is defined for all values for which the corresponding comparison
operation is define.
For instance `>5.0` allows all floating point values greater than `5.0`,
whereas `<0` allows all negative numbers (int or float).
-- bounds.cue --
rn :: >=3 & <8 // type int | float
ri :: >=3 & <8 & int // type int
rf :: >=3 & <=8.0 // type float
rs :: >="a" & <"mo"
a: rn & 3.5
b: ri & 3.5
c: rf & 3
d: rs & "ma"
e: rs & "mu"
r1: rn & >=5 & <10
-- expect-stdout-cue --
a: 3.5
b: _|_ // conflicting values ri and 3.5 (mismatched types int and float)
c: 3
d: "ma"
e: _|_ // invalid value "mu" (out of bound <"mo")
r1: >=5 & <8