Back

precedes? (clj)

(source)

function

(precedes? x y)

Examples

tick
(ns tick.alpha.interval-test
  (:require
   [clojure.spec.alpha :as s]
   [tick.core :as t]
   [tick.protocols :as p]
   [clojure.test
    :refer [deftest is testing run-tests]
    :refer-macros [deftest is testing run-tests]]
   [tick.alpha.interval :as ti]
   #?@(:cljs [[java.time :refer [Instant LocalDateTime LocalTime]]]))
  #?(:clj
     (:import [java.time LocalDateTime Instant LocalTime])))


(deftest disjoint-test []
  (is (ti/disjoint?
        (ti/new-interval (instants 0) (instants 1))
        (ti/new-interval (instants 2) (instants 3))))
  (is (= (ti/disjoint?
           (ti/new-interval (instants 0) (instants 1))
           (ti/new-interval (instants 2) (instants 3))) ti/precedes?))
  (is (nil?
        (ti/disjoint?
          (ti/new-interval (instants 0) (instants 2))
          (ti/new-interval (instants 1) (instants 3)))))
  (is (nil?
        (ti/disjoint?
          (ti/new-interval (instants 0) (instants 3))
          (ti/new-interval (instants 1) (instants 2))))))