From 2f0c3deb5ce5b0aa9abb20b78066b7e8277667d2 Mon Sep 17 00:00:00 2001 From: imaqtkatt Date: Tue, 12 Mar 2024 15:58:58 -0300 Subject: [PATCH 1/2] Remove expand in debug hook --- src/lib.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 9f48321f2..5c9f6081e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -261,11 +261,10 @@ pub fn run_compiled( let start_time = Instant::now(); if let Some(mut hook) = hook { - root.expand(); while !root.redexes.is_empty() { - hook(&host.lock().unwrap().readback(root)); + let readback = host.lock().unwrap().readback(root); + hook(&readback); root.reduce(1); - root.expand(); } } else if let Some(mut max_rwts) = max_rwts { if run_opts.lazy_mode { From 85c5c45fb7ed18f9d9e60c0473d49d2ea630560b Mon Sep 17 00:00:00 2001 From: imaqtkatt Date: Tue, 12 Mar 2024 16:21:44 -0300 Subject: [PATCH 2/2] Add debug flag cli test --- tests/golden_tests/cli/debug_u60_to_nat.args | 4 +++ tests/golden_tests/cli/debug_u60_to_nat.hvm | 6 ++++ .../snapshots/cli__debug_u60_to_nat.hvm.snap | 33 +++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 tests/golden_tests/cli/debug_u60_to_nat.args create mode 100644 tests/golden_tests/cli/debug_u60_to_nat.hvm create mode 100644 tests/snapshots/cli__debug_u60_to_nat.hvm.snap diff --git a/tests/golden_tests/cli/debug_u60_to_nat.args b/tests/golden_tests/cli/debug_u60_to_nat.args new file mode 100644 index 000000000..0dc92ddd0 --- /dev/null +++ b/tests/golden_tests/cli/debug_u60_to_nat.args @@ -0,0 +1,4 @@ +run +tests/golden_tests/cli/debug_u60_to_nat.hvm +-d +4 diff --git a/tests/golden_tests/cli/debug_u60_to_nat.hvm b/tests/golden_tests/cli/debug_u60_to_nat.hvm new file mode 100644 index 000000000..066ca8c8d --- /dev/null +++ b/tests/golden_tests/cli/debug_u60_to_nat.hvm @@ -0,0 +1,6 @@ +data Nat = (Z) | (S nat) + +(U60ToNat 0) = Z +(U60ToNat 1+p) = (S (U60ToNat p)) + +(Main n) = (U60ToNat n) diff --git a/tests/snapshots/cli__debug_u60_to_nat.hvm.snap b/tests/snapshots/cli__debug_u60_to_nat.hvm.snap new file mode 100644 index 000000000..fa90a4051 --- /dev/null +++ b/tests/snapshots/cli__debug_u60_to_nat.hvm.snap @@ -0,0 +1,33 @@ +--- +source: tests/golden_tests.rs +input_file: tests/golden_tests/cli/debug_u60_to_nat.hvm +--- +(λa (U60ToNat a) 4) +--------------------------------------- +(U60ToNat 4) +--------------------------------------- +(λa (S (U60ToNat a)) 3) +--------------------------------------- +(S (U60ToNat 3)) +--------------------------------------- +(S (λa (S (U60ToNat a)) 2)) +--------------------------------------- +(S (S (U60ToNat 2))) +--------------------------------------- +(S (S (λa (S (U60ToNat a)) 1))) +--------------------------------------- +(S (S (S (U60ToNat 1)))) +--------------------------------------- +(S (S (S (λa (S (U60ToNat a)) 0)))) +--------------------------------------- +(S (S (S (S (U60ToNat 0))))) +--------------------------------------- +(S (S (S (S Z)))) +--------------------------------------- +(S (S (S #Nat λ* #Nat λa #Nat (a Z)))) +--------------------------------------- +(S (S #Nat λ* #Nat λa #Nat (a #Nat λ* #Nat λb #Nat (b Z)))) +--------------------------------------- +(S #Nat λ* #Nat λa #Nat (a #Nat λ* #Nat λb #Nat (b #Nat λ* #Nat λc #Nat (c Z)))) +--------------------------------------- +(S (S (S (S Z))))