fix: attempt to convert from opaque before doing monomorphization
This commit is contained in:
13
examples/acceptance_tests/083/aiken.lock
Normal file
13
examples/acceptance_tests/083/aiken.lock
Normal file
@@ -0,0 +1,13 @@
|
||||
# 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"
|
||||
8
examples/acceptance_tests/083/aiken.toml
Normal file
8
examples/acceptance_tests/083/aiken.toml
Normal file
@@ -0,0 +1,8 @@
|
||||
name = "aiken-lang/acceptance_test_083"
|
||||
version = "0.0.0"
|
||||
description = ""
|
||||
|
||||
[[dependencies]]
|
||||
name = 'aiken-lang/stdlib'
|
||||
version = 'main'
|
||||
source = 'github'
|
||||
112
examples/acceptance_tests/083/lib/tests.ak
Normal file
112
examples/acceptance_tests/083/lib/tests.ak
Normal file
@@ -0,0 +1,112 @@
|
||||
use aiken/bytearray
|
||||
use aiken/dict.{Dict}
|
||||
use aiken/int
|
||||
use aiken/list
|
||||
use aiken/transaction.{OutputReference, TransactionId}
|
||||
use aiken/transaction/credential.{Address, VerificationKeyCredential}
|
||||
use aiken/transaction/value.{AssetName, PolicyId, Value}
|
||||
|
||||
fn compare_out_ref(ref1: OutputReference, ref2: OutputReference) -> Ordering {
|
||||
let OutputReference(TransactionId(tx_id1), out_index1) = ref1
|
||||
let OutputReference(TransactionId(tx_id2), out_index2) = ref2
|
||||
when bytearray.compare(tx_id1, tx_id2) is {
|
||||
Less -> Less
|
||||
Greater -> Greater
|
||||
Equal -> int.compare(out_index1, out_index2)
|
||||
}
|
||||
}
|
||||
|
||||
// Compare two values based on a specific asset. Ordering doesn't matter; they just shouldn't
|
||||
// be equal.
|
||||
fn compare_value(
|
||||
loan_id: AssetName,
|
||||
sym: PolicyId,
|
||||
val1: Value,
|
||||
val2: Value,
|
||||
) -> Ordering {
|
||||
if
|
||||
value.quantity_of(val1, sym, loan_id) == value.quantity_of(val2, sym, loan_id){
|
||||
|
||||
error @"Should not be equal"
|
||||
} else {
|
||||
Less
|
||||
}
|
||||
}
|
||||
|
||||
test dict_test1() {
|
||||
let offer_input_ref = OutputReference(TransactionId("00"), 0)
|
||||
let ask_input_ref = OutputReference(TransactionId("00"), 1)
|
||||
let pairings =
|
||||
[(ask_input_ref, offer_input_ref)]
|
||||
|
||||
let (ask_map, asize, offer_map, osize) =
|
||||
(
|
||||
dict.from_list([(ask_input_ref, transaction.NoDatum)], compare_out_ref),
|
||||
1,
|
||||
dict.from_list([(offer_input_ref, transaction.NoDatum)], compare_out_ref),
|
||||
1,
|
||||
)
|
||||
|
||||
(ask_map, asize, offer_map, osize) == (
|
||||
dict.from_list([(ask_input_ref, transaction.NoDatum)], compare_out_ref),
|
||||
1,
|
||||
dict.from_list([(offer_input_ref, transaction.NoDatum)], compare_out_ref),
|
||||
1,
|
||||
)
|
||||
}
|
||||
|
||||
// test dict_test2() {
|
||||
// let offer_input_ref = OutputReference(TransactionId("00"), 0)
|
||||
// let ask_input_ref = OutputReference(TransactionId("00"), 1)
|
||||
// let pairings =
|
||||
// [(ask_input_ref, offer_input_ref)]
|
||||
|
||||
// let foo =
|
||||
// fn(pair: (OutputReference, OutputReference), acc: Dict<Value, Address>) {
|
||||
// let new_pay_map =
|
||||
// dict.insert(
|
||||
// acc,
|
||||
// value.zero(),
|
||||
// Address(VerificationKeyCredential("00"), None),
|
||||
// compare_value("", "", _, _),
|
||||
// )
|
||||
|
||||
// new_pay_map
|
||||
// }
|
||||
|
||||
// let pay_map = list.foldl(pairings, dict.new(), foo)
|
||||
|
||||
// pay_map == dict.new()
|
||||
// }
|
||||
|
||||
// test dict_test3() {
|
||||
// let offer_input_ref = OutputReference(TransactionId("00"), 0)
|
||||
// let ask_input_ref = OutputReference(TransactionId("00"), 1)
|
||||
// let pairings =
|
||||
// [(ask_input_ref, offer_input_ref)]
|
||||
|
||||
// let (ask_map, asize, offer_map, osize) =
|
||||
// (
|
||||
// dict.from_list([(ask_input_ref, transaction.NoDatum)], compare_out_ref),
|
||||
// 1,
|
||||
// dict.from_list([(offer_input_ref, transaction.NoDatum)], compare_out_ref),
|
||||
// 1,
|
||||
// )
|
||||
|
||||
// let foo =
|
||||
// fn(pair: (OutputReference, OutputReference), acc: Dict<Value, Address>) {
|
||||
// let new_pay_map =
|
||||
// dict.insert(
|
||||
// acc,
|
||||
// value.zero(),
|
||||
// Address(VerificationKeyCredential("00"), None),
|
||||
// compare_value("", "", _, _),
|
||||
// )
|
||||
|
||||
// new_pay_map
|
||||
// }
|
||||
|
||||
// let pay_map = list.foldl(pairings, dict.new(), foo)
|
||||
|
||||
// pay_map == dict.new()
|
||||
// }
|
||||
Reference in New Issue
Block a user