fix(uplc): pair type formatting closes #680
This commit is contained in:
parent
1d1403816a
commit
be7a441205
|
@ -99,7 +99,7 @@ impl Config {
|
|||
}
|
||||
|
||||
pub fn insert(mut self, dependency: &Dependency, and_replace: bool) -> Option<Self> {
|
||||
for mut existing in self.dependencies.iter_mut() {
|
||||
for existing in self.dependencies.iter_mut() {
|
||||
if existing.name == dependency.name {
|
||||
return if and_replace {
|
||||
existing.version = dependency.version.clone();
|
||||
|
|
|
@ -308,6 +308,7 @@ peg::parser! {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use num_bigint::BigInt;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
use crate::ast::{Constant, Name, Program, Term, Type, Unique};
|
||||
use crate::builtins::DefaultFunction;
|
||||
|
|
|
@ -318,13 +318,35 @@ impl Type {
|
|||
.append(r#type.to_doc())
|
||||
.append(RcDoc::line_())
|
||||
.append(")"),
|
||||
Type::Pair(l, r) => RcDoc::text("pair")
|
||||
.append(RcDoc::text("<"))
|
||||
Type::Pair(l, r) => RcDoc::text("(pair")
|
||||
.append(RcDoc::line())
|
||||
.append(l.to_doc())
|
||||
.append(RcDoc::text(", "))
|
||||
.append(RcDoc::line())
|
||||
.append(r.to_doc())
|
||||
.append(RcDoc::text(">")),
|
||||
.append(")"),
|
||||
Type::Data => RcDoc::text("data"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use indoc::indoc;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn format_pair_bool_pair_integer_bytestring() {
|
||||
let uplc = "(program 0.0.0 (con (pair bool (pair integer bytestring)) (True, (14, #42))))";
|
||||
|
||||
assert_eq!(
|
||||
crate::parser::program(uplc).unwrap().to_pretty(),
|
||||
indoc! {
|
||||
r#"
|
||||
(program
|
||||
0.0.0
|
||||
(con (pair bool (pair integer bytestring)) (True, (14, #42)))
|
||||
)"#
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue