Refractor tests
parent
46b96f3e82
commit
4c4928ea9f
|
@ -1,21 +0,0 @@
|
|||
---
|
||||
source: src/tests.rs
|
||||
assertion_line: 27
|
||||
expression: "String::from_utf8(cmd.get_output().stdout.clone()).unwrap()"
|
||||
|
||||
---
|
||||
1.0
|
||||
0.0
|
||||
-1.0
|
||||
0.0
|
||||
1.0
|
||||
1.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
1.0
|
||||
1.0
|
||||
1.0
|
||||
0.0
|
||||
1.0
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
---
|
||||
source: src/tests.rs
|
||||
assertion_line: 27
|
||||
expression: "String::from_utf8(cmd.get_output().stdout.clone()).unwrap()"
|
||||
|
||||
---
|
||||
0.0
|
||||
1.0
|
||||
10.0
|
||||
-1.0
|
||||
-8.0
|
||||
7.0
|
||||
2.0
|
||||
1.0
|
||||
0.1
|
||||
1.0
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
source: src/tests.rs
|
||||
assertion_line: 47
|
||||
expression: run-pass funcs.scm
|
||||
|
||||
---
|
||||
5.0
|
||||
11.0
|
||||
14.0
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
---
|
||||
source: src/tests.rs
|
||||
assertion_line: 47
|
||||
expression: run-pass lambda-calc.scm
|
||||
|
||||
---
|
||||
1.0
|
||||
0.0
|
||||
-1.0
|
||||
0.0
|
||||
1.0
|
||||
1.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
1.0
|
||||
1.0
|
||||
1.0
|
||||
0.0
|
||||
1.0
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
source: src/tests.rs
|
||||
assertion_line: 47
|
||||
expression: run-pass math.scm
|
||||
|
||||
---
|
||||
0.0
|
||||
1.0
|
||||
10.0
|
||||
-1.0
|
||||
-8.0
|
||||
7.0
|
||||
2.0
|
||||
1.0
|
||||
0.1
|
||||
1.0
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
#lang scheme
|
||||
|
||||
(define (displayln x) (display x) (newline))
|
||||
|
||||
(define add1 +)
|
||||
(displayln (add1 2 3))
|
||||
|
||||
(define add2 (lambda (a b) (+ a b)))
|
||||
(displayln (add2 5 6))
|
||||
|
||||
(define (add3 a b) (+ a b))
|
||||
(displayln (add3 5 9))
|
32
src/tests.rs
32
src/tests.rs
|
@ -1,3 +1,5 @@
|
|||
use std::path::{Path, PathBuf};
|
||||
|
||||
// use fs_err as fs;
|
||||
|
||||
/*
|
||||
|
@ -13,15 +15,37 @@ upstream for this
|
|||
*/
|
||||
|
||||
#[test]
|
||||
fn pass() {
|
||||
insta::glob!("test/pass/**.scm", |p| {
|
||||
fn run_pass() {
|
||||
let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
|
||||
|
||||
insta::glob!("test/run-pass/**.scm", |p| {
|
||||
let p = PathBuf::from(
|
||||
p.canonicalize()
|
||||
.unwrap()
|
||||
.to_str()
|
||||
.unwrap()
|
||||
.replace("\\\\?\\", ""), // Work around IDK on windows
|
||||
);
|
||||
|
||||
let cmd = assert_cmd::Command::cargo_bin("handball")
|
||||
.unwrap()
|
||||
.arg(p)
|
||||
.arg(&p)
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
dbg!(&p, p.components().collect::<Vec<_>>());
|
||||
|
||||
dbg!(&p, manifest_dir);
|
||||
|
||||
let p = p.strip_prefix(manifest_dir).unwrap();
|
||||
let p = p.strip_prefix("src/test/run-pass").unwrap();
|
||||
let p = p.to_str().unwrap();
|
||||
|
||||
assert_eq!(cmd.get_output().stderr, Vec::<u8>::new());
|
||||
insta::assert_snapshot!(String::from_utf8(cmd.get_output().stdout.clone()).unwrap());
|
||||
insta::assert_snapshot!(
|
||||
"run-pass",
|
||||
String::from_utf8(cmd.get_output().stdout.clone()).unwrap(),
|
||||
&format!("run-pass {}", p)
|
||||
);
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue