Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
behrica committed May 11, 2024
1 parent 8d38dc0 commit 09d129f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 20 deletions.
3 changes: 2 additions & 1 deletion src/clojisr/v1/require.clj
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@
this-ns-symbol
(if (= refer :all)
r-symbols
(select-keys r-symbols refer)))))))
(select-keys r-symbols refer))
load-help?)))))
(catch Exception e
(log/warn [::require-r-package {:package-symbol package-symbol
:cause (exception-cause e)}])
Expand Down
24 changes: 6 additions & 18 deletions test/clojisr/v1/help_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,28 @@
[clojure.test :refer [is deftest]]
[clojisr.v1.r :as r]))

(reset! clojisr.v1.require/attach-help-as-docstring-to-vars true)
(r/require-r '[randomForest])



(deftest help-with-docstring
(reset! clojisr.v1.require/attach-help-as-docstring-to-vars true)
(deftest help-docstring
(r/require-r '[randomForest])
(Thread/sleep 10000)
(is (str/starts-with?
(:doc (meta (var r.randomForest/randomForest)))
"Classification and Regression with Random Forest"))
(reset! clojisr.v1.require/attach-help-as-docstring-to-vars false))


(deftest help-without-doctrsing
(reset! clojisr.v1.require/attach-help-as-docstring-to-vars false)
(r/require-r '[randomForest])
(is (nil?
(:doc (meta (var r.randomForest/randomForest))))
))

"Classification and Regression with Random Forest")))

(deftest help-function
(is (str/starts-with?
(r/help "randomForest" "randomForest")
"Classification and Regression with Random Forest")))

(deftest require-defauls-should-not-throws-exception
(reset! clojisr.v1.require/attach-help-as-docstring-to-vars true)

; should not crash
(r/require-r '[base])
(r/require-r '[stats])
(r/require-r '[utils])
(r/require-r '[graphics])
(r/require-r '[datasets])
(reset! clojisr.v1.require/attach-help-as-docstring-to-vars false)

)

2 changes: 1 addition & 1 deletion test/clojisr/v1/tutorials/main_generated_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@
(md
"As we saw earlier, R functions are Clojure functions. The arglists of functions brought up by `require-r` match the expected arguments. Here are some examples:"))

(reset! clojisr.v1.require/attach-help-as-docstring-to-vars false)

(def var251 (require-r '[base] '[stats] '[grDevices]))

(def
Expand Down

0 comments on commit 09d129f

Please sign in to comment.