File tree Expand file tree Collapse file tree 4 files changed +45
-6
lines changed
Expand file tree Collapse file tree 4 files changed +45
-6
lines changed Original file line number Diff line number Diff line change 364364; ; File, Line, and Column Helpers
365365
366366(defn js-line-and-column [stack-element]
367+ " Returns a 2-element vector containing the line and
368+ column encoded at the end of a stack element string.
369+ A line or column will be represented as NaN if not
370+ parsesable."
367371 (let [parts (.split stack-element " :" )
368372 cnt (count parts)]
369- [(js/parseInt (nth parts (- cnt 2 )) 10 )
370- (js/parseInt (nth parts (dec cnt)) 10 )]))
373+ (if (> cnt 1 )
374+ [(js/parseInt (nth parts (- cnt 2 )) 10 )
375+ (js/parseInt (nth parts (dec cnt)) 10 )]
376+ [NaN NaN])))
371377
372378(defn js-filename [stack-element]
373379 (first (.split (last (.split stack-element " /out/" )) " :" )))
Original file line number Diff line number Diff line change 1+ (ns cljs.test-test
2+ (:require [cljs.test :refer-macros [deftest testing is] :as ct]
3+ [clojure.string :as s]
4+ [clojure.set :as set]))
5+
6+ (defn- nan?
7+ [x]
8+ (and (number? x)
9+ (js/isNaN x)))
10+
11+ (deftest js-line-and-column-test
12+ (is (= [2 3 ] (ct/js-line-and-column " foo:bar:2:3" )))
13+ (is (= [2 3 ] (ct/js-line-and-column " foo:2:3" )))
14+ (is (= [2 3 ] (ct/js-line-and-column " 2:3" )))
15+ (let [[line column] (ct/js-line-and-column " foo:bogus:3" )]
16+ (is (nan? line))
17+ (is (== 3 column)))
18+ (let [[line column] (ct/js-line-and-column " foo:2:bogus" )]
19+ (is (== 2 line))
20+ (is (nan? column)))
21+ (let [[line column] (ct/js-line-and-column " foo:bogus:bogus" )]
22+ (is (nan? line))
23+ (is (nan? column)))
24+ (let [[line column] (ct/js-line-and-column " foo:3" )]
25+ (is (nan? line))
26+ (is (== 3 column)))
27+ (let [[line column] (ct/js-line-and-column " foo" )]
28+ (is (nan? line))
29+ (is (nan? column))))
Original file line number Diff line number Diff line change 3838 [cljs.clojure-alias-test]
3939 [cljs.hash-map-test]
4040 [cljs.predicates-test]
41- [cljs.tagged-literals-test]))
41+ [cljs.tagged-literals-test]
42+ [cljs.test-test]))
4243
4344(set! *print-newline* false )
4445(set-print-fn! js/print)
7475 'cljs.pprint-test
7576 'cljs.predicates-test
7677 'cljs.syntax-quote-test
77- 'cljs.tagged-literals-test)
78+ 'cljs.tagged-literals-test
79+ 'cljs.test-test)
Original file line number Diff line number Diff line change 280280 [cljs.clojure-alias-test]
281281 [cljs.hash-map-test]
282282 [cljs.syntax-quote-test]
283- [cljs.predicates-test]))
283+ [cljs.predicates-test]
284+ [cljs.test-test]))
284285 (fn [{:keys [value error]}]
285286 (if error
286287 (prn error)
315316 'cljs.clojure-alias-test
316317 'cljs.hash-map-test
317318 'cljs.syntax-quote-test
318- 'cljs.predicates-test)
319+ 'cljs.predicates-test
320+ 'cljs.test-test)
319321 (fn [{:keys [value error]}]
320322 (when error
321323 (prn error)))))))))
You can’t perform that action at this time.
0 commit comments