Skip to content

Commit c0071d7

Browse files
committed
tests
1 parent d70cfae commit c0071d7

File tree

9 files changed

+19
-19
lines changed

9 files changed

+19
-19
lines changed

tests/bench/liasolver.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ namespace Std.HashMap
6464
return false
6565

6666
def mapValsM [Monad m] (f : β → m γ) (xs : HashMap α β) : m (HashMap α γ) :=
67-
HashMap.empty (capacity := xs.size) |> xs.foldM fun acc k v => return acc.insert k (←f v)
67+
HashMap.emptyWithCapacity (capacity := xs.size) |> xs.foldM fun acc k v => return acc.insert k (←f v)
6868

6969
def mapVals (f : β → γ) (xs : HashMap α β) : HashMap α γ :=
70-
HashMap.empty (capacity := xs.size) |> xs.fold fun acc k v => acc.insert k (f v)
70+
HashMap.emptyWithCapacity (capacity := xs.size) |> xs.fold fun acc k v => acc.insert k (f v)
7171

7272
def fastMapVals (f : α → β → β) (xs : HashMap α β) : HashMap α β :=
7373
xs.map f
@@ -275,7 +275,7 @@ partial def readSolution? (p : Problem) : Option Solution := Id.run <| do
275275
return none
276276
if p.equations.any (fun _ eq => eq.const ≠ 0) then
277277
return some Solution.unsat
278-
let mut assignment : Array (Option Int) := mkArray p.nVars none
278+
let mut assignment : Array (Option Int) := Array.replicate p.nVars none
279279
for i in *...p.nVars do
280280
assignment := readSolution i assignment
281281
return Solution.sat <| assignment.map (·.get!)

tests/lean/match4.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ match x with
4444
def Vector' (α : Type) (n : Nat) := { a : Array α // a.size = n }
4545

4646
def mkVec {α : Type} (n : Nat) (a : α) : Vector' α n :=
47-
mkArray n a, Array.size_mkArray ..⟩
47+
Array.replicate n a, Array.size_replicate ..⟩
4848

4949
structure S :=
5050
(n : Nat)

tests/lean/repr_issue.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ foo
1313

1414
-- The following examples were producing an element of Type `id (Except String Nat)`.
1515
-- Type class resolution was failing to produce an instance for `Repr (id (Except String Nat))` because `id` is not transparent.
16-
#eval ex₁.run' (mkArray 10 1000) |>.run
17-
#eval ex₂.run' (mkArray 10 1000) |>.run
16+
#eval ex₁.run' (Array.replicate 10 1000) |>.run
17+
#eval ex₂.run' (Array.replicate 10 1000) |>.run

tests/lean/run/addDecorationsWithoutPartial.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ unsafe def replaceUnsafeM (size : USize) (e : Expr) (f? : (e' : Expr) → sizeOf
3939
private def notAnExpr : Unit × Unit := ⟨⟨⟩, ⟨⟩⟩
4040

4141
unsafe def initCache : State :=
42-
{ keys := mkArray cacheSize.toNat (cast lcProof notAnExpr), -- `notAnExpr` is not a valid `Expr`
43-
results := mkArray cacheSize.toNat default }
42+
{ keys := Array.replicate cacheSize.toNat (cast lcProof notAnExpr), -- `notAnExpr` is not a valid `Expr`
43+
results := Array.replicate cacheSize.toNat default }
4444

4545
unsafe def replaceUnsafe (e : Expr) (f? : (e' : Expr) → sizeOf e' ≤ sizeOf e → Option Expr) : Expr :=
4646
(replaceUnsafeM cacheSize e f?).run' initCache

tests/lean/run/array1.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def v : Array Nat := Array.mk [1, 2, 3, 4]
55
#guard v == #[1, 2, 3, 4, ]
66

77
def w : Array Nat :=
8-
(mkArray 9 1).push 3
8+
(Array.replicate 9 1).push 3
99

1010
#check @Array.casesOn
1111

@@ -15,17 +15,17 @@ def f : Fin w.size → Nat :=
1515
def arraySum (a : Array Nat) : Nat :=
1616
a.foldl Nat.add 0
1717

18-
#guard mkArray 4 1 == #[1, 1, 1, 1]
18+
#guard Array.replicate 4 1 == #[1, 1, 1, 1]
1919

2020
#guard Array.map (fun x => x+10) v == #[11, 12, 13, 14]
2121

2222
#guard f ⟨1, sorry⟩ == 1
2323

2424
#guard f ⟨9, sorry⟩ == 3
2525

26-
#guard (((mkArray 1 1).push 2).push 3).foldl (fun x y => x + y) 0 == 6
26+
#guard (((Array.replicate 1 1).push 2).push 3).foldl (fun x y => x + y) 0 == 6
2727

28-
#guard arraySum (mkArray 10 1) == 10
28+
#guard arraySum (Array.replicate 10 1) == 10
2929

3030
axiom axLt {a b : Nat} : a < b
3131

tests/lean/run/depElim1.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def mkTester (elimName : Name) (majors : List Expr) (lhss : List AltLHS) (inProp
154154
generalizeTelescope majors.toArray fun majors => do
155155
let resultType := if inProp then mkConst `True /- some proposition -/ else mkConst `Nat
156156
let matchType ← mkForallFVars majors resultType
157-
Match.mkMatcher { matcherName := elimName, matchType, discrInfos := mkArray majors.size {}, lhss }
157+
Match.mkMatcher { matcherName := elimName, matchType, discrInfos := Array.replicate majors.size {}, lhss }
158158

159159
def test (ex : Name) (numPats : Nat) (elimName : Name) (inProp : Bool := false) : MetaM Unit :=
160160
withDepElimFrom ex numPats fun majors alts => do

tests/lean/run/maze.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,13 @@ def delabGameState : Lean.Expr → Lean.PrettyPrinter.Delaborator.Delab
144144
try extractGameState e
145145
catch err => failure -- can happen if game state has variables in it
146146

147-
let topBar := Array.mkArray numCols $ ← `(horizontal_border| ─)
147+
let topBar := Array.replicate numCols $ ← `(horizontal_border| ─)
148148
let emptyCell ← `(game_cell| ░)
149-
let emptyRow := Array.mkArray numCols emptyCell
149+
let emptyRow := Array.replicate numCols emptyCell
150150
let emptyRowStx ← `(game_row| │$emptyRow:game_cell*│)
151-
let allRows := Array.mkArray numRows emptyRowStx
151+
let allRows := Array.replicate numRows emptyRowStx
152152

153-
let a0 := Array.mkArray numRows $ Array.mkArray numCols emptyCell
153+
let a0 := Array.replicate numRows $ Array.replicate numCols emptyCell
154154
let a1 := update2dArray a0 playerCoords $ ← `(game_cell| @)
155155
let a2 := update2dArrayMulti a1 walls $ ← `(game_cell| ▓)
156156
let aa ← Array.mapM delabGameRow a2

tests/lean/run/unifhint2.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ unif_hint natAddStep (x y z w : Nat) where
1313
def BV (n : Nat) := { a : Array Bool // a.size = n }
1414

1515
def sext (x : BV s) (n : Nat) : BV (s+n) :=
16-
mkArray (s+n) false, Array.size_mkArray ..⟩
16+
Array.replicate (s+n) false, Array.size_replicate ..⟩
1717

1818
def bvmul (x y : BV w) : BV w := x
1919

tests/lean/run/unihint.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ set_option pp.all true
3232
def BV (n : Nat) := { a : Array Bool // a.size = n }
3333

3434
def sext (x : BV s) (n : Nat) : BV (s+n) :=
35-
mkArray (s+n) false, Array.size_mkArray ..⟩
35+
Array.replicate (s+n) false, Array.size_replicate ..⟩
3636

3737
def bvmul (x y : BV w) : BV w :=
3838
x

0 commit comments

Comments
 (0)