Browse files

MATCH-67: CLJS support regression

syntax for try/catch in ClojureScript chagned to match clojure. We can
no longer catch 0 since `0 instanceof Number` is false in
JavaScript. We now catch a preallocated Error just like we do in
Clojure proper. Users must now include `clojure.core.match` namespace as
well as requiring the macros files.

Started adding tests so we can notice ClojureScript regression sooner.
  • Loading branch information...
1 parent 68709c4 commit 3bab92b6620dccdcb9e55941af4599e3adf78a6e @swannodette swannodette committed Feb 15, 2013
View
6 project.clj
@@ -11,19 +11,19 @@
:dependencies [[org.clojure/clojure "1.4.0"]
[org.clojure/clojurescript "0.0-1576"]]
- :dev-dependencies [[nrepl "0.2.1"]]
+ :dev-dependencies [[org.clojure/tools.nrepl "0.2.1"]]
:plugins [[lein-cljsbuild "0.3.0"]]
:cljsbuild
{:builds
[{:id "test"
:source-paths ["src/test/cljs"]
- :compiler {:output-js "test.js"
+ :compiler {:output-to "test.js"
:pretty-print true
:static-fns true
:optimizations :simple}}
{:id "test-adv"
:source-paths ["src/test/cljs"]
- :compiler {:output-js "test-adv.js"
+ :compiler {:output-to "test-adv.js"
:pretty-print true
:optimizations :advanced}}]})
View
6 src/main/clojure/clojure/core/match.clj
@@ -79,7 +79,7 @@
(defn backtrack-expr []
(if *clojurescript*
- `(throw 0)
+ `(throw clojure.core.match/backtrack)
`(throw clojure.core.match/backtrack)))
(defn warn [msg]
@@ -439,8 +439,8 @@
(defn catch-error [& body]
(if *clojurescript*
- `(catch e#
- (if (identical? e# 0)
+ `(catch js/Error e#
+ (if (identical? e# clojure.core.match/backtrack)
(do
~@body)
(throw e#)))
View
3 src/main/clojure/clojure/core/match.cljs
@@ -0,0 +1,3 @@
+(ns clojure.core.match)
+
+(def backtrack (js/Error.))
View
3 src/test/cljs/clojure/core/match/js/tests.cljs
@@ -1,5 +1,6 @@
(ns clojure.core.match.js.tests
- (:use-macros [clojure.core.match.js :only [match]]))
+ (:use-macros [clojure.core.match.js :only [match]])
+ (:require [clojure.core.match]))
(defn js-print [& args]
(if (js* "typeof console != 'undefined'")

0 comments on commit 3bab92b

Please sign in to comment.