Public Vars

Back

pos-int? (clj)

(source)

function

(pos-int? x)
Return true if x is a positive fixed precision integer

Examples

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/integer? (t/Pred t/AnyInteger)
cc/int? (t/Pred #?(:clj (t/U Long
                             Integer
                             Short
                             Byte)
                   :cljs (t/U t/CLJSInteger
                              goog.math.Integer
                              goog.math.Long)))
cc/pos-int? [t/Any :-> t/Bool
             :filters {:then (is #?(:clj (t/U Long
                                              Integer
                                              Short
                                              Byte)
                                    :cljs (t/U t/CLJSInteger
                                               goog.math.Integer
                                               goog.math.Long)) 0)}]
cc/neg-int? [t/Any :-> t/Bool
             :filters {:then (is #?(:clj (t/U Long
                                              Integer
                                              Short
                                              Byte)
                                    :cljs (t/U t/CLJSInteger
                                               goog.math.Integer
                                               goog.math.Long)) 0)}]
cc/nat-int? [t/Any :-> t/Bool
             :filters {:then (is #?(:clj (t/U Long
                                              Integer
                                              Short
                                              Byte)
                                    :cljs (t/U t/CLJSInteger
                                               goog.math.Integer
                                               goog.math.Long)) 0)}]
cc/number? (t/Pred t/Num)
cc/double? (t/Pred #?(:clj Double
                      :cljs t/Num))
cc/float? (t/Pred #?(:clj (t/U Double Float)
                     :cljs t/Num))
