Skip to content

Commit 93ea357

Browse files
committed
create main, top-level tests
1 parent 1df4b0f commit 93ea357

13 files changed

+42
-30
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ rustc_private=true
1010

1111
[dev-dependencies]
1212
pretty_assertions = "1.3.0"
13+
expect-test = "1.4.0"
1314

1415
[dependencies]
1516
anyhow = "1"

crates/formality-check/src/lib.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,13 @@ pub fn check_all_crates(program: &Program) -> Fallible<()> {
2929
}
3030

3131
/// Checks the current crate in the program, assuming all other crates are valid.
32-
fn check_current_crate(_program: &Program) -> Fallible<()> {
33-
todo!()
32+
fn check_current_crate(program: &Program) -> Fallible<()> {
33+
let decls = program.to_prove_decls();
34+
Check {
35+
program,
36+
decls: &decls,
37+
}
38+
.check()
3439
}
3540

3641
mod adts;
@@ -100,6 +105,6 @@ impl Check<'_> {
100105
return Ok(());
101106
}
102107

103-
bail!("failed to prove {goal:?} from {assumptions:?}, got {cs:?}")
108+
bail!("failed to prove {goal:?} given {assumptions:?}, got {cs:?}")
104109
}
105110
}

src/lib.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
use clap::Parser;
2+
use formality_check::check_all_crates;
3+
use formality_rust::grammar::Program;
4+
use formality_types::parse::term;
5+
6+
#[derive(Parser, Debug)]
7+
#[command(author, version, about, long_about = None)]
8+
struct Args {
9+
#[arg(long)]
10+
print_rust: bool,
11+
12+
input_path: String,
13+
}
14+
15+
pub fn main() -> anyhow::Result<()> {
16+
let args = Args::parse();
17+
let input: String = std::fs::read_to_string(&args.input_path)?;
18+
let program: Program = term(&input);
19+
20+
if args.print_rust {
21+
eprintln!("{:#?}", program);
22+
}
23+
24+
check_all_crates(&program)
25+
}
26+
27+
pub fn test_program_ok(input: &str) -> anyhow::Result<()> {
28+
let program: Program = term(&input);
29+
check_all_crates(&program)
30+
}

src/main.rs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,3 @@
1-
use clap::Parser;
2-
use formality_check::check_all_crates;
3-
use formality_rust::grammar::Program;
4-
use formality_types::parse::term;
5-
6-
#[derive(Parser, Debug)]
7-
#[command(author, version, about, long_about = None)]
8-
struct Args {
9-
#[arg(long)]
10-
print_rust: bool,
11-
12-
input_path: String,
13-
}
14-
151
fn main() -> anyhow::Result<()> {
16-
let args = Args::parse();
17-
let input: String = std::fs::read_to_string(&args.input_path)?;
18-
let program: Program = term(&input);
19-
20-
if args.print_rust {
21-
eprintln!("{:#?}", program);
22-
}
23-
24-
check_all_crates(&program)
2+
formality::main()
253
}

crates/formality-rust/tests/basic--hello_world.rs renamed to tests/basic--hello_world.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#![allow(non_snake_case)]
2-
#![cfg(FIXME)]
32

4-
use formality_rust::test_program_ok;
3+
use formality::test_program_ok;
54

65
const PROGRAM_BROKEN: &str = "[
76
crate Foo {
@@ -24,7 +23,6 @@ const PROGRAM_OK: &str = "[
2423
]";
2524

2625
#[test]
27-
#[ignore]
2826
fn test_broken() {
2927
expect_test::expect![[r#"
3028
Err(
@@ -40,7 +38,6 @@ fn test_broken() {
4038
}
4139

4240
#[test]
43-
#[ignore]
4441
fn test_ok() {
4542
expect_test::expect![[r#"
4643
Ok(

0 commit comments

Comments
 (0)