From 0f44d07aad436146963b146c420bd68ef14c23f1 Mon Sep 17 00:00:00 2001 From: Eduardo Sandalo Porto Date: Fri, 7 Jun 2024 16:10:49 -0300 Subject: [PATCH] Add test for safety checking --- tests/programs/safety-check.hvm | 31 +++++++++++++++++++ .../snapshots/run__file@safety-check.hvm.snap | 6 ++++ 2 files changed, 37 insertions(+) create mode 100644 tests/programs/safety-check.hvm create mode 100644 tests/snapshots/run__file@safety-check.hvm.snap diff --git a/tests/programs/safety-check.hvm b/tests/programs/safety-check.hvm new file mode 100644 index 00000000..801006bf --- /dev/null +++ b/tests/programs/safety-check.hvm @@ -0,0 +1,31 @@ +@List/Cons = (a (b ((@List/Cons/tag (a (b c))) c))) + +@List/Cons/tag = 1 + +@List/Nil = ((@List/Nil/tag a) a) + +@List/Nil/tag = 0 + +@id = (a a) + +@list = c + & @List/Cons ~ (1 (b c)) + & @List/Cons ~ (2 (@List/Nil b)) + +@main = b + & @map ~ (@main__C0 (a b)) + & @List/Cons ~ (@id (@List/Nil a)) + +@main__C0 = (a b) + & @map ~ (a (@list b)) + +@map = (a ((@map__C1 (a b)) b)) + +@map__C0 = (* (a (d ({(a b) c} f)))) + & @List/Cons ~ (b (e f)) + & @map ~ (c (d e)) + +@map__C1 = (?(((* @List/Nil) @map__C0) a) a) + +// Test flags +@test-rust-only = 1 \ No newline at end of file diff --git a/tests/snapshots/run__file@safety-check.hvm.snap b/tests/snapshots/run__file@safety-check.hvm.snap new file mode 100644 index 00000000..fbc70b78 --- /dev/null +++ b/tests/snapshots/run__file@safety-check.hvm.snap @@ -0,0 +1,6 @@ +--- +source: tests/run.rs +expression: rust_output +input_file: tests/programs/safety-check.hvm +--- +ERROR: attempt to clone a non-affine global reference.