Add new acceptance test scenario 023

```
  Error:
    × Main thread panicked.
    ├─▶ at crates/lang/src/uplc.rs:2830:32
    ╰─▶ called `Option::unwrap()` on a `None` value
  ```
This commit is contained in:
KtorZ 2022-12-19 18:51:44 +01:00
parent 43ff66cd01
commit dbd3d3fd7d
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
2 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,2 @@
name = "acceptance_test_023"
version = "0.0.0"

View File

@ -0,0 +1,45 @@
pub opaque type AssocList<key, value> {
inner: List<#(key, value)>,
}
pub fn new() -> AssocList<key, value> {
AssocList { inner: [] }
}
pub fn to_list(m: AssocList<key, value>) -> List<#(key, value)> {
m.inner
}
pub fn insert(
in m: AssocList<key, value>,
key k: key,
value v: value,
) -> AssocList<key, value> {
AssocList { inner: do_insert(m.inner, k, v) }
}
fn do_insert(
elems: List<#(key, value)>,
k: key,
v: value,
) -> List<#(key, value)> {
when elems is {
[] -> [#(k, v)]
[#(k2, v2), ..rest] ->
if k == k2 {
[#(k, v), ..rest]
} else {
[#(k2, v2), ..do_insert(rest, k, v)]
}
}
}
fn fixture_1() {
new()
|> insert("foo", 42)
|> insert("bar", 14)
}
test to_list_2() {
to_list(fixture_1()) == [#("foo", 42), #("bar", 14)]
}