Skip to content

Commit 29e3219

Browse files
authored
Merge pull request #574 from FStarLang/nik_testcase_for_extraction_with_interfaces
Test: Regression test for Pulse fn extraction with .fsti interface
2 parents 1f1c90c + 09b73ec commit 29e3219

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* krml header omitted for test repeatability */
2+
3+
4+
#include "ExtractPulseFnIface.h"
5+
6+
extern krml_checked_int_t Prims_op_Addition(krml_checked_int_t x, krml_checked_int_t y);
7+
8+
krml_checked_int_t ExtractPulseFnIface_pure_add(krml_checked_int_t x, krml_checked_int_t y)
9+
{
10+
return Prims_op_Addition(x, y);
11+
}
12+
13+
krml_checked_int_t ExtractPulseFnIface_pulse_read_ref(krml_checked_int_t *r)
14+
{
15+
return *r;
16+
}
17+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module ExtractPulseFnIface
2+
#lang-pulse
3+
4+
open Pulse.Lib.Pervasives
5+
open Pulse.Lib.Reference
6+
module R = Pulse.Lib.Reference
7+
8+
let pure_add (x y : int) : int = x + y
9+
10+
fn pulse_read_ref
11+
(r: ref int)
12+
(#v: Ghost.erased int)
13+
requires R.pts_to r v
14+
returns x: int
15+
ensures R.pts_to r v ** pure (x == Ghost.reveal v)
16+
{
17+
let x = !r;
18+
x
19+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module ExtractPulseFnIface
2+
#lang-pulse
3+
4+
(** Interface for ExtractPulseFnIface.
5+
Tests that a Pulse fn declared in .fsti extracts to C correctly.
6+
Regression test: previously, fn declarations in .fsti were not
7+
recognized by the interleaver, causing the implementation to be
8+
tagged KrmlPrivate and silently dropped by KaRaMeL. *)
9+
10+
open Pulse.Lib.Pervasives
11+
open Pulse.Lib.Reference
12+
module R = Pulse.Lib.Reference
13+
14+
val pure_add (x y : int) : int
15+
16+
fn pulse_read_ref
17+
(r: ref int)
18+
(#v: Ghost.erased int)
19+
requires R.pts_to r v
20+
returns x: int
21+
ensures R.pts_to r v ** pure (x == Ghost.reveal v)

0 commit comments

Comments
 (0)