Move program builder to uplc crate
This commit is contained in:
parent
f8aae49fce
commit
a238dc58a6
|
@ -235,13 +235,6 @@ dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "program_builder"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"uplc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.18"
|
version = "1.0.18"
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
members = ["crates/cli", "crates/flat", "crates/uplc", "crates/program_builder"]
|
members = ["crates/cli", "crates/flat", "crates/uplc"]
|
||||||
|
|
|
@ -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" }
|
|
|
@ -18,3 +18,7 @@ hex = "0.4.3"
|
||||||
peg = "0.8.0"
|
peg = "0.8.0"
|
||||||
pretty = "0.11.3"
|
pretty = "0.11.3"
|
||||||
thiserror = "1.0.31"
|
thiserror = "1.0.31"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
unstable = []
|
||||||
|
test = ["unstable"]
|
||||||
|
|
|
@ -5,5 +5,5 @@ mod flat;
|
||||||
pub mod parser;
|
pub mod parser;
|
||||||
mod pretty;
|
mod pretty;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(any(feature = "unstable", test))]
|
||||||
mod test;
|
pub mod program_builder;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#![cfg_attr(test, allow(non_snake_case))]
|
#![cfg_attr(test, allow(non_snake_case))]
|
||||||
|
|
||||||
|
use crate::ast::{Constant, Name, Program, Term, Unique};
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use uplc::ast::{Constant, Name, Program, Term, Unique};
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::{Builder, WithTerm};
|
use super::*;
|
||||||
use uplc::parser;
|
use crate::parser;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn build_named__with_const() {
|
fn build_named__with_const() {
|
|
@ -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);
|
|
||||||
}
|
|
|
@ -74,7 +74,6 @@ fn fibonacci() {
|
||||||
round_trip_test(bytes, code);
|
round_trip_test(bytes, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: This is failing, see Bug: https://github.com/txpipe/aiken/issues/10
|
|
||||||
#[test]
|
#[test]
|
||||||
fn one_way_fibonacci() {
|
fn one_way_fibonacci() {
|
||||||
let bytes = include_bytes!("../test_data/fibonacci/fibonacci.flat");
|
let bytes = include_bytes!("../test_data/fibonacci/fibonacci.flat");
|
||||||
|
|
Loading…
Reference in New Issue