Skip to content

Commit

Permalink
test: CLIPS EXTERNAL_ADDRESS type support tests
Browse files Browse the repository at this point in the history
Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
  • Loading branch information
noxdafox committed Feb 6, 2022
1 parent 194b8bf commit 4043f52
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/environment_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ def python_types():
return None, True, False


def python_objects(obj):
return obj


def python_error():
raise Exception("BOOM!")

Expand All @@ -56,6 +60,11 @@ def __exit__(self, *_):
os.remove(self.name)


class ObjectTest:
def __init__(self, value):
self.value = value


class TestEnvironment(unittest.TestCase):
def setUp(self):
self.values = []
Expand All @@ -66,6 +75,7 @@ def setUp(self):
name='python-function-renamed')
self.env.define_function(python_error)
self.env.define_function(python_types)
self.env.define_function(python_objects)
self.env.define_function(self.python_method)
self.env.define_function(self.python_fact_method)
self.env.build(DEFCLASS)
Expand Down Expand Up @@ -118,6 +128,14 @@ def test_eval_python_method(self):
self.assertEqual(ret, Symbol('nil'))
self.assertEqual(self.values, expected)

def test_call_python_object(self):
"""Python objects are correctly marshalled."""
test_object = ObjectTest(42)

ret = self.env.call('python_objects', test_object)

self.assertEqual(ret, test_object)

def test_rule_python_fact(self):
"""Facts are forwarded to Python """
fact = self.env.assert_string('(test-fact)')
Expand Down

0 comments on commit 4043f52

Please sign in to comment.