Public Vars

Back

false? (clj)

(source)

function

(false? x)
Returns true if x is the value false, false otherwise.

Examples

originrose/cortex
(ns cortex.optimise.util-test
  (:refer-clojure :exclude [defonce])
  (:require [cortex.optimise.util :refer :all]
            [clojure.core.matrix :as m]
            [clojure.test :refer :all]))

(deftest seq-like?-test
  (is (false? (seq-like? nil)))
  (is (false? (seq-like? "Hello")))
  (is (false? (seq-like? 5)))
  (is (true? (seq-like? (range 5))))
  (is (true? (seq-like? [:a :b :c])))
  (is (true? (seq-like? {:a 1 :b 2})))
  (is (true? (seq-like? (m/array :vectorz [1 2 3]))))
  (is (true? (seq-like? (m/array :vectorz [[1 2] [3 4]])))))

(deftest approx=-test
  (testing "comparing floats"
    (is (false? (approx= 0.1 10 11)))
    (is (false? (approx= 0.1 10 11.0)))
    (is (true? (approx= 0.1 10.0 11.0)))
    (is (false? (approx= 0.09 10.0 11.0))))
  (testing "comparing more than two floats"
    (is (false? (approx= 0.1 10.0 10.75 11.5)))
    (is (true? (approx= 0.1 10.0 10.5 11.0))))
  (testing "comparing vectors"
    (is (false? (approx= 0.1
                         (m/array :vectorz [10.0 11.0])
                         [11.5 10.0])))
    (is (true? (approx= 0.1
                        (m/array :vectorz [10.0 11.0])
                        [11.0 10.0]))))
  (testing "comparing nested data structures"
    (is (false? (approx= 0.1
                         {:a [10.0 11.0] :b 10.0}
                         {:a [11.0 10.0] :c 10.0})))
    (is (false? (approx= 0.1
                         {:a [10.0 11.0] :b 10.0}
                         {:a [12.0 10.0] :b 10.0})))
    (is (true? (approx= 0.1
                        {:a [10.0 11.0] :b 10.0}
                        {:a [11.0 10.0] :b 10.0}))))
  (testing "lists of different lengths"
    (is (false? (approx= 0.1
                         [1.0 2.0 3.0]
                         [1.0 2.0])))))
originrose/cortex
(ns cortex.util-test
  (:refer-clojure :exclude [defonce])
  (:require
    #?(:cljs [cljs.test :refer-macros [deftest is testing]]
       :clj [clojure.test :refer [deftest is testing]])
    [clojure.core.matrix :as m]
    [clojure.string :as str]
    [cortex.util :refer :all]))

(deftest seq-like?-test
  (is (false? (seq-like? nil)))
  (is (false? (seq-like? "Hello")))
  (is (false? (seq-like? 5)))
  (is (true? (seq-like? (range 5))))
  (is (true? (seq-like? [:a :b :c])))
  (is (true? (seq-like? {:a 1 :b 2})))
  (is (true? (seq-like? (m/array :vectorz [1 2 3]))))
  (is (true? (seq-like? (m/array :vectorz [[1 2] [3 4]])))))

(deftest approx=-test
  (testing "comparing floats"
    (is (false? (approx= 0.1 10 11)))
    (is (false? (approx= 0.1 10 11.0)))
    (is (true? (approx= 0.1 10.0 11.0)))
    (is (false? (approx= 0.09 10.0 11.0))))
  (testing "comparing more than two floats"
    (is (false? (approx= 0.1 10.0 10.75 11.5)))
    (is (true? (approx= 0.1 10.0 10.5 11.0))))
  (testing "comparing vectors"
    (is (false? (approx= 0.1
                         (m/array :vectorz [10.0 11.0])
                         [11.5 10.0])))
    (is (true? (approx= 0.1
                        (m/array :vectorz [10.0 11.0])
                        [11.0 10.0]))))
  (testing "comparing nested data structures"
    (is (false? (approx= 0.1
                         {:a [10.0 11.0] :b 10.0}
                         {:a [11.0 10.0] :c 10.0})))
    (is (false? (approx= 0.1
                         {:a [10.0 11.0] :b 10.0}
                         {:a [12.0 10.0] :b 10.0})))
    (is (true? (approx= 0.1
                        {:a [10.0 11.0] :b 10.0}
                        {:a [11.0 10.0] :b 10.0}))))
  (testing "lists of different lengths"
    (is (false? (approx= 0.1
                         [1.0 2.0 3.0]
                         [1.0 2.0])))))
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/seq? (t/Pred (t/Seq t/Any))
cc/set? (t/Pred (t/Set t/Any))
cc/vector? (t/Pred (t/Vec t/Any))
cc/nil? (t/Pred nil)
#?@(:cljs [
cc/undefined? (t/Pred t/JSundefined)
])
cc/false? (t/Pred false)
cc/true? (t/Pred true)
cc/symbol? (t/Pred t/Sym)
cc/keyword? (t/Pred t/Keyword)
cc/map? (t/Pred (t/Map t/Any t/Any))
cc/boolean? (t/Pred t/Bool)
cc/any? [t/Any :-> true]
cc/record? (t/Pred #?(:clj clojure.lang.IRecord
                      :cljs cljs.core/IRecord))
brianium/clean-todos
(ns todos.core.use-case.update-todo-test
  (:require [clojure.test :refer :all]
            [clojure.core.async :as async]
            [yoose.core :as yoose]
            [todos.core.entity.todo :as todo]
            [todos.core.entity :as entity]
            [todos.core.action :as action]
            [todos.core.use-case.update-todo :as ut]
            [todos.storage.todo.collection :refer [make-storage]]
            [todos.test :refer [test-async]]))


(deftest test-update-todo
  (let [in           (async/chan)
        out          (async/chan)
        updating     (todo/make-todo "Not in collection")
        storage      (make-storage #{updating})
        use-case     (ut/update-todo in out {:storage storage})]
    (yoose/push! use-case [(::entity/id updating) updating])
    (test-async
      (async/go (yoose/pull! use-case
                  (fn [{:keys [::action/error?]}]
                    (is (false? error?))))))))
brianium/clean-todos
(ns todos.core.use-case.delete-todo-test
  (:require [clojure.test :refer :all]
            [clojure.core.async :refer [chan go]]
            [yoose.core :as yoose]
            [todos.core.entity.todo :as todo]
            [todos.core.entity :as e]
            [todos.core.action :as action]
            [todos.storage.todo.collection :refer [make-storage]]
            [todos.core.use-case.delete-todo :as dt]
            [todos.test :refer [test-async]]))


(deftest test-deleting-a-non-existent-todo
  (let [in           (chan)
        out          (chan)
        use-case     (dt/delete-todo in out {:storage (make-storage)})]
    (yoose/push! use-case (e/make-uuid))
    (test-async
      (go (yoose/pull! use-case
            (fn [{{:keys [result]} ::action/payload}]
              (is (false? result))))))))