ANN: ClojureScript 0.0-2496, cljs.test - a clojure.test port

2,374 views
Skip to first unread message

David Nolen

unread,
Dec 17, 2014, 4:54:17 PM12/17/14
to clojure, clojur...@googlegroups.com
ClojureScript, the Clojure compiler that emits JavaScript source code.

README and source code: https://github.com/clojure/clojurescript

New release version: 0.0-2496

Leiningen dependency information:

[org.clojure/clojurescript "0.0-2496"]

The big change in this release is a port of the clojure.test namespace
- cljs.test.
It is largely compatible with clojure.test and implements enough
functionality such
that we could port all of the existing tests to it. It's also featureful enough
to support a ClojureScript port of test.check that is underway.
cljs.test is compatible
with all of the optimization settings provided by the compiler including :none.

Still cljs.test may not satisfy all the patterns that people have come to expect
from clojure.test so feedback (and enhancement/fix patches) is very welcome.

On the way we implemented changes to the compiler in order to make
custom testing
frameworks simpler to implement - this includes compiler support for
:test metadata as well
as introducing static vars.

ClojureScript does not have vars, however there are var patterns that
are largely
static in nature and useful for metaprogramming and REPL interactions. Towards
this end we've implemented the `var` special form and introduced very restricted
functionality - metadata is the primary use case.