cc/ident? (t/Pred t/Ident)
cc/simple-ident? [t/Any :-> t/Bool :filters {:then (is t/Ident 0)}]
cc/qualified-ident? [t/Any :-> t/Bool :filters {:then (is t/Ident 0)}]
cc/simple-symbol? [t/Any :-> t/Bool :filters {:then (is t/Sym 0)}]
cc/qualified-symbol? [t/Any :-> t/Bool :filters {:then (is t/Sym 0)}]
cc/simple-keyword? [t/Any :-> t/Bool :filters {:then (is t/Kw 0)}]
cc/qualified-keyword? [t/Any :-> t/Bool :filters {:then (is t/Kw 0)}]
cc/var? (t/Pred t/AnyVar)
typedclojure/typedclojure
(ns typed-test.malli.schema-to-type
  (:require [clojure.test :refer [deftest is]]
            [malli.error :as me]
            [typed.clojure :as t]
            [typed.malli :as tm]
            [typed.malli.parse-type :as t->s]
            [typed.malli.schema-to-type :as sut]
            [typed.clj.checker.parse-unparse :as prs]
            [typed.clj.checker.subtype :as sub]
            [clojure.core.typed.type-contract :as tcon]
            [typed.clj.checker.test-utils :refer [clj is-clj subtype? both-subtype? tc-e tc-err is-tc-e is-tc-err]]
            [malli.core :as m]))

  (is (= `'[t/AnyInteger]
         (sut/malli-syntax->validator-type
           [:catn [:int :int]])))
  (is (= `[t/AnyInteger :-> t/AnyInteger]
         (sut/malli-syntax->validator-type
           [:=> [:cat :int] :int])))
  (is (= `[t/AnyInteger t/AnyInteger :-> t/AnyInteger]
         (sut/malli-syntax->validator-type
           [:=> [:cat :int :int] :int])))
  (is (= `(t/IFn [t/AnyInteger :-> t/AnyInteger]
                 [t/AnyInteger t/AnyInteger :-> t/AnyInteger])
         (sut/malli-syntax->validator-type
           [:=> [:cat :int [:? :int]] :int])))
  (is (= `[t/AnyInteger t/AnyInteger :* :-> t/AnyInteger]
         (sut/malli-syntax->validator-type
           [:=> [:cat :int [:* :int]] :int])))
  (is (= `[t/AnyInteger :-> t/AnyInteger]
         (sut/malli-syntax->validator-type
           [:=> [:catn [:foo :int]] :int])))
  (is (= `t/AnyInteger
         (sut/malli-syntax->validator-type
           'integer?)))
  (is (= `(t/Val nil)
         (sut/malli-syntax->validator-type 'nil?)
         (sut/malli-syntax->validator-type :nil)))
  (is (= `(t/HMap)
         (sut/malli-syntax->validator-type [:map])))
  (is (= `'{:a t/AnyInteger}
         (sut/malli-syntax->validator-type [:map [:a :int]])))
  (is (= `(t/HMap :optional {:a t/AnyInteger})
         (sut/malli-syntax->validator-type [:map [:a {:optional true} :int]])))
  (is (= `(t/HMap :mandatory {:b t/Bool}
                  :optional {:a t/AnyInteger})
         (sut/malli-syntax->validator-type [:map [:a {:optional true} :int]
                                            [:b :boolean]])))
  (is (thrown? clojure.lang.ExceptionInfo (m/schema [:and])))
  (is (thrown? clojure.lang.ExceptionInfo (m/schema [:or])))
  (is (= `t/AnyInteger
         (sut/malli-syntax->validator-type
           [:and
            {:title "Age"
             :description "It's an age"
             :json-schema/example 20}
            :int [:> 18]])))
  ;; FIXME refine
  (is (= `(t/U t/Num
               t/Num
               t/Num)
         (sut/malli-syntax->validator-type
           '[:or int? pos-int? neg-int?])))
  (is (thrown? clojure.lang.ExceptionInfo
               (sut/malli-syntax->validator-type '[:function])))
  (is (= `[t/Num :-> t/Num]
         (sut/malli-syntax->validator-type
           '[:function
             [:=> [:cat number?] number?]])))
  (is (= `(t/IFn [t/Num :-> t/Num]
                 [t/Num t/Num :-> t/Num])
         (sut/malli-syntax->validator-type
           '[:function
             [:=> [:cat number?] number?]
             [:=> [:cat number? number?] number?]])))
  (is (= `(t/IFn [:-> t/Num]
                 [t/Num :-> t/Num]
                 [t/Num t/Num :-> t/Num])
         (sut/malli-syntax->validator-type
           '[:function
             [:=> [:cat [:? number?]] number?]
             [:=> [:cat number? number?] number?]])))
  (is (= `(t/Vec t/Num)
         (sut/malli-syntax->validator-type
           '[:vector number?])))
  (is (= `(t/Set t/Num)
         (sut/malli-syntax->validator-type
           '[:set number?])))
  (is (= `(t/SequentialColl t/Num)
         (sut/malli-syntax->validator-type
           '[:sequential number?])))
  (is (= `(t/Nilable t/Num)
         (sut/malli-syntax->validator-type
           '[:maybe number?])))
  (is (= `(t/Nilable t/Num)
         (sut/malli-syntax->validator-type
           '[:maybe number?])))
  (is (= `t/Str
         (sut/malli-syntax->validator-type '[:re "foo"])
         (sut/malli-syntax->validator-type '[:re #"foo"])))
  (is (= `t/UUID
         (sut/malli-syntax->validator-type :uuid)))
  (is (thrown? clojure.lang.ExceptionInfo (sut/malli-syntax->validator-type :simple-keyword)))
  (is (= `t/Kw
         (sut/malli-syntax->validator-type :keyword)
         (sut/malli-syntax->validator-type 'keyword?)
         (sut/malli-syntax->validator-type 'simple-keyword?)
         (sut/malli-syntax->validator-type :qualified-keyword)
         (sut/malli-syntax->validator-type 'qualified-keyword?)))
  (is (thrown? clojure.lang.ExceptionInfo (sut/malli-syntax->validator-type :simple-symbol)))
  (is (= `t/Sym
         (sut/malli-syntax->validator-type :symbol)
         (sut/malli-syntax->validator-type 'symbol?)
         (sut/malli-syntax->validator-type 'simple-symbol?)
         (sut/malli-syntax->validator-type :qualified-symbol)
         (sut/malli-syntax->validator-type 'qualified-symbol?)))
walmartlabs/lacinia-pedestal
(ns com.walmartlabs.lacinia.pedestal.spec
  "Common specifications."
  {:added "0.10.0"}
  (:require
    com.walmartlabs.lacinia.schema                          ; for CompiledSchema
    [clojure.core.async.impl.protocols :refer [Buffer]]
    io.pedestal.interceptor                                 ; for Interceptor
    [clojure.spec.alpha :as s])
  (:import
    (com.walmartlabs.lacinia.schema CompiledSchema)
    (io.pedestal.interceptor Interceptor)))

(when (-> *clojure-version* :minor (< 9))
  (require '[clojure.future :refer [pos-int?]]))

(s/def ::buffer-or-n (s/or :buffer #(satisfies? Buffer %)
                           :n pos-int?))
Quantisan/docker-clojure
(ns docker-clojure.config
  (:require [clojure.spec.alpha :as s]
            [clojure.string :as str]
            [docker-clojure.core :as-alias core]))

(s/def ::jdk-version
  (s/and pos-int? #(<= 8 %)))
(s/def ::jdk-versions (s/coll-of ::jdk-version :distinct true :into #{}))
samply/blaze
(ns blaze.http-client-test
  (:require
   [blaze.http-client]
   [blaze.http-client.spec]
   [blaze.module.test-util :refer [with-system]]
   [blaze.test-util :as tu :refer [given-thrown]]
   [clojure.core.protocols :refer [Datafiable]]
   [clojure.datafy :refer [datafy]]
   [clojure.spec.alpha :as s]
   [clojure.spec.test.alpha :as st]
   [clojure.test :as test :refer [deftest is testing]]
   [integrant.core :as ig]
   [java-time.api :as time]
   [juxt.iota :refer [given]]
   [taoensso.timbre :as log])
  (:import
   [java.net.http HttpClient]
   [java.util Optional]))

  (testing "invalid caches"
    (given-thrown (ig/init {:blaze/http-client {:connect-timeout ::invalid}})
      :key := :blaze/http-client
      :reason := ::ig/build-failed-spec
      [:explain ::s/problems 0 :pred] := `pos-int?
      [:explain ::s/problems 0 :val] := ::invalid)))