fix: change list_access_to_uplc to properly handle list discards

This commit is contained in:
microproofs
2024-01-30 23:53:33 -05:00
parent a83220c8d9
commit 444bccf19c
4 changed files with 190 additions and 94 deletions

View File

@@ -0,0 +1,16 @@
# This file was generated by Aiken
# You typically do not need to edit this file
[[requirements]]
name = "aiken-lang/stdlib"
version = "main"
source = "github"
[[packages]]
name = "aiken-lang/stdlib"
version = "main"
requirements = []
source = "github"
[etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1706674613, nanos_since_epoch = 871553000 }, "cf946239d3dd481ed41f20e56bf24910b5229ea35aa171a708edc2a47fc20a7b"]

View File

@@ -0,0 +1,8 @@
name = "aiken-lang/acceptance_test_070"
version = '0.0.0'
description = ''
[[dependencies]]
name = 'aiken-lang/stdlib'
version = 'main'
source = 'github'

View File

@@ -0,0 +1,47 @@
use aiken/list
use aiken/transaction.{InlineDatum, Input, OutputReference, TransactionId}
type OtherInput {
output_reference: OutputReference,
other: Data,
}
type MyDatum<a> {
Constructor1(a)
Constructor2
}
test discard_partitions() {
let all_inputs =
[
OtherInput(OutputReference(TransactionId(#"aabb"), 2), 3),
OtherInput(OutputReference(TransactionId(#"aabbcc"), 3), 3),
]
let own_out_ref = OutputReference(TransactionId(#"aabb"), 2)
expect ([_], other_inputs) =
list.partition(
all_inputs,
fn(input) { input.output_reference == own_out_ref },
)
let inputs: List<Input> =
[]
list.all(
inputs,
fn(input) {
expect dat: MyDatum<Int> =
when input.output.datum is {
InlineDatum(d) -> d
_ -> fail @"Not an inline datum"
}
when dat is {
Constructor1 { .. } -> True
_ -> False
}
},
)
}