From b2c0d36600b2b5431a25210c627a4254509ed50c Mon Sep 17 00:00:00 2001 From: Vitaly Bogdanov Date: Mon, 25 Nov 2024 13:31:00 +0300 Subject: [PATCH 1/2] Fix FIXMEs from test MeTTa scenarious --- python/tests/scripts/c3_pln_stv.metta | 10 ++-------- python/tests/scripts/e2_states.metta | 6 ++++-- python/tests/scripts/f1_imports.metta | 8 +++++--- python/tests/scripts/f1_moduleA.metta | 6 +----- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/python/tests/scripts/c3_pln_stv.metta b/python/tests/scripts/c3_pln_stv.metta index 9e571c70f..0caf06708 100644 --- a/python/tests/scripts/c3_pln_stv.metta +++ b/python/tests/scripts/c3_pln_stv.metta @@ -56,15 +56,9 @@ (Evaluation (Predicate F) (Concept A))) (stv 0.8 1.0)) -; FIXME? `(PA)` and `(PB)` are used because otherwise -; substitution is not invoked (atm of test creation) -(= (PA) (Evaluation (Predicate P) (Concept A))) -(= (PB) (Evaluation (Predicate P) (Concept B))) -(= (FA) (Evaluation (Predicate F) (Concept A))) - ; Tests -!(assertEqual (TV (And (PA) (PB))) (stv 0.3 0.8)) -!(assertEqual (TV (FA)) (stv 0.4 0.8)) +!(assertEqual (TV (And (Evaluation (Predicate P) (Concept A)) (Evaluation (Predicate P) (Concept B)))) (stv 0.3 0.8)) +!(assertEqual (TV (Evaluation (Predicate F) (Concept A))) (stv 0.4 0.8)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/python/tests/scripts/e2_states.metta b/python/tests/scripts/e2_states.metta index 37e001b6c..1eb2dd7b1 100644 --- a/python/tests/scripts/e2_states.metta +++ b/python/tests/scripts/e2_states.metta @@ -91,5 +91,7 @@ (let $tnso (new-state 1) $tnso) (new-state 1)) -; FIXME: doesn't work as for 25 May 2023 -; !(get-state (let $x (new-state 1) $x)) +; New state atom can be instantiated just before calling get-state +!(assertEqual + (get-state (let $x (new-state 1) $x)) + 1) diff --git a/python/tests/scripts/f1_imports.metta b/python/tests/scripts/f1_imports.metta index 6f32c95db..b5c887f5d 100644 --- a/python/tests/scripts/f1_imports.metta +++ b/python/tests/scripts/f1_imports.metta @@ -41,9 +41,11 @@ (let $x (collapse (get-atoms &m)) (contains $x is-space)) True) -; FIXME? Now, it is moduleC space. -; Should it be `stdlib` atom for a separately imported space -; !(let $x (collapse (get-atoms &m)) (car-atom $x)) +; FIXME: It is the `stdlib` atom but equality check doesn't work +;!(import! &stdlib top:stdlib) +;!(assertEqual + ;(let $x (collapse (get-atoms &m)) (car-atom $x)) + ;&stdlib) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/python/tests/scripts/f1_moduleA.metta b/python/tests/scripts/f1_moduleA.metta index 51d376c69..506da96b9 100644 --- a/python/tests/scripts/f1_moduleA.metta +++ b/python/tests/scripts/f1_moduleA.metta @@ -4,12 +4,8 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; !(import! &self f1_moduleC) -; FIXME? stdlib space is not available at importing time - -; only tokens / grounded operations work, while symbolic functions -; (like `if`) don't work. -; FIXME? Exceptions are not caught by `importOp` !(assertEqual (+ 1 2) 3) -; !(assertEqual (if True "S" "F") "S") +!(assertEqual (if True "S" "F") "S") (= (dup $x) (if (== $x 0) (+ $x 10) (g $x))) From 190619e286f4f0911cd4d0ad2eb32436d1facf53 Mon Sep 17 00:00:00 2001 From: Vitaly Bogdanov Date: Mon, 25 Nov 2024 14:06:50 +0300 Subject: [PATCH 2/2] Explain why (id_atom (+ 1 1)) gets reduced to 2 --- python/tests/test_grounded_type.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/tests/test_grounded_type.py b/python/tests/test_grounded_type.py index 9c0beb012..ffeb6b346 100644 --- a/python/tests/test_grounded_type.py +++ b/python/tests/test_grounded_type.py @@ -79,7 +79,9 @@ def test_meta_types(self): myAtom untyp ''')) - # FIXME: why does it get reduced? + # FIXME: (id_atom (+ 1 1)) gets reduced because after id_atom returns + # (+ 1 1) it is evaluated further and becomes 2. We don't have a manner + # to prevent evaluation in MeTTa. # self.assertEqual(metta.run("!(id_atom (+ 1 1))"), [metta.parse_all("(+ 1 1)")]) ### Polymorphic without unwrapping # Nothing is done with `$t` on the Grounded side, but we check that: