I'm having some trouble attempting to use interop with ClojureScript.
I'm trying to translate examples from the Closure book into
ClojureScript, and I keep getting stuck on various things.

1) When using goog.testing, it appears that I can't access
goog.testing.TestRunner and goog.testing.TestCase unless those
specific namespaces are imported as well.  For example:

(ns example.core
  (:require [goog.testing :as testing]))

(defn ^:export start-test []
  testing/TestCase))

If i call start_test() from the browser repl it returns null. If I add
[goog.testing.TestCase :as tc] to the requires, without changing
start-test, then the code works fine.

2) Trying to launch the TestRunner fails if i do it in a function, but
works if I return the runner and call it from the browser.

(defn ^:export start-test []
  (let [runner (testing/TestRunner.)
        test (testing/TestCase. "foo")]
    (.add test (tc/Test. "test-html-escaping"
                         test-html-escaping
                         goog.global))
    (.initialize runner test)
    ((.execute runner))))

This will throw an exception that the TestRunner is not initialized.
However, if I change ((.execute runner)) to runner, then call
"start_test().execute()" it runs perfectly.  I can only guess that the
this object is not getting set correctly for some reason.

Note that changing the last line to (. runner (execute)) also works.

3) Is there some way to export a symbol to be global? For example,
goog.testing.jsunit will automatically search the global namespace for
test functions, but I can't figure out (aside from js*) how to stick
something in there.  I basically created start-test above to get
around this.

jack.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to