chore: fix tests
This commit is contained in:
parent
e4b358a01e
commit
36ebccb822
6 changed files with 9 additions and 25 deletions
|
|
@ -52,6 +52,9 @@ def get : (a : @& ByteArray) → (@& Fin a.size) → UInt8
|
|||
@[inline] def getOp (self : ByteArray) (idx : Nat) : UInt8 :=
|
||||
self.get! idx
|
||||
|
||||
instance : GetElem ByteArray Nat UInt8 fun xs i => LT.lt i xs.size where
|
||||
getElem xs i h := xs.get ⟨i, h⟩
|
||||
|
||||
@[extern "lean_byte_array_set"]
|
||||
def set! : ByteArray → (@& Nat) → UInt8 → ByteArray
|
||||
| ⟨bs⟩, i, b => ⟨bs.set! i b⟩
|
||||
|
|
|
|||
|
|
@ -58,6 +58,9 @@ def get? (ds : FloatArray) (i : Nat) : Option Float :=
|
|||
@[inline] def getOp (self : FloatArray) (idx : Nat) : Float :=
|
||||
self.get! idx
|
||||
|
||||
instance : GetElem FloatArray Nat Float fun xs i => LT.lt i xs.size where
|
||||
getElem xs i h := xs.get ⟨i, h⟩
|
||||
|
||||
@[extern "lean_float_array_uset"]
|
||||
def uset : (a : FloatArray) → (i : USize) → Float → i.toNat < a.size → FloatArray
|
||||
| ⟨ds⟩, i, v, h => ⟨ds.uset i v h⟩
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
(h : Nat.succ j' < Array.size a),
|
||||
Array.insertionSort.swapLoop lt a (Nat.succ j') h =
|
||||
let_fun h' := (_ : j' < Array.size a);
|
||||
if lt (Array.getOp a { val := Nat.succ j', isLt := h }) (Array.getOp a { val := j', isLt := h' }) = true then
|
||||
if lt (getElem a (Nat.succ j') h) (getElem a j' h') = true then
|
||||
Array.insertionSort.swapLoop lt (Array.swap a { val := Nat.succ j', isLt := h } { val := j', isLt := h' }) j'
|
||||
(_ : j' < Array.size (Array.swap a { val := Nat.succ j', isLt := h } { val := j', isLt := h' }))
|
||||
else a
|
||||
|
|
|
|||
|
|
@ -366,7 +366,7 @@ def State.step : State → State
|
|||
| s@(done ..) => s
|
||||
|
||||
def Context.equiv (cₗ cᵣ : Context) : Prop :=
|
||||
∀ n, cₗ[n] = cᵣ[n]
|
||||
∀ n : String, cₗ[n] = cᵣ[n]
|
||||
|
||||
def State.stepN : State → Nat → State
|
||||
| s, 0 => s
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
def MyArray := Array
|
||||
|
||||
namespace MyArray
|
||||
|
||||
def getOp? (self : MyArray α) (idx : Nat) : Option α :=
|
||||
Array.get? self idx
|
||||
|
||||
def getOp! [Inhabited α] (self : MyArray α) (idx : Nat) : α :=
|
||||
Array.get! self idx
|
||||
|
||||
def getOp (self : MyArray α) (idx : Fin self.size) : α :=
|
||||
Array.get self idx
|
||||
|
||||
end MyArray
|
||||
|
||||
variable (a : MyArray Nat)
|
||||
|
||||
#check a[0]!
|
||||
#check a[0]?
|
||||
|
||||
variable (i : Fin a.size)
|
||||
#check a[i]
|
||||
|
|
@ -26,7 +26,7 @@ def tst3 (n : Nat) (expected : UInt32) : IO Unit := do
|
|||
let bs := mkByteArray n
|
||||
let mut sum := 0
|
||||
for i in [:bs.size] do
|
||||
sum := sum + bs[i].toUInt32
|
||||
sum := sum + bs[i]!.toUInt32
|
||||
assert! sum == expected
|
||||
IO.println sum
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue