diff --git a/tests/coq/misc/Issue194RecursiveStructProjector.v b/tests/coq/misc/Issue194RecursiveStructProjector.v new file mode 100644 index 000000000..d1a074491 --- /dev/null +++ b/tests/coq/misc/Issue194RecursiveStructProjector.v @@ -0,0 +1,54 @@ +(** THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS *) +(** [issue_194_recursive_struct_projector] *) +Require Import Primitives. +Import Primitives. +Require Import Coq.ZArith.ZArith. +Require Import List. +Import ListNotations. +Local Open Scope Primitives_scope. +Module Issue194RecursiveStructProjector. + +(** [issue_194_recursive_struct_projector::AVLNode] + Source: 'tests/src/issue-194-recursive-struct-projector.rs', lines 2:0-2:17 *) +Inductive AVLNode_t (T : Type) := +| mkAVLNode_t : + T -> + option (AVLNode_t T) -> + option (AVLNode_t T) -> + AVLNode_t T +. + +Arguments mkAVLNode_t { _ }. + +Definition aVLNode_value {T : Type} (x : AVLNode_t T) := + match x with | mkAVLNode_t x1 _ _ => x1 end +. + +Notation "x2 .(aVLNode_value)" := (aVLNode_value x2) (at level 9). + +Definition aVLNode_left {T : Type} (x : AVLNode_t T) := + match x with | mkAVLNode_t _ x1 _ => x1 end +. + +Notation "x2 .(aVLNode_left)" := (aVLNode_left x2) (at level 9). + +Definition aVLNode_right {T : Type} (x : AVLNode_t T) := + match x with | mkAVLNode_t _ _ x1 => x1 end +. + +Notation "x2 .(aVLNode_right)" := (aVLNode_right x2) (at level 9). + +(** [issue_194_recursive_struct_projector::get_val]: + Source: 'tests/src/issue-194-recursive-struct-projector.rs', lines 10:0-10:33 *) +Definition get_val (T : Type) (x : AVLNode_t T) : result T := + Ok x.(aVLNode_value) +. + +(** [issue_194_recursive_struct_projector::get_left]: + Source: 'tests/src/issue-194-recursive-struct-projector.rs', lines 14:0-14:43 *) +Definition get_left + (T : Type) (x : AVLNode_t T) : result (option (AVLNode_t T)) := + Ok x.(aVLNode_left) +. + +End Issue194RecursiveStructProjector. diff --git a/tests/fstar/misc/Issue194RecursiveStructProjector.fst b/tests/fstar/misc/Issue194RecursiveStructProjector.fst new file mode 100644 index 000000000..76368f04c --- /dev/null +++ b/tests/fstar/misc/Issue194RecursiveStructProjector.fst @@ -0,0 +1,24 @@ +(** THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS *) +(** [issue_194_recursive_struct_projector] *) +module Issue194RecursiveStructProjector +open Primitives + +#set-options "--z3rlimit 50 --fuel 1 --ifuel 1" + +(** [issue_194_recursive_struct_projector::AVLNode] + Source: 'tests/src/issue-194-recursive-struct-projector.rs', lines 2:0-2:17 *) +type aVLNode_t (t : Type0) = +{ + value : t; left : option (aVLNode_t t); right : option (aVLNode_t t); +} + +(** [issue_194_recursive_struct_projector::get_val]: + Source: 'tests/src/issue-194-recursive-struct-projector.rs', lines 10:0-10:33 *) +let get_val (t : Type0) (x : aVLNode_t t) : result t = + Ok x.value + +(** [issue_194_recursive_struct_projector::get_left]: + Source: 'tests/src/issue-194-recursive-struct-projector.rs', lines 14:0-14:43 *) +let get_left (t : Type0) (x : aVLNode_t t) : result (option (aVLNode_t t)) = + Ok x.left + diff --git a/tests/fstar/misc/Matches.fst b/tests/fstar/misc/Matches.fst new file mode 100644 index 000000000..06a9b6dfe --- /dev/null +++ b/tests/fstar/misc/Matches.fst @@ -0,0 +1,12 @@ +(** THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS *) +(** [matches] *) +module Matches +open Primitives + +#set-options "--z3rlimit 50 --fuel 1 --ifuel 1" + +(** [matches::match_u32]: + Source: 'tests/src/matches.rs', lines 4:0-4:27 *) +let match_u32 (x : u32) : result u32 = + begin match x with | 0 -> Ok 0 | 1 -> Ok 1 | _ -> Ok 2 end + diff --git a/tests/lean/InfiniteLoop.lean b/tests/lean/InfiniteLoop.lean new file mode 100644 index 000000000..47c6b842d --- /dev/null +++ b/tests/lean/InfiniteLoop.lean @@ -0,0 +1,25 @@ +-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS +-- [infinite_loop] +import Base +open Primitives + +namespace infinite_loop + +/- [infinite_loop::bar]: + Source: 'tests/src/infinite-loop.rs', lines 4:0-4:8 -/ +def bar : Result Unit := + Result.ok () + +/- [infinite_loop::foo]: loop 0: + Source: 'tests/src/infinite-loop.rs', lines 6:0-10:1 -/ +divergent def foo_loop : Unit := + do + let _ ← bar + foo_loop + +/- [infinite_loop::foo]: + Source: 'tests/src/infinite-loop.rs', lines 6:0-6:8 -/ +def foo : Result Unit := + foo_loop + +end infinite_loop diff --git a/tests/lean/Issue194RecursiveStructProjector.lean b/tests/lean/Issue194RecursiveStructProjector.lean new file mode 100644 index 000000000..4eb23934b --- /dev/null +++ b/tests/lean/Issue194RecursiveStructProjector.lean @@ -0,0 +1,35 @@ +-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS +-- [issue_194_recursive_struct_projector] +import Base +open Primitives + +namespace issue_194_recursive_struct_projector + +/- [issue_194_recursive_struct_projector::AVLNode] + Source: 'tests/src/issue-194-recursive-struct-projector.rs', lines 2:0-2:17 -/ +inductive AVLNode (T : Type) := +| mk : T → Option (AVLNode T) → Option (AVLNode T) → AVLNode T + +@[simp, reducible] +def AVLNode.value {T : Type} (x : AVLNode T) := + match x with | AVLNode.mk x1 _ _ => x1 + +@[simp, reducible] +def AVLNode.left {T : Type} (x : AVLNode T) := + match x with | AVLNode.mk _ x1 _ => x1 + +@[simp, reducible] +def AVLNode.right {T : Type} (x : AVLNode T) := + match x with | AVLNode.mk _ _ x1 => x1 + +/- [issue_194_recursive_struct_projector::get_val]: + Source: 'tests/src/issue-194-recursive-struct-projector.rs', lines 10:0-10:33 -/ +def get_val (T : Type) (x : AVLNode T) : Result T := + Result.ok x.value + +/- [issue_194_recursive_struct_projector::get_left]: + Source: 'tests/src/issue-194-recursive-struct-projector.rs', lines 14:0-14:43 -/ +def get_left (T : Type) (x : AVLNode T) : Result (Option (AVLNode T)) := + Result.ok x.left + +end issue_194_recursive_struct_projector diff --git a/tests/lean/Matches.lean b/tests/lean/Matches.lean new file mode 100644 index 000000000..3e3a558bf --- /dev/null +++ b/tests/lean/Matches.lean @@ -0,0 +1,16 @@ +-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS +-- [matches] +import Base +open Primitives + +namespace matches + +/- [matches::match_u32]: + Source: 'tests/src/matches.rs', lines 4:0-4:27 -/ +def match_u32 (x : U32) : Result U32 := + match x with + | 0#u32 => Result.ok 0#u32 + | 1#u32 => Result.ok 1#u32 + | _ => Result.ok 2#u32 + +end matches diff --git a/tests/src/infinite-loop.rs b/tests/src/infinite-loop.rs new file mode 100644 index 000000000..a56bc8b8c --- /dev/null +++ b/tests/src/infinite-loop.rs @@ -0,0 +1,10 @@ +//@ [coq,fstar] skip +//@ [coq,fstar] subdir=misc +//^note: this fails on the fstar and coq backends +fn bar() {} + +fn foo() { + loop { + bar() + } +} diff --git a/tests/src/issue-194-recursive-struct-projector.rs b/tests/src/issue-194-recursive-struct-projector.rs new file mode 100644 index 000000000..9ebdc2bc8 --- /dev/null +++ b/tests/src/issue-194-recursive-struct-projector.rs @@ -0,0 +1,16 @@ +//@ [coq,fstar] subdir=misc +struct AVLNode { + value: T, + left: AVLTree, + right: AVLTree, +} + +type AVLTree = Option>>; + +fn get_val(x: AVLNode) -> T { + x.value +} + +fn get_left(x: AVLNode) -> AVLTree { + x.left +} diff --git a/tests/src/matches.rs b/tests/src/matches.rs new file mode 100644 index 000000000..5710a6043 --- /dev/null +++ b/tests/src/matches.rs @@ -0,0 +1,10 @@ +//@ [coq] skip +//@ [coq,fstar] subdir=misc +//^ note: coq gives "invalid notation for pattern" +fn match_u32(x: u32) -> u32 { + match x { + 0 => 0, + 1 => 1, + _ => 2, + } +}