Magic values test values
Words a human reads as text and a parser reads as a boolean, an absent value or a number. 12 values, each with what it breaks and what a correct application does instead.
Type them one at a time with AltShiftN
in the palette, or take them all into a script with nkb emit magic-values.
The word no
magic-values/bool-no
no
no
- 2 graphemes
- 2 code points
- 2 bytes
- 2 UTF-16 units
- What it breaks
- YAML 1.1 and several config parsers read the unquoted word no as boolean false - and NO is the country code for Norway.
- What a correct application does
- Stored and returned as the two-character string no.
The word null
magic-values/word-null
null
null
- 4 graphemes
- 4 code points
- 4 bytes
- 4 UTF-16 units
- What it breaks
- Serializers and loosely typed interfaces turn the text into an absent value; the field looks saved and comes back empty.
- What a correct application does
- Stored and returned as the four-character string, distinct from an empty field.
The word true
magic-values/bool-true
true
true
- 4 graphemes
- 4 code points
- 4 bytes
- 4 UTF-16 units
- What it breaks
- A text field holding the word true becomes a boolean somewhere in the chain and stops round-tripping.
- What a correct application does
- Returned as text, exactly as entered.
The word NaN
magic-values/word-nan
NaN
NaN
- 3 graphemes
- 3 code points
- 3 bytes
- 3 UTF-16 units
- What it breaks
- Numeric parsers accept it, and then every comparison against it is false - filters and sorting quietly drop the row.
- What a correct application does
- Rejected in a numeric field; kept verbatim in a text field.
The word Infinity
magic-values/word-infinity
Infinity
Infinity
- 8 graphemes
- 8 code points
- 8 bytes
- 8 UTF-16 units
- What it breaks
- Accepted as a number by some layers and rejected by others, so the same value validates differently at each step.
- What a correct application does
- One consistent verdict across the interface, the service layer and storage.
The word undefined
magic-values/word-undefined
undefined
undefined
- 9 graphemes
- 9 code points
- 9 bytes
- 9 UTF-16 units
- What it breaks
- Often the result of a bug elsewhere, so a real value spelled this way is indistinguishable from a defect.
- What a correct application does
- Stored and displayed as ordinary text, without special treatment.
The word yes
magic-values/bool-yes
yes
yes
- 3 graphemes
- 3 code points
- 3 bytes
- 3 UTF-16 units
- What it breaks
- The same coercion problem as the word no, in the opposite direction, and equally invisible in review.
- What a correct application does
- Returned as the three-character string.
The word off
magic-values/bool-off
off
off
- 3 graphemes
- 3 code points
- 3 bytes
- 3 UTF-16 units
- What it breaks
- Another word coerced to a boolean by common configuration parsers.
- What a correct application does
- Returned as text.
The word None
magic-values/word-none
None
None
- 4 graphemes
- 4 code points
- 4 bytes
- 4 UTF-16 units
- What it breaks
- The absent-value keyword in one widely used language; travels through interfaces as a null.
- What a correct application does
- Returned as the four-character string.
The word nil
magic-values/word-nil
nil
nil
- 3 graphemes
- 3 code points
- 3 bytes
- 3 UTF-16 units
- What it breaks
- The absent-value keyword in another; same failure, different layer.
- What a correct application does
- Returned as text.
N/A with a slash
magic-values/na-slash
N/A
N/A
- 3 graphemes
- 3 code points
- 3 bytes
- 3 UTF-16 units
- What it breaks
- Contains a separator, so it also breaks paths, CSV columns and anything splitting on a slash.
- What a correct application does
- Stored and displayed intact.
A single dash
magic-values/dash-only
-
-
- 1 grapheme
- 1 code point
- 1 byte
- 1 UTF-16 unit
- What it breaks
- A single dash is a real answer in forms and a "no value" marker in reports - the two meanings collide on export.
- What a correct application does
- Stored as a one-character value, distinguishable from an empty field.