Many of our tests in `tests/lean/run/` produce output from `#eval` (or `#check`) statements, that is then ignored. This PR tries to capture all the useful output using `#guard_msgs`. I've only done a cursory check that the output is still sane --- there is a chance that some "unchecked" tests have already accumulated regressions and this just cements them! In the other direction, I did identify two rotten tests: * a minor one in `setStructInstNotation.lean`, where a comment says `Set Nat`, but `#check` actually prints `?_`. Weird? * `CompilerProbe.lean` is generating empty output, apparently indicating that something is broken, but I don't know the signficance of this file. In any case, I'll ask about these elsewhere. (This started by noticing that a recent `grind` test file had an untested `trace_state`, and then got carried away.)
52 lines
1.1 KiB
Text
52 lines
1.1 KiB
Text
@[default_instance]
|
||
instance [Mul α] : HMul α (Array α) (Array α) where
|
||
hMul a as := as.map (a * ·)
|
||
|
||
instance [Mul α] : Mul (Array α) where
|
||
mul as bs := (as.zip bs).map fun (a, b) => a * b
|
||
|
||
#guard 2 * #[3, 4, 5] == #[6, 8, 10]
|
||
|
||
#guard (2:Nat) * #[3, 4, 5] == #[6, 8, 10]
|
||
|
||
#check fun x => x * 2
|
||
#check fun y : Int => let x := 1; x * y
|
||
#check fun y : Int => let_delayed x := 1; x * y
|
||
|
||
def f1 (n : Nat) (i : Int) :=
|
||
i * n
|
||
|
||
def f2 (n : Nat) (i : Int) :=
|
||
n * i
|
||
|
||
def f3 (n : Nat) (i : Int) :=
|
||
n * (n * (n * (n * i)))
|
||
|
||
def f4 (n : Nat) (i : Int) :=
|
||
n + (n + (n * (n * i)))
|
||
|
||
def f5 (n : Nat) (i : Int) :=
|
||
n + (n + (n * (i, i).1))
|
||
|
||
def f6 (n : Nat) (i : Int) :=
|
||
let y := 2 * i
|
||
let x := y * n
|
||
n + x
|
||
|
||
def f7 (n : Nat) (i : Int) :=
|
||
n + (n * 2 * i)
|
||
|
||
def f8 (n : Nat) (i : Int) :=
|
||
n * 2 + (i * 1 * n * 2 * i)
|
||
|
||
def f9 [Mul α] (a : α) (as bs : Array α) : Array α :=
|
||
a * as * bs
|
||
|
||
def f10 (a : Int) (as bs : Array Int) : Array Int :=
|
||
2 * a * as * bs
|
||
|
||
def f11 (a : Int) (as bs : Array Int) : Array Int :=
|
||
3 * a * as * (2 * bs)
|
||
|
||
def f12 [Mul α] (as bs : Array α) : Array α :=
|
||
as.foldl (init := bs) fun bs a => a * bs
|