Back
renumbering-read (clj)
(source)function
(renumbering-read opts reader line-number)
Reads from reader, which must be a LineNumberingPushbackReader, while capturing
the read string. If the read is successful, reset the line number and re-read.
The line number on re-read is the passed line-number unless :line or
:clojure.core/eval-file meta are explicitly set on the read value.
Examples
clojure
(ns clojure.test-clojure.main
(:use clojure.test
[clojure.test-helper :only [platform-newlines]])
(:require [clojure.main :as main]))
(deftest renumbering-read
(are [s line-in line-out]
(= line-out (-> (main/renumbering-read nil (s->lpr s) line-in) meta :line))
"(let [x 1] x)" 100 100
"^{:line 20 :clojure.core/eval-file \"a/b.clj\"} (let [x 1] x)" 100 20
"^{:line 20} (let [x 1] x)" 100 20))