Skip to content

Value Types

scaf supports several value types for inputs, expected outputs, and assertions.

Double or single quotes:

name: "Alice"
status: 'active'
message: "Hello, World!"
path: '/usr/local/bin'
// In quoted strings
escaped: "Line 1\nLine 2"
tab: "Column1\tColumn2"
quote: "She said \"Hello\""
backslash: "C:\\path\\to\\file"
EscapeCharacter
\"Double quote
\'Single quote
\\Backslash
\nNewline
\tTab
\rCarriage return

Backtick-delimited, no escape processing:

fn Example `
SELECT * FROM users
WHERE name = 'Alice'
`

Raw strings preserve all content literally, including newlines and special characters.

count: 42
negative: -17
zero: 0
price: 19.99
rate: 0.05
negative: -3.14
// Hexadecimal
hex: 0xFF
hex2: 0x1a2b3c
// Binary
binary: 0b1010
bits: 0b11110000
// Octal
octal: 0o755
permissions: 0o644
large: 1e10
small: 1.5e-5
precise: 6.022e23

Underscores improve readability:

million: 1_000_000
binary: 0b1111_0000_1111_0000
hex: 0xFF_FF_FF
verified: true
deleted: false

Case-sensitive — True, TRUE, FALSE are invalid.

deletedAt: null
optionalField: null

Use null to assert that a field is null/missing.

Ordered collections:

// Empty list
empty: []
// Simple values
numbers: [1, 2, 3, 4, 5]
strings: ["a", "b", "c"]
mixed: [1, "two", true, null]
// Nested lists
matrix: [[1, 2], [3, 4], [5, 6]]
// Trailing comma allowed
items: [
"first",
"second",
"third",
]
assert {
(len(items) > 0)
(items[0] == "first")
("admin" in roles)
}

Key-value objects:

// Empty map
empty: {}
// Simple map
user: {name: "Alice", age: 30}
// Nested maps
config: {
database: {
host: "localhost",
port: 5432
},
cache: {
enabled: true,
ttl: 3600
}
}
// Trailing comma allowed
options: {
key1: "value1",
key2: "value2",
}

Keys must be valid identifiers (no quotes):

// Valid
data: {name: "Alice", userId: 1}
// Invalid - no quoted keys
data: {"user-name": "Alice"} // Error!
assert {
(user.name == "Alice")
(user.profile.theme == "dark")
(config["timeout"] > 0)
}

scaf compares values with type awareness:

ExpectedActualResult
1 (int)1.0 (float)Match ✓
"1" (string)1 (number)No match ✗
true1No match ✗
nullmissing fieldMatch ✓
[][]Match ✓
[1, 2][2, 1]No match ✗ (order matters)

Complex nested data:

test "complex data" {
$input: {
users: [
{id: 1, name: "Alice", roles: ["admin", "user"]},
{id: 2, name: "Bob", roles: ["user"]}
],
config: {
features: {
beta: true,
legacy: false
}
}
}
result.users[0].name: "Alice"
result.users[0].roles: ["admin", "user"]
result.config.features.beta: true
}

How database types map to scaf types:

Neo4j Typescaf Type
Stringstring
Integernumber
Floatnumber
Booleanboolean
Nullnull
Listlist
Mapmap
Nodemap (properties)
Relationshipmap (properties)
Datestring (ISO format)
DateTimestring (ISO format)
Durationstring
SQL Typescaf Type
VARCHAR, TEXTstring
INT, BIGINTnumber
FLOAT, DECIMALnumber
BOOLEANboolean
NULLnull
ARRAYlist
JSON, JSONBmap
DATEstring (ISO format)
TIMESTAMPstring (ISO format)