Skip to content

Instantly share code, notes, and snippets.

@nickmain
Created November 1, 2013 18:14
Show Gist options
  • Save nickmain/7269478 to your computer and use it in GitHub Desktop.
Save nickmain/7269478 to your computer and use it in GitHub Desktop.
How can a meaningful unit test be written for this CLIPS rule ? The rule is declarative - it states the preconditions that must exist and is explicit about what the post-conditions are (the asserted facts). How can a unit test add value to this and not be merely a test that CLIPS itself actually works ?
(defrule make-group
(make-graphic ?sheet ?id)
(dict-entry ?id Class "Group")
(not (dict-entry ?id isSubgraph ?))
(dict-entry ?id Graphics ?array)
(array ?array $?graphics)
=>
(assert (group ?id))
(foreach ?graphic $?graphics
(assert (make-graphic ?sheet ?graphic))
(assert (graphic-parent ?id ?graphic))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment