Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 149 additions & 0 deletions tests/base/nat_native_model.bend
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# Nat's ops and U32.to_nat run as native C and JS (comp.ts
# OPERATIONS), not as Base's defs.
# model proves by {==} that the calls equal these values in Base's defs,
# so --verdict pins the model; main prints the same calls, so every lane
# must print what the model computes. The values are each lane's answers.
import Base

def calls() -> List<Nat>:
[
Nat.add(0n, 0n),
Nat.add(0n, 7n),
Nat.add(7n, 0n),
Nat.add(3n, 10n),
Nat.add(10n, 3n),
Nat.add(31n, 64n),
Nat.add(100n, 7n),
Nat.add(64n, 64n),
Nat.sub(0n, 0n),
Nat.sub(0n, 7n),
Nat.sub(7n, 0n),
Nat.sub(3n, 10n),
Nat.sub(10n, 3n),
Nat.sub(31n, 64n),
Nat.sub(100n, 7n),
Nat.sub(64n, 64n),
Nat.mul(0n, 0n),
Nat.mul(0n, 7n),
Nat.mul(7n, 0n),
Nat.mul(3n, 10n),
Nat.mul(10n, 3n),
Nat.mul(31n, 64n),
Nat.mul(100n, 7n),
Nat.mul(64n, 64n),
Nat.div(0n, 0n),
Nat.div(0n, 7n),
Nat.div(7n, 0n),
Nat.div(3n, 10n),
Nat.div(10n, 3n),
Nat.div(31n, 64n),
Nat.div(100n, 7n),
Nat.div(64n, 64n),
Nat.mod(0n, 0n),
Nat.mod(0n, 7n),
Nat.mod(7n, 0n),
Nat.mod(3n, 10n),
Nat.mod(10n, 3n),
Nat.mod(31n, 64n),
Nat.mod(100n, 7n),
Nat.mod(64n, 64n),
Nat.min(0n, 0n),
Nat.min(0n, 7n),
Nat.min(7n, 0n),
Nat.min(3n, 10n),
Nat.min(10n, 3n),
Nat.min(31n, 64n),
Nat.min(100n, 7n),
Nat.min(64n, 64n),
Nat.max(0n, 0n),
Nat.max(0n, 7n),
Nat.max(7n, 0n),
Nat.max(3n, 10n),
Nat.max(10n, 3n),
Nat.max(31n, 64n),
Nat.max(100n, 7n),
Nat.max(64n, 64n),
Nat.double(0n),
Nat.double(7n),
Nat.double(100n),
Nat.pow(0n, 0n),
Nat.pow(2n, 5n),
Nat.pow(3n, 3n),
U32.to_nat(0),
U32.to_nat(255),
U32.to_nat(1000)
]

def model() -> {calls() == [
0n,
7n,
7n,
13n,
13n,
95n,
107n,
128n,
0n,
0n,
7n,
0n,
7n,
0n,
93n,
0n,
0n,
0n,
0n,
30n,
30n,
1984n,
700n,
4096n,
0n,
0n,
0n,
0n,
3n,
0n,
14n,
1n,
0n,
0n,
7n,
3n,
1n,
31n,
2n,
0n,
0n,
0n,
0n,
3n,
3n,
31n,
7n,
64n,
0n,
7n,
7n,
10n,
10n,
64n,
100n,
64n,
0n,
14n,
200n,
1n,
32n,
27n,
0n,
255n,
1000n
] : List<Nat>}:
{==}

def main() -> List<Nat>:
calls()

#|[0n, 7n, 7n, 13n, 13n, 95n, 107n, 128n, 0n, 0n, 7n, 0n, 7n, 0n, 93n, 0n, 0n, 0n, 0n, 30n, 30n, 1984n, 700n, 4096n, 0n, 0n, 0n, 0n, 3n, 0n, 14n, 1n, 0n, 0n, 7n, 3n, 1n, 31n, 2n, 0n, 0n, 0n, 0n, 3n, 3n, 31n, 7n, 64n, 0n, 7n, 7n, 10n, 10n, 64n, 100n, 64n, 0n, 14n, 200n, 1n, 32n, 27n, 0n, 255n, 1000n]
99 changes: 99 additions & 0 deletions tests/base/u32_native_compare.bend
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# U32's comparisons run as native C and JS (comp.ts OPERATIONS),
# not as Base's defs.
# model proves by {==} that the calls equal these values in Base's defs,
# so --verdict pins the model; main prints the same calls, so every lane
# must print what the model computes. The values are each lane's answers.
import Base

def calls() -> List<Bool>:
[
U32.is_eq(0, 0),
U32.is_eq(0, 4294967295),
U32.is_eq(4294967295, 0),
U32.is_eq(2147483648, 2147483647),
U32.is_eq(2147483647, 2147483648),
U32.is_eq(4294967295, 4294967295),
U32.is_ne(0, 0),
U32.is_ne(0, 4294967295),
U32.is_ne(4294967295, 0),
U32.is_ne(2147483648, 2147483647),
U32.is_ne(2147483647, 2147483648),
U32.is_ne(4294967295, 4294967295),
U32.is_lt(0, 0),
U32.is_lt(0, 4294967295),
U32.is_lt(4294967295, 0),
U32.is_lt(2147483648, 2147483647),
U32.is_lt(2147483647, 2147483648),
U32.is_lt(4294967295, 4294967295),
U32.is_le(0, 0),
U32.is_le(0, 4294967295),
U32.is_le(4294967295, 0),
U32.is_le(2147483648, 2147483647),
U32.is_le(2147483647, 2147483648),
U32.is_le(4294967295, 4294967295),
U32.is_gt(0, 0),
U32.is_gt(0, 4294967295),
U32.is_gt(4294967295, 0),
U32.is_gt(2147483648, 2147483647),
U32.is_gt(2147483647, 2147483648),
U32.is_gt(4294967295, 4294967295),
U32.is_ge(0, 0),
U32.is_ge(0, 4294967295),
U32.is_ge(4294967295, 0),
U32.is_ge(2147483648, 2147483647),
U32.is_ge(2147483647, 2147483648),
U32.is_ge(4294967295, 4294967295),
U32.is_zero(0),
U32.is_zero(1),
U32.is_zero(2147483648),
U32.is_zero(4294967295)
]

def model() -> {calls() == [
True{},
False{},
False{},
False{},
False{},
True{},
False{},
True{},
True{},
True{},
True{},
False{},
False{},
True{},
False{},
False{},
True{},
False{},
True{},
True{},
False{},
False{},
True{},
True{},
False{},
False{},
True{},
True{},
False{},
False{},
True{},
False{},
True{},
True{},
False{},
True{},
True{},
False{},
False{},
False{}
] : List<Bool>}:
{==}

def main() -> List<Bool>:
calls()

#|[True{}, False{}, False{}, False{}, False{}, True{}, False{}, True{}, True{}, True{}, True{}, False{}, False{}, True{}, False{}, False{}, True{}, False{}, True{}, True{}, False{}, False{}, True{}, True{}, False{}, False{}, True{}, True{}, False{}, False{}, True{}, False{}, True{}, True{}, False{}, True{}, True{}, False{}, False{}, False{}]
Loading