From 9c902cdf8985a26ec75f3f688e0688426d0d8b5c Mon Sep 17 00:00:00 2001 From: KtorZ Date: Tue, 13 Dec 2022 22:54:07 +0100 Subject: [PATCH] Add new acceptance test scenario (012) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ``` Error: × Main thread panicked. ├─▶ at crates/lang/src/uplc.rs:3413:34 ╰─▶ internal error: entered unreachable code: Var { scope: [ 0, 1, 3, 24, 25, 29, 32, ], constructor: ValueConstructor { public: false, variant: LocalVariable { location: 46..62, }, tipo: Fn { args: [ Var { tipo: RefCell { value: Link { tipo: App { public: true, module: "", name: "Int", args: [], }, }, }, }, ], ret: App { public: true, module: "", name: "Bool", args: [], }, }, }, name: "f", variant_name: "", } ``` --- examples/acceptance_tests/012/aiken.toml | 2 ++ examples/acceptance_tests/012/lib/test.ak | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 examples/acceptance_tests/012/aiken.toml create mode 100644 examples/acceptance_tests/012/lib/test.ak diff --git a/examples/acceptance_tests/012/aiken.toml b/examples/acceptance_tests/012/aiken.toml new file mode 100644 index 00000000..ed8f7704 --- /dev/null +++ b/examples/acceptance_tests/012/aiken.toml @@ -0,0 +1,2 @@ +name = "acceptance_test_012" +version = "0.0.0" diff --git a/examples/acceptance_tests/012/lib/test.ak b/examples/acceptance_tests/012/lib/test.ak new file mode 100644 index 00000000..b0a781e3 --- /dev/null +++ b/examples/acceptance_tests/012/lib/test.ak @@ -0,0 +1,18 @@ +use aiken/builtin + +pub fn filter(xs: List, f: fn(a) -> Bool) -> List { + when xs is { + [] -> [] + [x, ..rest] -> + if f(x) { + [x, ..filter(rest, f)] + } else { + filter(rest, f) + } + } +} + +test filter_1() { + filter([1, + 2, 3, 4, 5, 6], fn(x) { builtin.mod_integer(x, 2) == 0 }) == [2, 4, 6] +}