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

Investigate non-compile-time sessions in ClojureScript in tests #292

Closed
WilliamParker opened this issue May 10, 2017 · 2 comments
Closed

Comments

@WilliamParker
Copy link
Collaborator

A pull request was submitted in relation to issue 285 to add tests validating that salience works in ClojureScript. In this PR, there was this usage of defsession:

(deftest test-salience ......
    (defsession test-salience-session 'clara.test-salience
                     :cache false
                     :activation-group-sort-fn (condp = sort-fn
                                                 :default-sort nil
                                                 :numeric-greatest-sort numeric-greatest-sort
                                                 :numeric-least-sort numeric-least-sort
                                                 :boolean-greatest-sort  >
                                                 :boolean-least-sort <)
                     :activation-group-fn (condp = group-fn
                                            :default-group nil
                                            :salience-group salience-group-fn
                                            :neg-salience-group neg-salience-group-fn))

The point of having defsession in ClojureScript is that due to the lack of eval in ClojureScript, which is used heavily by mk-session we can't generate sessions at runtime in ClojureScript as we can in Clojure. However, because the rule sources work at compile time and only the options needed to fall through to runtime evaluation, and the defsession macro was organized in a way that inadvertently facilitated this, this actually worked.

I didn't want to derail adding the tests with this larger issue, but I'd like to consider a couple options here. This was also discussed in a comment on the PR at #288 (comment).

  • Should we create a macro that doesn't create a definition for the session? Basically it would just be a macro that has this same behavior, but intentionally. If we add this, should it be for internal test use only or a public API?
  • There has been some work to add eval to ClojureScript; perhaps this is mature enough that we could use it in Clara's tests.
  • Other options to consider?
@alex-dixon
Copy link
Contributor

@WilliamParker Should this be closed?

@WilliamParker
Copy link
Collaborator Author

Yes, I don't see anything left to do here after the changes for #296, closing.

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

2 participants