Public Vars

Back

tagged-literal (clj)

(source)

function

(tagged-literal tag form)
Construct a data representation of a tagged literal from a tag symbol and a form.

Examples

clojure
(deftest division
  (is (= clojure.core// /))
  (binding [*ns* *ns*]
    (eval '(do (ns foo
                 (:require [clojure.core :as bar])
                 (:use [clojure.test]))
               (is (= clojure.core// bar//))))))

(deftest preserve-read-cond-test
  (let [x (read-string {:read-cond :preserve} "#?(:clj foo :cljs bar)" )]
       (is (reader-conditional? x))
       (is (not (:splicing? x)))
       (is (= :foo (get x :no-such-key :foo)))
       (is (= (:form x) '(:clj foo :cljs bar)))
       (is (= x (reader-conditional '(:clj foo :cljs bar) false))))
  (let [x (read-string {:read-cond :preserve} "#?@(:clj [foo])" )]
       (is (reader-conditional? x))
       (is (:splicing? x))
       (is (= :foo (get x :no-such-key :foo)))
       (is (= (:form x) '(:clj [foo])))
       (is (= x (reader-conditional '(:clj [foo]) true))))
  (is (thrown-with-msg? RuntimeException #"No reader function for tag"
                        (read-string {:read-cond :preserve} "#js {:x 1 :y 2}" )))
  (let [x (read-string {:read-cond :preserve} "#?(:cljs #js {:x 1 :y 2})")
        [platform tl] (:form x)]
       (is (reader-conditional? x))
       (is (tagged-literal? tl))
       (is (= 'js (:tag tl)))
       (is (= {:x 1 :y 2} (:form tl)))
       (is (= :foo (get tl :no-such-key :foo)))
       (is (= tl (tagged-literal 'js {:x 1 :y 2}))))
  (testing "print form roundtrips"
           (doseq [s ["#?(:clj foo :cljs bar)"
                      "#?(:cljs #js {:x 1, :y 2})"
                      "#?(:clj #clojure.test_clojure.reader.TestRecord [42 85])"]]
                  (is (= s (pr-str (read-string {:read-cond :preserve} s)))))))
typedclojure/typedclojure
(ns ^:no-doc typed.ann.clojure
  "Type annotations for the base Clojure distribution."
  #?(:cljs (:require-macros [typed.ann-macros.clojure :as macros]))
  (:require [clojure.core :as cc]
            [typed.clojure :as t]
            #?(:clj [typed.ann-macros.clojure :as macros])
            #?(:clj typed.ann.clojure.jvm) ;; jvm annotations
            #?(:clj clojure.core.typed))
  #?(:clj
     (:import (clojure.lang PersistentHashSet PersistentList
                            APersistentMap #_IPersistentCollection
                            #_ITransientSet
                            IRef)
              (java.util Comparator Collection))))

cc/seqable? (t/Pred t/AnySeqable)
cc/indexed? (t/Pred (t/Indexed t/Any))
cc/inst-ms [:-> t/Int]
cc/inst? (t/Pred cc/Inst)
cc/uuid? (t/Pred t/UUID)
cc/random-uuid [:-> t/UUID]
cc/parse-uuid [t/Str :-> (t/Option t/UUID)]
cc/uri? (t/Pred t/URI)
cc/tagged-literal? (t/Pred clojure.lang.TaggedLiteral)
cc/reader-conditional? (t/Pred clojure.lang.ReaderConditional)

cc/tagged-literal [t/Sym t/Any :-> clojure.lang.TaggedLiteral]
cc/reader-conditional [t/Any t/Bool :-> clojure.lang.ReaderConditional]
mauricioszabo/repl-tooling
(ns repl-tooling.repl-client.parsing-test
  (:require [clojure.test :refer [async testing is]]
            [check.core :refer [check]]
            [clojure.core.async :as async]
            [devcards.core :as cards :include-macros true]
            [repl-tooling.eval :as eval]
            [repl-tooling.editor-helpers :as helpers]
            [repl-tooling.eval-helpers :refer [eval-on-repl eval-and-parse
                                                      async-with-clj-repl]]
            [repl-tooling.repl-client.clojure :as clj]))

       (testing "no ellisions on taggable code"
         (let [code  "(tagged-literal 'foo/bar \"Baz\")"
               not-ellided (:result (eval-and-parse code))]
           (check (eval/get-more-fn not-ellided) => nil)))