Skip to content

Commit

Permalink
Add tests for atomic skeletons
Browse files Browse the repository at this point in the history
  • Loading branch information
sunsided committed May 19, 2024
1 parent 1b19e59 commit 0f44b2a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
22 changes: 22 additions & 0 deletions src/parsers/atomic_formula_skeleton.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,25 @@ impl crate::parsers::Parser for AtomicFormulaSkeleton {
parse_atomic_formula_skeleton(input)
}
}

#[cfg(test)]
mod tests {
use crate::{AtomicFormulaSkeleton, Parser, Predicate, Variable};
use crate::{ToTyped, TypedList};

#[test]
fn test_parse() {
let (_, value) = AtomicFormulaSkeleton::parse("(at ?x - physob ?y - location)").unwrap();

assert_eq!(
value,
AtomicFormulaSkeleton::new(
Predicate::from("at"),
TypedList::from_iter([
Variable::from("x").to_typed("physob"),
Variable::from("y").to_typed("location")
])
)
);
}
}
21 changes: 19 additions & 2 deletions src/parsers/atomic_function_skeleton.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ impl crate::parsers::Parser for AtomicFunctionSkeleton {
///
/// ## Example
/// ```
/// # use pddl::parsers::{parse_atomic_function_skeleton, Span, UnwrapValue};
/// # use pddl::{Variable, AtomicFunctionSkeleton, Predicate, FunctionSymbol, Parser};
/// # use pddl::{Variable, AtomicFunctionSkeleton, FunctionSymbol, Parser};
/// # use pddl::{ToTyped, TypedList};
/// let (_, value) = AtomicFunctionSkeleton::parse("(battery-amount ?r - rover)").unwrap();
///
Expand All @@ -60,3 +59,21 @@ impl crate::parsers::Parser for AtomicFunctionSkeleton {
parse_atomic_function_skeleton(input)
}
}

#[cfg(test)]
mod tests {
use crate::{AtomicFunctionSkeleton, FunctionSymbol, Parser, Variable};
use crate::{ToTyped, TypedList};

#[test]
fn test_parse() {
let (_, value) = AtomicFunctionSkeleton::parse("(battery-amount ?r - rover)").unwrap();
assert_eq!(
value,
AtomicFunctionSkeleton::new(
FunctionSymbol::from("battery-amount"),
TypedList::from_iter([Variable::from("r").to_typed("rover")])
)
);
}
}

0 comments on commit 0f44b2a

Please sign in to comment.