-
Notifications
You must be signed in to change notification settings - Fork 780
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CLJS-1367: Better api call arguments
This change adds additional arity for api calls which need compiler-env. Old arities continue to use the dynamic var. Also, api calls which take options map as argument, now use :warning-handlers options to set value for dynamic var cljs.analyzer/*cljs-warning-handlers*.
- Loading branch information
Showing
5 changed files
with
153 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
(ns cljs.analyzer-api-tests | ||
(:require [cljs.analyzer.api :as ana-api]) | ||
(:use clojure.test)) | ||
|
||
(def warning-form | ||
'(do (defn x [a b] (+ a b)) | ||
(x 1 2 3 4))) | ||
|
||
(defn warning-handler [counter] | ||
(fn [warning-type env extra] | ||
(when (ana-api/warning-enabled? warning-type) | ||
(swap! counter inc)))) | ||
|
||
(def test-cenv (atom {})) | ||
(def test-env (ana-api/empty-env)) | ||
|
||
(deftest with-warning-handlers-test | ||
(let [counter (atom 0)] | ||
(ana-api/analyze test-cenv test-env warning-form nil | ||
{:warning-handlers [(warning-handler counter)]}) | ||
(is (= 1 @counter)))) | ||
|
||
(deftest vary-warning-handlers-test | ||
(let [counter (atom 0)] | ||
(cljs.analyzer/all-warn | ||
(ana-api/analyze test-cenv test-env warning-form nil | ||
{:warning-handlers [(warning-handler counter)]})) | ||
(is (= 1 @counter)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters