test: Add binder capturing test

This commit is contained in:
Leni Aniva 2024-12-22 08:47:38 +09:00
parent 48b924fae2
commit 5a05e9e8d4
Signed by: aniva
GPG Key ID: 4D9B1C8D10EA4C50
1 changed files with 10 additions and 0 deletions

View File

@ -193,6 +193,15 @@ def mystery (k: Nat) : Nat := true
} }
] ]
def test_capture_type_mismatch_in_binder : TestT MetaM Unit := do
let input := "
example (p: Prop) (h: (∀ (x: Prop), Nat) → p): p := h (λ (y: Nat) => 5)
"
let goalStates ← (collectSorrysFromSource input).run' {}
let [goalState] := goalStates | panic! s!"Incorrect number of states: {goalStates.length}"
checkEq "goals" ((← goalState.serializeGoals (options := {})).map (·.devolatilize)) #[
]
def collectNewConstants (source: String) : MetaM (List (List Name)) := do def collectNewConstants (source: String) : MetaM (List (List Name)) := do
let filename := "<anonymous>" let filename := "<anonymous>"
let (context, state) ← do Frontend.createContextStateFromFile source filename (← getEnv) {} let (context, state) ← do Frontend.createContextStateFromFile source filename (← getEnv) {}
@ -227,6 +236,7 @@ def suite (env : Environment): List (String × IO LSpec.TestSeq) :=
("sorry_in_coupled", test_sorry_in_coupled), ("sorry_in_coupled", test_sorry_in_coupled),
("environment_capture", test_environment_capture), ("environment_capture", test_environment_capture),
("capture_type_mismatch", test_capture_type_mismatch), ("capture_type_mismatch", test_capture_type_mismatch),
("capture_type_mismatch_in_binder", test_capture_type_mismatch_in_binder),
("collect_one_constant", test_collect_one_constant), ("collect_one_constant", test_collect_one_constant),
("collect_one_theorem", test_collect_one_theorem), ("collect_one_theorem", test_collect_one_theorem),
] ]