Back

Deferred (clj)

(source)

record

Examples

aero
(ns aero.core-test
  (:require
   [aero.core :refer [read-config reader
                      #?@(:clj [deferred resource-resolver root-resolver])
                      #?(:cljs Deferred)]
    #?@(:cljs [:refer-macros [deferred]])]
   [clojure.test :refer [deftest is testing are]]
   #?@(:clj [[clojure.java.io :as io]]
       :cljs [[goog.object :as gobj]
              [goog.string :as gstring]
              goog.string.format
              [cljs.tools.reader.reader-types
               :refer [source-logging-push-back-reader]]]))
  #?(:clj (:import [aero.core Deferred])))

(deftest deferred-test
  (is
   (instance? Deferred (deferred (+ 2 2))))
  ;; The basic idea here is to ensure that the #expensive-network-call
  ;; tag literal is called (because it increments its value). This
  ;; also tests the Deferred functionality as a consequence.
  (let [config (read-config "test/aero/config.edn")]
    (is (= (get-in config [:network-call])
           8))))