diff --git a/Cargo.lock b/Cargo.lock index b9d60342..12706516 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -235,13 +235,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "program_builder" -version = "0.1.0" -dependencies = [ - "uplc", -] - [[package]] name = "quote" version = "1.0.18" diff --git a/Cargo.toml b/Cargo.toml index 0b391440..f409c5ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,2 +1,2 @@ [workspace] -members = ["crates/cli", "crates/flat", "crates/uplc", "crates/program_builder"] +members = ["crates/cli", "crates/flat", "crates/uplc"] diff --git a/crates/program_builder/Cargo.toml b/crates/program_builder/Cargo.toml deleted file mode 100644 index e076f18a..00000000 --- a/crates/program_builder/Cargo.toml +++ /dev/null @@ -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" } diff --git a/crates/uplc/Cargo.toml b/crates/uplc/Cargo.toml index e1a93b69..4a079719 100644 --- a/crates/uplc/Cargo.toml +++ b/crates/uplc/Cargo.toml @@ -18,3 +18,7 @@ hex = "0.4.3" peg = "0.8.0" pretty = "0.11.3" thiserror = "1.0.31" + +[features] +unstable = [] +test = ["unstable"] diff --git a/crates/uplc/src/lib.rs b/crates/uplc/src/lib.rs index fd3b4c31..e13a58ad 100644 --- a/crates/uplc/src/lib.rs +++ b/crates/uplc/src/lib.rs @@ -5,5 +5,5 @@ mod flat; pub mod parser; mod pretty; -#[cfg(test)] -mod test; +#[cfg(any(feature = "unstable", test))] +pub mod program_builder; diff --git a/crates/program_builder/src/lib.rs b/crates/uplc/src/program_builder.rs similarity index 97% rename from crates/program_builder/src/lib.rs rename to crates/uplc/src/program_builder.rs index c9336619..688ed3c0 100644 --- a/crates/program_builder/src/lib.rs +++ b/crates/uplc/src/program_builder.rs @@ -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; diff --git a/crates/program_builder/src/tests.rs b/crates/uplc/src/program_builder/tests.rs similarity index 97% rename from crates/program_builder/src/tests.rs rename to crates/uplc/src/program_builder/tests.rs index d2be8415..22e2acfb 100644 --- a/crates/program_builder/src/tests.rs +++ b/crates/uplc/src/program_builder/tests.rs @@ -1,5 +1,5 @@ -use crate::{Builder, WithTerm}; -use uplc::parser; +use super::*; +use crate::parser; #[test] fn build_named__with_const() { diff --git a/crates/uplc/src/test.rs b/crates/uplc/src/test.rs deleted file mode 100644 index ae5f3f1f..00000000 --- a/crates/uplc/src/test.rs +++ /dev/null @@ -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 = parsed_program.clone().try_into().unwrap(); - - let decoded_program: Program = 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 = 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 = parsed_program.clone().try_into().unwrap(); - - let decoded_program: Program = 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 = decoded_program.try_into().unwrap(); - - assert_eq!(parsed_program, name_program); - - let pretty = name_program.to_pretty(); - - assert_eq!(pretty, code); -} diff --git a/crates/uplc/tests/integ_tests.rs b/crates/uplc/tests/integ_tests.rs index e6bf60fa..753e73c0 100644 --- a/crates/uplc/tests/integ_tests.rs +++ b/crates/uplc/tests/integ_tests.rs @@ -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");