Move program builder to uplc crate

This commit is contained in:
Turner 2022-06-28 22:27:40 -07:00 committed by Lucas
parent f8aae49fce
commit a238dc58a6
9 changed files with 10 additions and 81 deletions

7
Cargo.lock generated
View File

@ -235,13 +235,6 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "program_builder"
version = "0.1.0"
dependencies = [
"uplc",
]
[[package]]
name = "quote"
version = "1.0.18"

View File

@ -1,2 +1,2 @@
[workspace]
members = ["crates/cli", "crates/flat", "crates/uplc", "crates/program_builder"]
members = ["crates/cli", "crates/flat", "crates/uplc"]

View File

@ -1,10 +0,0 @@
[package]
name = "program_builder"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
# 1st party
uplc = { path = '../uplc', version = "0.0.5" }

View File

@ -18,3 +18,7 @@ hex = "0.4.3"
peg = "0.8.0"
pretty = "0.11.3"
thiserror = "1.0.31"
[features]
unstable = []
test = ["unstable"]

View File

@ -5,5 +5,5 @@ mod flat;
pub mod parser;
mod pretty;
#[cfg(test)]
mod test;
#[cfg(any(feature = "unstable", test))]
pub mod program_builder;

View File

@ -1,8 +1,8 @@
#![cfg_attr(test, allow(non_snake_case))]
use crate::ast::{Constant, Name, Program, Term, Unique};
use std::cell::{Cell, RefCell};
use std::collections::HashMap;
use uplc::ast::{Constant, Name, Program, Term, Unique};
#[cfg(test)]
mod tests;

View File

@ -1,5 +1,5 @@
use crate::{Builder, WithTerm};
use uplc::parser;
use super::*;
use crate::parser;
#[test]
fn build_named__with_const() {

View File

@ -1,57 +0,0 @@
/// e2e encoding/decoding tests
use crate::{
ast::{DeBruijn, Name, Program},
parser,
};
#[test]
fn integer() {
let bytes = include_bytes!("../test_data/basic/integer/integer.flat");
let code = include_str!("../test_data/basic/integer/integer.uplc");
let parsed_program = parser::program(code).unwrap();
let debruijn_program: Program<DeBruijn> = parsed_program.clone().try_into().unwrap();
let decoded_program: Program<DeBruijn> = Program::from_flat(bytes).unwrap();
assert_eq!(debruijn_program, decoded_program);
let encoded_program = debruijn_program.to_flat().unwrap();
assert_eq!(encoded_program, bytes);
let name_program: Program<Name> = decoded_program.try_into().unwrap();
assert_eq!(parsed_program, name_program);
let pretty = name_program.to_pretty();
assert_eq!(pretty, code);
}
#[test]
fn jpg() {
let bytes = include_bytes!("../test_data/jpg/jpg.flat");
let code = include_str!("../test_data/jpg/jpg.uplc");
let parsed_program = parser::program(code).unwrap();
let debruijn_program: Program<DeBruijn> = parsed_program.clone().try_into().unwrap();
let decoded_program: Program<DeBruijn> = Program::from_flat(bytes).unwrap();
assert_eq!(debruijn_program, decoded_program);
let encoded_program = debruijn_program.to_flat().unwrap();
assert_eq!(encoded_program, bytes);
let name_program: Program<Name> = decoded_program.try_into().unwrap();
assert_eq!(parsed_program, name_program);
let pretty = name_program.to_pretty();
assert_eq!(pretty, code);
}

View File

@ -74,7 +74,6 @@ fn fibonacci() {
round_trip_test(bytes, code);
}
// TODO: This is failing, see Bug: https://github.com/txpipe/aiken/issues/10
#[test]
fn one_way_fibonacci() {
let bytes = include_bytes!("../test_data/fibonacci/fibonacci.flat");