Initial Commit

This commit is contained in:
akko
2024-10-08 11:47:30 +02:00
commit 85b6b7360f
31 changed files with 2889 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
(ns emptyhead.test.idea.protocol
(:require [cljs.test :as t :include-macros true]
[emptyhead.idea.crud :as crud]
[emptyhead.idea.protocol :as prtc]
[emptyhead.test.utils :refer [expect-error]]
[emptyhead.test.fixtures :as fx]))
(t/use-fixtures :once fx/temporary-state)
(t/use-fixtures :each fx/pre-reset)
(t/deftest protocol
(t/testing "Value/reference semantics"
(let [idea (crud/have-idea!)]
;; Repeatedly going between value and reference shouldn't mangle idea
(t/is (= idea (-> idea prtc/value prtc/reference)))
(t/is (= (prtc/value idea) (-> idea prtc/reference prtc/value)))
;; Attempting to get a reference to a copy should be an error
(expect-error :stale-reference #(prtc/reference (prtc/copy idea)))
;; Attempting to get a reference to an invalid idea should be an error
(expect-error :invalid-reference #(prtc/reference {})))))