This adds a `test_extern` command. Usage: ``` import Lean.Util.TestExtern test_extern Nat.add 17 37 ``` This: * Checks that the head symbol has an `@[extern]` attribute. * Writes down `t == t'`, where `t` is the term provided, and `t'` is the reference implementation (specifically, `t` with the head symbol unfolded). * Tries to reduce this to `true`, and complains if this fails. Note that the type of the term must have a `BEq` instance for this to work: there's a self-explanatory error message if it isn't available.
9 lines
231 B
Text
9 lines
231 B
Text
import Lean.Util.TestExtern
|
|
|
|
instance : BEq ByteArray where
|
|
beq x y := x.data == y.data
|
|
|
|
test_extern Nat.add 12 37
|
|
test_extern 4 + 5
|
|
|
|
test_extern ByteArray.copySlice ⟨#[1,2,3]⟩ 1 ⟨#[4, 5, 6, 7, 8, 9, 10, 11, 12, 13]⟩ 0 6
|