Skip to content

Commit

Permalink
Merge pull request #268 from vsbogd/various-fixes
Browse files Browse the repository at this point in the history
Fixing typos and adding unit test
  • Loading branch information
vsbogd authored Apr 7, 2023
2 parents 980d693 + bcda7af commit 10758f5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/src/metta/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//! * [Atom::Variable] is returned as is.
//! * [Atom::Symbol] and [Atom::Grounded] are type checked; each applicable
//! type of the atom is checked vs expected type:
//! * If type is corrent then atom is returned as is.
//! * If type is correct then atom is returned as is.
//! * If type is incorrect then error result is returned.
//! * Note: cast may return as many results as many types were casted
//! successfully, each result may have its own variable bindings if
Expand Down Expand Up @@ -51,7 +51,7 @@
//! * If result is not empty plan to interpret each alternative further is
//! returned. Note: if each alternative returns error then the result
//! of execution is also error.
//! * If one of previous steps returned error then original expresion is
//! * If one of previous steps returned error then original expression is
//! returned. Otherwise the result of the interpretation is returned.
//! It may be empty if one of expression is grounded expression which
//! returns empty result.
Expand All @@ -61,8 +61,8 @@
//! returns empty result, or one of the arguments returned empty result
//! * error is returned when atom cannot be casted to the type expected
//! or all alternative interpretations are errors; the overall result includes
//! successfuly interpreted alternatives only
//! * call of the expression returns either succesful result or original expression
//! successfully interpreted alternatives only
//! * call of the expression returns either successful result or original expression
use crate::*;
use crate::common::plan::*;
Expand Down
15 changes: 15 additions & 0 deletions lib/src/metta/runner/stdlib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1379,6 +1379,21 @@ mod tests {
vec![sym!("B"), sym!("C")]);
}

#[test]
fn get_type_op_non_valid_atom() {
let space = Shared::new(metta_space("
(: f (-> Number String))
(: 42 Number)
(: \"test\" String)
"));

let get_type_op = GetTypeOp::new(space);
assert_eq_no_order!(get_type_op.execute(&mut vec![expr!("f" "42")]).unwrap(),
vec![sym!("String")]);
assert_eq_no_order!(get_type_op.execute(&mut vec![expr!("f" "\"test\"")]).unwrap(),
Vec::<Atom>::new());
}

#[test]
fn println_op() {
assert_eq!(PrintlnOp{}.execute(&mut vec![sym!("A")]), Ok(vec![]));
Expand Down

0 comments on commit 10758f5

Please sign in to comment.