improve tests settings

This commit is contained in:
LunaAmora 2023-11-13 11:35:00 -04:00
parent 7530cea3d5
commit 00e87e6502
109 changed files with 192 additions and 292 deletions

View File

@ -33,7 +33,7 @@ fn do_parse_net(code: &str) -> Result<hvmc::ast::Net, String> {
parse_net(&mut code.chars().peekable())
}
const TESTS_PATH: &'static str = "/tests/golden_tests/";
const TESTS_PATH: &str = "/tests/golden_tests/";
fn run_single_golden_test(
path: &Path,
@ -43,7 +43,16 @@ fn run_single_golden_test(
let file_name = path.to_str().and_then(|path| path.rsplit_once(TESTS_PATH)).unwrap().1;
let result: String = run(path, &code).unwrap_or_else(|err| err);
assert_snapshot!(file_name, result);
let mut settings = insta::Settings::clone_current();
settings.set_prepend_module_to_snapshot(false);
settings.set_omit_expression(true);
settings.set_input_file(path);
settings.bind(|| {
assert_snapshot!(file_name, result);
});
Ok(())
}

View File

@ -1,33 +0,0 @@
(True) = λTrue λFalse True
(False) = λTrue λFalse False
(Filled) = λa0 λFilled λEmpty (Filled a0)
(Empty) = λFilled λEmpty Empty
(North) = λNorth λSouth λEast λWest North
(South) = λNorth λSouth λEast λWest South
(East) = λNorth λSouth λEast λWest East
(West) = λNorth λSouth λEast λWest West
(Red) = λRed λYellow λGreen Red
(Yellow) = λRed λYellow λGreen Yellow
(Green) = λRed λYellow λGreen Green
(Cons) = λa0 λa1 λCons λNil ((Cons a0) a1)
(Nil) = λCons λNil Nil
(Some) = λa0 λSome λNone (Some a0)
(None) = λSome λNone None
(Ok) = λa0 λOk λErr (Ok a0)
(Err) = λa0 λOk λErr (Err a0)

View File

@ -1,25 +0,0 @@
(Var) = λa0 λVar λNum λApp λFun λIf λLet λDup λTup λOp2 (Var a0)
(Num) = λa0 λVar λNum λApp λFun λIf λLet λDup λTup λOp2 (Num a0)
(App) = λa0 λa1 λVar λNum λApp λFun λIf λLet λDup λTup λOp2 ((App a0) a1)
(Fun) = λa0 λa1 λVar λNum λApp λFun λIf λLet λDup λTup λOp2 ((Fun a0) a1)
(If) = λa0 λa1 λa2 λVar λNum λApp λFun λIf λLet λDup λTup λOp2 (((If a0) a1) a2)
(Let) = λa0 λa1 λa2 λVar λNum λApp λFun λIf λLet λDup λTup λOp2 (((Let a0) a1) a2)
(Dup) = λa0 λa1 λa2 λa3 λVar λNum λApp λFun λIf λLet λDup λTup λOp2 ((((Dup a0) a1) a2) a3)
(Tup) = λa0 λa1 λVar λNum λApp λFun λIf λLet λDup λTup λOp2 ((Tup a0) a1)
(Op2) = λa0 λa1 λa2 λVar λNum λApp λFun λIf λLet λDup λTup λOp2 (((Op2 a0) a1) a2)
(Add) = λAdd λSub λMul λDiv Add
(Sub) = λAdd λSub λMul λDiv Sub
(Mul) = λAdd λSub λMul λDiv Mul
(Div) = λAdd λSub λMul λDiv Div

View File

@ -1,15 +0,0 @@
(main) = (λx x Saturday)
(Monday) = λMonday λTuesday λWednesday λThursday λFriday λSaturday λSunday Monday
(Tuesday) = λMonday λTuesday λWednesday λThursday λFriday λSaturday λSunday Tuesday
(Wednesday) = λMonday λTuesday λWednesday λThursday λFriday λSaturday λSunday Wednesday
(Thursday) = λMonday λTuesday λWednesday λThursday λFriday λSaturday λSunday Thursday
(Friday) = λMonday λTuesday λWednesday λThursday λFriday λSaturday λSunday Friday
(Saturday) = λMonday λTuesday λWednesday λThursday λFriday λSaturday λSunday Saturday
(Sunday) = λMonday λTuesday λWednesday λThursday λFriday λSaturday λSunday Sunday

View File

@ -1,26 +0,0 @@
@App = (a (b (* (* ((a (b c)) (* (* (* (* (* (* c)))))))))))
@Dup = (a (b (c (d (* (* (* (* (* (* ((a (b (c (d e)))) (* (* e)))))))))))))
@F = (a (* (* a)))
@G = (a (* a))
@H = (* @G)
@Let = (a (b (c (* (* (* (* (* ((a (b (c d))) (* (* (* d))))))))))))
@Mul = (* @H)
@Num = (a (* ((a b) (* (* (* (* (* (* (* b))))))))))
@Op2 = (a (b (c (* (* (* (* (* (* (* (* ((a (b (c d))) d))))))))))))
@Sub = (* @F)
@Var = (a ((a b) (* (* (* (* (* (* (* (* b))))))))))
@main = a
& (b (c (d a))) ~ @Let
& (e (f (g (h d)))) ~ @Dup
& (i (j h)) ~ @App
& (#2 j) ~ @Var
& (#1 i) ~ @Var
& (#0 g) ~ @Var
& (#2 f) ~ @Var
& (#1 e) ~ @Var
& (@Mul (k c)) ~ @Op2
& (@Sub (l (m (n k)))) ~ @Op2
& (#3 n) ~ @Num
& (#1 m) ~ @Num
& (#2 l) ~ @Num
& (#0 b) ~ @Var

View File

@ -1 +0,0 @@
Non-exhaustive pattern at definition 'Foo'. Argument 2 of type 'Type' does not cover the 'A' constructor

View File

@ -1,9 +0,0 @@
@9 = (a a)
@K = (a (* a))
@L = (* @K)
@M = (* @L)
@N = (* @M)
@O = (* @N)
@Satu = (* @O)
@main = a
& (@Satu a) ~ @9

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/adt_generation/common.hvm
---
(True) = λTrue λFalse True

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/adt_generation/expr.hvm
---
(Var) = λa0 λVar λNum λApp λFun λIf λLet λDup λTup λOp2 (Var a0)

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/adt_generation/weekday.hvm
---
(main) = (λx x Saturday)

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_file/addition.hvm
---
@2 = (a b)
& <c <a b>> ~ #1

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/bad_parens_making_erased_let.hvm
---
Unbound variable 'two'

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_file/bool.hvm
---
@5 = (a a)
@Not = ((@fals (@true a)) a)

View File

@ -1,5 +1,5 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_file/cyclic_dup.hvm
---
Unbound variable 'y1'

View File

@ -1,5 +1,5 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_file/double_main.hvm
---
File has both 'Main' and 'main' definitions

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_file/ex0.hvm
---
@9 = (a a)
@C_2 = ({2 (a b) (c a)} (c b))

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_file/ex2.hvm
---
@E = (* @G)
@F = (a a)

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_file/example.hvm
---
@7 = (a a)
@8 = (a a)

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_file/expr.hvm
---
@App = (a (b (* (* ((a (b c)) (* (* (* (* (* (* c)))))))))))
@Dup = (a (b (c (d (* (* (* (* (* (* ((a (b (c (d e)))) (* (* e)))))))))))))

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_file/extracted_match_pred.hvm
---
@5 = (a b)
& (a b) ~ @valS

View File

@ -0,0 +1,6 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/hvm1_main.hvm
---
@main = (a a)

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_file/inline_app.hvm
---
@Rul1 = (a a)
@Rul2 = (a a)

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_file/long_name.hvm
---
@WowT = (a a)
@main = (a b)

View File

@ -1,5 +1,5 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_file/non_exhaustive_pattern.hvm
---
Non-exhaustive pattern at definition 'Foo'. Argument 2 of type 'Type' does not cover the 'A' constructor

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_file/ref_to_ref.hvm
---
@A2 = #1
@B5 = #2

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_file/repeated_name_trucation.hvm
---
@1 = (* @3)
@3 = (* @1)

View File

@ -1,5 +1,5 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_file/self_ref.hvm
---
Definition main is a reference to itself

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_file/snd.hvm
---
@main = a
& ([#0 #42] a) ~ @snd

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_file/spacing.hvm
---
@2 = (a a)
@main = ({2 a b} c)

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_file/spacing2.hvm
---
@2 = (a a)
@3 = (a a)

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_file/var_shadows_ref.hvm
---
@3 = (a a)
@a = (a a)

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_file/weekday.hvm
---
@9 = (a a)
@K = (a (* a))

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_term/addition.hvm
---
a
& (#8 a) ~ (b c)

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_term/church_one.hvm
---
a
& ((* (b b)) a) ~ ((c (d e)) ({2 (e f) c} (d f)))

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_term/church_zero.hvm
---
(* (a a))

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_term/complicated_dup.hvm
---
({3 (a b) (c d)} e)
& ((f {2 a c}) b) ~ ((f d) e)

View File

@ -1,5 +1,5 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_term/cyclic_global_lam.hvm
---
Found term that compiles into an inet with a vicious cycle

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_term/dup_apply.hvm
---
({2 (a b) a} b)

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_term/dup_global_lam.hvm
---
a
& (b a) ~ ({2 (c b) c} (d d))

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_term/erased_dup.hvm
---
({2 * a} a)

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_term/fst_snd.hvm
---
a
& (b a) ~ ([* c] c)

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_term/global_lam.hvm
---
a
& (b a) ~ (b (c c))

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_term/id.hvm
---
(a a)

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_term/infer_dup.hvm
---
({2 a (a b)} b)

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_term/let_substitution.hvm
---
({2 a (a b)} b)

View File

@ -1,5 +1,5 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_term/let_tup.hvm
---
[(a (* a)) (* (b b))]

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_term/lets.hvm
---
a
& (b (c (d a))) ~ (e e)

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_term/match.hvm
---
a
& <#0 <#1 ? ((b (* b)) (* (* (c c)))) a>> ~ #1

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_term/nested_let.hvm
---
a
& [[* *] [a *]] ~ [[#2 #4] [#3 #6]]

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_term/op2.hvm
---
a
& <b <#11 a>> ~ #1

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_term/simple_tup.hvm
---
[#0 #42]

View File

@ -1,5 +1,5 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_term/tup.hvm
---
[[#1 #4] [#2 #3]]

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/compile_term/tup_add.hvm
---
a
& <b <c a>> ~ #1

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_term/unbound_var.hvm
---
Unbound variable 'a'

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_term/unbound_var_scope.hvm
---
Unbound variable 'b'

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/flatten_rules/already_flat.hvm
---
(Rule1) = λx x

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/flatten_rules/bits_dec.hvm
---
(Data.Bits.dec Data.Bits.e) = Data.Bits.e
(Data.Bits.dec (Data.Bits.o .x0)) = (Data.Bits.dec$0$ .x0)

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/flatten_rules/nested_ctrs.hvm
---
(Rule (CtrA a .x0)) = ((Rule$0$ a) .x0)
(Rule (CtrB b)) = b

View File

@ -1,5 +0,0 @@
---
source: tests/golden_tests.rs
expression: result
---
Unbound variable 'two'

View File

@ -1,6 +0,0 @@
---
source: tests/golden_tests.rs
expression: result
---
@main = (a a)

View File

@ -1,5 +0,0 @@
---
source: tests/golden_tests.rs
expression: result
---
(* (a a))

View File

@ -1,5 +0,0 @@
---
source: tests/golden_tests.rs
expression: result
---
({2 (a b) a} b)

View File

@ -1,5 +0,0 @@
---
source: tests/golden_tests.rs
expression: result
---
({2 * a} a)

View File

@ -1,5 +0,0 @@
---
source: tests/golden_tests.rs
expression: result
---
(a a)

View File

@ -1,5 +0,0 @@
---
source: tests/golden_tests.rs
expression: result
---
({2 a (a b)} b)

View File

@ -1,5 +0,0 @@
---
source: tests/golden_tests.rs
expression: result
---
({2 a (a b)} b)

View File

@ -1,5 +0,0 @@
---
source: tests/golden_tests.rs
expression: result
---
[#0 #42]

View File

@ -1,5 +0,0 @@
---
source: tests/golden_tests.rs
expression: result
---
Unbound variable 'a'

View File

@ -1,5 +0,0 @@
---
source: tests/golden_tests.rs
expression: result
---
Unbound variable 'b'

View File

@ -1,5 +0,0 @@
---
source: tests/golden_tests.rs
expression: result
---
(+ 2 1)

View File

@ -1,5 +0,0 @@
---
source: tests/golden_tests.rs
expression: result
---
λa λb a

View File

@ -1,5 +0,0 @@
---
source: tests/golden_tests.rs
expression: result
---
λa λb a

View File

@ -1,5 +0,0 @@
---
source: tests/golden_tests.rs
expression: result
---
λa a

View File

@ -1,5 +0,0 @@
---
source: tests/golden_tests.rs
expression: result
---
10

View File

@ -1,5 +0,0 @@
---
source: tests/golden_tests.rs
expression: result
---
(0, 42)

View File

@ -1,5 +0,0 @@
---
source: tests/golden_tests.rs
expression: result
---
10

View File

@ -1,5 +0,0 @@
---
source: tests/golden_tests.rs
expression: result
---
λa a

View File

@ -1,5 +0,0 @@
---
source: tests/golden_tests.rs
expression: result
---
8

View File

@ -1,5 +0,0 @@
---
source: tests/golden_tests.rs
expression: result
---
0

View File

@ -1,5 +0,0 @@
---
source: tests/golden_tests.rs
expression: result
---
λ* λa a

View File

@ -1,5 +0,0 @@
---
source: tests/golden_tests.rs
expression: result
---
2

View File

@ -1,5 +0,0 @@
---
source: tests/golden_tests.rs
expression: result
---
λ* λ* Main

View File

@ -1,5 +0,0 @@
---
source: tests/golden_tests.rs
expression: result
---
λ* λ* main

View File

@ -1,5 +0,0 @@
---
source: tests/golden_tests.rs
expression: result
---
λa (a λb b)

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/readback_lnet/addition.hvm
---
(+ 2 1)

View File

@ -1,6 +1,6 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/readback_lnet/bad_net.hvm
---
Invalid readback:
*

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/readback_lnet/bad_net1.hvm
---
λa λb a

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/readback_lnet/bad_net3.hvm
---
λa λb a

View File

@ -1,5 +1,5 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/readback_lnet/complicated_dup.hvm
---
λa (λb (a (b c)) λc (a (b c)))

View File

@ -1,5 +1,5 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/readback_lnet/fst_snd.hvm
---
let (*, b) = a; let (d, *) = c; (λa b (λc d ((1, 3), 2)))

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/readback_lnet/id.hvm
---
λa a

View File

@ -1,5 +1,5 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/readback_lnet/match.hvm
---
match 1 { 0: λa a; 1+b: b }

View File

@ -1,5 +1,5 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/readback_lnet/nested_let.hvm
---
let (c, b) = ((2, 4), (3, 6)); let (a, *) = b; a

View File

@ -1,5 +1,5 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/readback_lnet/nested_tup.hvm
---
((1, 2), (4, (3, 5)))

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/readback_lnet/number.hvm
---
10

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/readback_lnet/simple_tup.hvm
---
(0, 42)

View File

@ -1,5 +1,5 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/readback_lnet/tup_add.hvm
---
let (a, b) = (1, 2); (+ a b)

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_single_files/addition.hvm
---
10

View File

@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_single_files/dup_global_lam.hvm
---
λa a

View File

@ -1,5 +1,5 @@
---
source: tests/golden_tests.rs
expression: result
input_file: tests/golden_tests/run_single_files/empty.hvm
---
File has no 'main' definition

Some files were not shown because too many files have changed in this diff Show More