From 3126eba2ba1b07502e24177db0f997578830f365 Mon Sep 17 00:00:00 2001 From: imaqtkatt Date: Mon, 1 Apr 2024 11:20:40 -0300 Subject: [PATCH] Readd oall eta tests --- src/lib.rs | 3 +++ src/term/transform/mod.rs | 2 ++ tests/golden_tests/compile_file_o_all/eta_chain.hvm | 5 +++++ tests/golden_tests/compile_file_o_all/unapplied_eta.hvm | 2 ++ tests/snapshots/compile_file_o_all__eta_chain.hvm.snap | 9 ++++++++- .../snapshots/compile_file_o_all__unapplied_eta.hvm.snap | 3 ++- 6 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 tests/golden_tests/compile_file_o_all/eta_chain.hvm create mode 100644 tests/golden_tests/compile_file_o_all/unapplied_eta.hvm diff --git a/src/lib.rs b/src/lib.rs index cd5205a78..a2062c81f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -52,6 +52,9 @@ pub fn compile_book( if opts.pre_reduce { core_book.pre_reduce(&|x| x == book.hvmc_entrypoint(), None, 100_000); } + if opts.eta { + core_book.values_mut().for_each(Net::eta_reduce); + } if opts.prune { prune_defs(&mut core_book, book.hvmc_entrypoint().to_string()); } diff --git a/src/term/transform/mod.rs b/src/term/transform/mod.rs index f4737d8e9..9e125e17a 100644 --- a/src/term/transform/mod.rs +++ b/src/term/transform/mod.rs @@ -5,6 +5,8 @@ pub mod definition_pruning; pub mod desugar_match_defs; pub mod encode_adts; pub mod encode_match_terms; +pub mod fix_match_defs; +pub mod fix_match_terms; pub mod float_combinators; pub mod inline; pub mod linearize_matches; diff --git a/tests/golden_tests/compile_file_o_all/eta_chain.hvm b/tests/golden_tests/compile_file_o_all/eta_chain.hvm new file mode 100644 index 000000000..d8cd9c0f8 --- /dev/null +++ b/tests/golden_tests/compile_file_o_all/eta_chain.hvm @@ -0,0 +1,5 @@ +Baz a b c = (+ a (+ b c)) +Bar a b = (Baz a b) +Foo a = (Bar a) + +main = λa (Foo a) diff --git a/tests/golden_tests/compile_file_o_all/unapplied_eta.hvm b/tests/golden_tests/compile_file_o_all/unapplied_eta.hvm new file mode 100644 index 000000000..728eb962d --- /dev/null +++ b/tests/golden_tests/compile_file_o_all/unapplied_eta.hvm @@ -0,0 +1,2 @@ +Id = λa a +main = λa (Id a) diff --git a/tests/snapshots/compile_file_o_all__eta_chain.hvm.snap b/tests/snapshots/compile_file_o_all__eta_chain.hvm.snap index 3ae33e837..cc403c5dc 100644 --- a/tests/snapshots/compile_file_o_all__eta_chain.hvm.snap +++ b/tests/snapshots/compile_file_o_all__eta_chain.hvm.snap @@ -2,4 +2,11 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/compile_file_o_all/eta_chain.hvm --- -@main = (<+ a b> (<+ c a> (c b))) +@Bar = @Baz + +@Baz = (<+ a b> (<+ c a> (c b))) + +@Foo = @Bar + +@main = a + & @Foo ~ a diff --git a/tests/snapshots/compile_file_o_all__unapplied_eta.hvm.snap b/tests/snapshots/compile_file_o_all__unapplied_eta.hvm.snap index 6ae3dd0cc..c21b26302 100644 --- a/tests/snapshots/compile_file_o_all__unapplied_eta.hvm.snap +++ b/tests/snapshots/compile_file_o_all__unapplied_eta.hvm.snap @@ -2,4 +2,5 @@ source: tests/golden_tests.rs input_file: tests/golden_tests/compile_file_o_all/unapplied_eta.hvm --- -@main = (a a) +@main = a + & (c c) ~ a