(defn foo [])
(meta #'foo) ;; will return the expected metadata

cljs.test is implemented on top of this functionality as well as a new namespace
cljs.analyzer.api which I think macro writers will find quite useful.

Also there's a doc macro now in the cljs.repl namespace that works as expected.
Patches welcome to bring all the useful bits of clojure.repl into cljs.repl.

## 0.0-2496

### Enhancements
* cljs.test added, mirrors clojure.test
* New cljs.analyzer.api namespace for easier access to analysis info from macros
* New cljs.analyzer.api namespace for easier access to analysis info from macros
* Support :test metadata on vars
* Support static vars
* cljs.source-map for client side source mapping
* expose ClojureScript :warnings build option
* CLJS-909: Add stable api for consumers of compiler data.

### Changes
* convert all ClojureScript tests to cljs.test
* add volatile! from Clojure 1.7
* stateful transducers use volatile!
* added `js-debugger` macro, compiles to "debugger;"
* CLJS-892: Improve performance of compare-symbols/compare-keywords
* CLJS-696: remove arguments usage from defrecord constructor
* unroll `partial`, copy & pasted from Clojure core.clj
* optimize clojure.string/join

### Fixes
* fix `cljs.nodejs/enable-util-print!`, incorrectly monkey patched
`cjls.core/string-print` instead of setting `cljs.core/*print-fn*`
* cljs.reader bug, '/ incorrectly read
* avoid emitting the same goog.require

Mimmo Cosenza

unread,
Dec 17, 2014, 5:10:43 PM12/17/14
to clojur...@googlegroups.com, clo...@googlegroups.com
thanks so much David!
mimmo
> --
> Note that posts from new members are moderated - please be patient with your first post.
> ---
> You received this message because you are subscribed to the Google Groups "ClojureScript" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clojurescrip...@googlegroups.com.
> To post to this group, send email to clojur...@googlegroups.com.
> Visit this group at http://groups.google.com/group/clojurescript.

Dom Kiva-Meyer

unread,
Dec 17, 2014, 5:18:05 PM12/17/14
to clojur...@googlegroups.com, clojure
Thank you! This is awesome news.

Shaun LeBron

unread,
Dec 17, 2014, 5:39:32 PM12/17/14
to clojur...@googlegroups.com, clo...@googlegroups.com
really exciting stuff, thanks a lot

Nikita Beloglazov

unread,
Dec 17, 2014, 6:37:13 PM12/17/14
to clojur...@googlegroups.com, clo...@googlegroups.com
Does cljs.test support asynchronous tests? What are benefits of cljs.test over clojurescript.test (https://github.com/cemerick/clojurescript.test)? Clojurescript.test also a port of clojure.test but has additional API for writing asynchronous tests.

James MacAulay

unread,
Dec 17, 2014, 6:41:40 PM12/17/14
to clojur...@googlegroups.com, clo...@googlegroups.com
Looks great, thanks so much!

I was happy to see the "TODO: support async" comment in test.clj, as I am currently using Chas Emerick's clojurescript.test for very async-heavy stuff. I ended up writing a macro which I think improves the ergonomics of portable async testing quite a bit:

https://github.com/jamesmacaulay/zelkova/blob/32fdcecd74e5fa51a6e710625aa4e59abb6aa25e/src/cljx/jamesmacaulay/async_tools/test.cljx#L7-L16

...which is used like this:

https://github.com/jamesmacaulay/zelkova/blob/32fdcecd74e5fa51a6e710625aa4e59abb6aa25e/test/cljx/jamesmacaulay/zelkova/signal_test.cljx#L66-L82

I really like writing async tests like this; very little fuss. Maybe once cljs.test has async support, a testing macro like this could go into core.async?

Glen Mailer

unread,
Dec 18, 2014, 2:35:12 AM12/18/14
to clo...@googlegroups.com
> Also there's a doc macro now in the cljs.repl namespace that works as expected.

This is great to hear!

Excited to see test.check being on the horizon as well.

David Nolen

unread,
Dec 19, 2014, 5:50:31 PM12/19/14
to clojure, clojur...@googlegroups.com
I just cut 0.0-2498, the only change is support for
`cljs.test/use-fixtures` analogous to `clojure.test/use-fixtures`.

David

Yehonathan Sharvit

unread,
Dec 21, 2014, 4:56:36 PM12/21/14
to clojur...@googlegroups.com, clo...@googlegroups.com
Now that var is implemented. Could we expect the support of private functions in cljs?

Yehonathan Sharvit

unread,
Dec 23, 2014, 4:59:45 PM12/23/14
to clojur...@googlegroups.com, clo...@googlegroups.com
What is the gap between clojure.test and cljs.test?

For exmaple: is the `are` macro implemented in cljs.test?

On Wednesday, 17 December 2014 23:54:09 UTC+2, David Nolen wrote:

Russell Mull

unread,
Dec 24, 2014, 12:38:52 PM12/24/14
to clo...@googlegroups.com, clojur...@googlegroups.com
Things that aren't in cljs.test:
  • with-test
  • run-tests can take a custom environment parameter. Things that required rebinding a var in clj.test are configured with an entry in the environment. 
    • :reporter, instead of rebinding the report function
    • :testing-contexts instead of *testing-contexts*
    • :testing-vars instead of *testing-vars*
And that's it. It looks like a nearly complete port. 

- Russell

Yehonathan Sharvit

unread,
Dec 24, 2014, 1:13:51 PM12/24/14
to clojur...@googlegroups.com, clo...@googlegroups.com, clojur...@googlegroups.com
What about the 'are' macro?



--
Note that posts from new members are moderated - please be patient with your first post.
---
You received this message because you are subscribed to a topic in the Google Groups "ClojureScript" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojurescript/gnCl0CySSk8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojurescrip...@googlegroups.com.

Russell Mull

unread,
Dec 24, 2014, 1:17:14 PM12/24/14
to clo...@googlegroups.com, clojur...@googlegroups.com
Yes, it's there. The things I listed are the only differences I could find. The separation of macros makes it a little confusing, but it's pretty easy to find in the source:


Russell



--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@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+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/gnCl0CySSk8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

puzzler

unread,
May 8, 2015, 2:49:07 AM5/8/15
to clo...@googlegroups.com, clojur...@googlegroups.com
I can't find any documentation or examples for using the new cljs.test namespace.  Can someone point me in the right direction?  Thanks.

Matthew Boston

unread,
May 8, 2015, 8:45:58 PM5/8/15
to clo...@googlegroups.com, clojur...@googlegroups.com
Here's the commit I used when swapping cljs.test from clojurescript.test:


Note the runner.js file line 26 is calling the exported function to run all the tests.
Reply all
Reply to author
Forward
0 new messages