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> {
|
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 {
|
if existing.name == dependency.name {
|
||||||
return if and_replace {
|
return if and_replace {
|
||||||
existing.version = dependency.version.clone();
|
existing.version = dependency.version.clone();
|
||||||
|
|
|
@ -308,6 +308,7 @@ peg::parser! {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use num_bigint::BigInt;
|
use num_bigint::BigInt;
|
||||||
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
use crate::ast::{Constant, Name, Program, Term, Type, Unique};
|
use crate::ast::{Constant, Name, Program, Term, Type, Unique};
|
||||||
use crate::builtins::DefaultFunction;
|
use crate::builtins::DefaultFunction;
|
||||||
|
|
|
@ -318,13 +318,35 @@ impl Type {
|
||||||
.append(r#type.to_doc())
|
.append(r#type.to_doc())
|
||||||
.append(RcDoc::line_())
|
.append(RcDoc::line_())
|
||||||
.append(")"),
|
.append(")"),
|
||||||
Type::Pair(l, r) => RcDoc::text("pair")
|
Type::Pair(l, r) => RcDoc::text("(pair")
|
||||||
.append(RcDoc::text("<"))
|
.append(RcDoc::line())
|
||||||
.append(l.to_doc())
|
.append(l.to_doc())
|
||||||
.append(RcDoc::text(", "))
|
.append(RcDoc::line())
|
||||||
.append(r.to_doc())
|
.append(r.to_doc())
|
||||||
.append(RcDoc::text(">")),
|
.append(")"),
|
||||||
Type::Data => RcDoc::text("data"),
|
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