Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert documented examples of predicate-arity and function-arity usage into assertEqualToResult-based unit tests #220

Open
TeamSPoon opened this issue Dec 11, 2024 · 0 comments

Comments

@TeamSPoon
Copy link
Collaborator

We have a series of documented examples showing how predicate-arity and function-arity are used. We’d like to convert these examples into automated unit tests that use the !(assertEqualToResult ...) form to verify outputs against expected results. This will help ensure that future changes do not break the documented behaviors.

Examples to Convert:

Are found at https://github.com/trueagi-io/metta-wam/blob/master/prolog/metta_lang/stdlib_mettalog.metta#L100-L165

  1. Testing size-atom as a predicate:

    (predicate-arity size-atom 2)
    
    ; Using `size-atom` forward:
    !(assertEqualToResult
        (match &dyn-space '(size-atom (a b c) $size) (The abc tuple was len $size))
        ((The abc tuple was len 3)))
    
    ; Using `size-atom` in reverse (deduce a 4-element atom from size=4):
    !(assertEqualToResult
        (match &self (size-atom $new-atom 4) (The new atom is $new-atom))
        ((The new atom is ($1 $2 $3 $4))))
        
        etc

What We Need:

  • For each documented scenario, write a corresponding unit test that:

    • Sets up any required arities or definitions.
    • Executes the provided logic using the !(assertEqualToResult ...) form.
    • Checks that the output matches the documented expected results.
  • Ensure that the tests are stable. If a result might vary depending on internal logic, consider adjusting the test or using a known stable output scenario.

Why This Is Important:

  • It provides automated verification of behaviors described in the documentation.
  • Ensures that future changes won’t unintentionally break these functionalities.
  • Makes the documented behaviors both demonstrable and testable.

Acceptance Criteria:

  • Each provided example is converted into at least one unit test.
  • The tests run and pass with the current code.
  • The expected results are explicitly defined so that any regressions can be quickly caught.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant