diff -Nru core-memoize-clojure-0.7.1/CONTRIBUTING.md core-memoize-clojure-1.0.257/CONTRIBUTING.md --- core-memoize-clojure-0.7.1/CONTRIBUTING.md 2018-03-02 21:35:58.000000000 +0000 +++ core-memoize-clojure-1.0.257/CONTRIBUTING.md 2022-02-11 22:56:55.000000000 +0000 @@ -3,12 +3,10 @@ Under the Clojure contrib [guidelines], this project cannot accept pull requests. All patches must be submitted via [JIRA]. -See [Contributing] and the [FAQ] on the Clojure development [wiki] for +See [Contributing] on the Clojure website for more information on how to contribute. -[Clojure contrib]: http://dev.clojure.org/display/doc/Clojure+Contrib -[Contributing]: http://dev.clojure.org/display/community/Contributing -[FAQ]: http://dev.clojure.org/display/community/Contributing+FAQ -[JIRA]: http://dev.clojure.org/jira/browse/CMEMOIZE -[guidelines]: http://dev.clojure.org/display/community/Guidelines+for+Clojure+Contrib+committers -[wiki]: http://dev.clojure.org/ +[Clojure contrib]: https://clojure.org/community/contrib_libs +[Contributing]: https://clojure.org/community/contributing +[JIRA]: http://clojure.atlassian.net/browse/CMEMOIZE +[guidelines]: https://clojure.org/community/contrib_howto diff -Nru core-memoize-clojure-0.7.1/debian/changelog core-memoize-clojure-1.0.257/debian/changelog --- core-memoize-clojure-0.7.1/debian/changelog 2020-11-05 10:49:56.000000000 +0000 +++ core-memoize-clojure-1.0.257/debian/changelog 2022-10-25 03:08:25.000000000 +0000 @@ -1,3 +1,26 @@ +core-memoize-clojure (1.0.257-1) unstable; urgency=medium + + * Team upload. + + [ Louis-Philippe Véronneau ] + * d/control: New email for the Clojure Team. + + [ Jérôme Charaoui ] + * New upstream version 1.0.257 + * d/control: + + add Rules-Requires-Root field + + bump dh-compat to 13 + + bump Standards-Version, no changes needed + * d/docs: ship upstream README + * d/gbp.conf: add config with clojure team defaults + * d/rules: actually run build tests + * d/rules: drop converting markdown to html + * d/tests: add autopkgtests + * d/upstream: add upstream metadata + * d/watch: switch to git mode + + -- Jérôme Charaoui Mon, 24 Oct 2022 23:08:25 -0400 + core-memoize-clojure (0.7.1-1) unstable; urgency=medium * Team upload. diff -Nru core-memoize-clojure-0.7.1/debian/control core-memoize-clojure-1.0.257/debian/control --- core-memoize-clojure-0.7.1/debian/control 2020-11-05 10:49:56.000000000 +0000 +++ core-memoize-clojure-1.0.257/debian/control 2022-10-25 03:08:25.000000000 +0000 @@ -1,21 +1,22 @@ Source: core-memoize-clojure Section: java Priority: optional -Maintainer: an Clojure Maintainers +Maintainer: Debian Clojure Maintainers Uploaders: Apollon Oikonomopoulos , Build-Depends: clojure, - debhelper-compat (= 10), + debhelper-compat (= 13), default-jdk, javahelper, libcore-cache-clojure, - markdown, maven-repo-helper, -Standards-Version: 4.5.0 + libbultitude-clojure , +Standards-Version: 4.6.1 Vcs-Git: https://salsa.debian.org/clojure-team/core-memoize-clojure.git Vcs-Browser: https://salsa.debian.org/clojure-team/core-memoize-clojure Homepage: https://github.com/clojure/core.memoize +Rules-Requires-Root: no Package: libcore-memoize-clojure Architecture: all diff -Nru core-memoize-clojure-0.7.1/debian/docs core-memoize-clojure-1.0.257/debian/docs --- core-memoize-clojure-0.7.1/debian/docs 1970-01-01 00:00:00.000000000 +0000 +++ core-memoize-clojure-1.0.257/debian/docs 2022-10-25 03:08:25.000000000 +0000 @@ -0,0 +1 @@ +README.md diff -Nru core-memoize-clojure-0.7.1/debian/gbp.conf core-memoize-clojure-1.0.257/debian/gbp.conf --- core-memoize-clojure-0.7.1/debian/gbp.conf 1970-01-01 00:00:00.000000000 +0000 +++ core-memoize-clojure-1.0.257/debian/gbp.conf 2022-10-25 03:08:25.000000000 +0000 @@ -0,0 +1,4 @@ +[DEFAULT] +pristine-tar = True +debian-branch = debian/main +upstream-branch = upstream diff -Nru core-memoize-clojure-0.7.1/debian/rules core-memoize-clojure-1.0.257/debian/rules --- core-memoize-clojure-0.7.1/debian/rules 2020-11-05 10:49:56.000000000 +0000 +++ core-memoize-clojure-1.0.257/debian/rules 2022-10-25 03:08:25.000000000 +0000 @@ -5,13 +5,6 @@ MDWN_DOCS = $(patsubst %.md,%.html,$(wildcard $(CURDIR)/*.md)) -DEB_PKGNAME := $(shell dpkg-parsechangelog -SSource) -DEB_VERSION := $(shell dpkg-parsechangelog -SVersion) -DEB_NOEPOCH_VERSION := $(shell echo $(DEB_VERSION) | cut -d: -f2-) -DEB_UPSTREAM_VERSION := $(shell echo $(DEB_NOEPOCH_VERSION) | sed 's/-[^-]*$$//') -GIT_TAG := $(shell echo '$(DEB_UPSTREAM_VERSION)' | sed -e 's/~/_/') -UPSTREAM_GIT = https://github.com/clojure/core.memoize - export CLASSPATH=/usr/share/java/clojure.jar:/usr/share/java/core.cache.jar PRODUCED_JAR=core.memoize.jar @@ -19,14 +12,13 @@ %: dh $@ --with javahelper --with maven_repo_helper -override_jh_build: $(MDWN_DOCS) +override_jh_build: jar cf $(PRODUCED_JAR) -C src/main/clojure . - mkdir -p $(CURDIR)/doc/html && mv $^ $(CURDIR)/doc/html override_dh_auto_test: - dh_auto_test - (cd src/test/clojure && \ - find . -name "test_*.clj" | xargs clojure -cp $(CURDIR)/$(PRODUCED_JAR)) +ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) + debian/run-build-tests +endif override_jh_classpath: jh_classpath $(PRODUCED_JAR) @@ -34,41 +26,6 @@ override_jh_installlibs: jh_installlibs $(PRODUCED_JAR) -override_dh_installdocs: - dh_installdocs $(CURDIR)/*.md $(CURDIR)/doc/* - override_jh_clean: jh_clean rm -f $(CURDIR)/$(PRODUCED_JAR) - rm -rf $(CURDIR)/doc - -get-orig-source: - uscan --download-version $(DEB_VERSION_UPSTREAM) --force-download --rename - -%.html:%.md - @echo '' > $@ - @echo "" >> $@ - @echo "" >> $@ - @echo "$(shell head -n 1 $< | sed 's/^#*\s*//')" >> $@ - @echo "" >> $@ - @echo "" >> $@ - markdown $< >> $@ - @echo "" >> $@ - @echo "" >> $@ - -gen-orig-xz: - git tag -v $(GIT_TAG) || true - if [ ! -f ../$(DEBPKGNAME)_$(VERSION).orig.tar.xz ] ; then \ - git archive --prefix=$(DEB_PKGNAME)-$(DEB_UPSTREAM_VERSION)/ $(GIT_TAG) | xz >../$(DEB_PKGNAME)_$(DEB_UPSTREAM_VERSION).orig.tar.xz ; \ - mkdir -p ../build-area ; \ - cp ../$(DEB_PKGNAME)_$(DEB_UPSTREAM_VERSION).orig.tar.xz ../build-area ; \ - fi - -fetch-upstream-remote: -ifeq (,$(findstring https:,$(UPSTREAM_GIT))) - $(error Using insecure proto in UPSTREAM_GIT: $(UPSTREAM_GIT)) -endif - git remote add upstream $(UPSTREAM_GIT) || true - git remote set-url upstream $(UPSTREAM_GIT) - git fetch upstream diff -Nru core-memoize-clojure-0.7.1/debian/run-build-tests core-memoize-clojure-1.0.257/debian/run-build-tests --- core-memoize-clojure-0.7.1/debian/run-build-tests 1970-01-01 00:00:00.000000000 +0000 +++ core-memoize-clojure-1.0.257/debian/run-build-tests 2022-10-25 03:08:25.000000000 +0000 @@ -0,0 +1,12 @@ +#!/bin/sh +set -efu + +CLASSPATH=/usr/share/java/clojure.jar:/usr/share/java/bultitude.jar:/usr/share/java/core.cache.jar:src/main/clojure:src/test/clojure + +clojure \ + -cp $CLASSPATH \ + -e "(require '[clojure.test])" \ + -e "(require '[bultitude.core :as b])" \ + -e '(def all-tests (b/namespaces-on-classpath :classpath "src/test/clojure"))' \ + -e "(map #(require %) all-tests)" \ + -e '(System/exit (if (clojure.test/successful? (clojure.test/run-all-tests #"clojure\.core\.memoize\.\S+-test")) 0 1))' diff -Nru core-memoize-clojure-0.7.1/debian/tests/control core-memoize-clojure-1.0.257/debian/tests/control --- core-memoize-clojure-0.7.1/debian/tests/control 1970-01-01 00:00:00.000000000 +0000 +++ core-memoize-clojure-1.0.257/debian/tests/control 2022-10-25 03:08:25.000000000 +0000 @@ -0,0 +1,11 @@ +Tests: smoke +Depends: + clojure, + @, +Restrictions: superficial + +Tests: upstream +Depends: + clojure, + libbultitude-clojure, + @, diff -Nru core-memoize-clojure-0.7.1/debian/tests/smoke core-memoize-clojure-1.0.257/debian/tests/smoke --- core-memoize-clojure-0.7.1/debian/tests/smoke 1970-01-01 00:00:00.000000000 +0000 +++ core-memoize-clojure-1.0.257/debian/tests/smoke 2022-10-25 03:08:25.000000000 +0000 @@ -0,0 +1,5 @@ +#!/bin/sh + +CLASSPATH=/usr/share/java/clojure.jar:/usr/share/java/core.memoize.jar + +clojure -cp $CLASSPATH -e '(use '"'"'clojure.core.memoize)' diff -Nru core-memoize-clojure-0.7.1/debian/tests/upstream core-memoize-clojure-1.0.257/debian/tests/upstream --- core-memoize-clojure-0.7.1/debian/tests/upstream 1970-01-01 00:00:00.000000000 +0000 +++ core-memoize-clojure-1.0.257/debian/tests/upstream 2022-10-25 03:08:25.000000000 +0000 @@ -0,0 +1,15 @@ +#!/bin/sh +set -efu + +CLASSPATH=/usr/share/java/clojure.jar:/usr/share/java/bultitude.jar:/usr/share/java/core.memoize.jar:test + +cp -a src/test/clojure "$AUTOPKGTEST_TMP/test" +cd "$AUTOPKGTEST_TMP" + +clojure \ + -cp $CLASSPATH \ + -e "(require '[clojure.test])" \ + -e "(require '[bultitude.core :as b])" \ + -e '(def all-tests (b/namespaces-on-classpath :classpath "test"))' \ + -e "(map #(require %) all-tests)" \ + -e '(System/exit (if (clojure.test/successful? (clojure.test/run-all-tests #"clojure\.core\.memoize\.\S+-test")) 0 1))' diff -Nru core-memoize-clojure-0.7.1/debian/upstream/metadata core-memoize-clojure-1.0.257/debian/upstream/metadata --- core-memoize-clojure-0.7.1/debian/upstream/metadata 1970-01-01 00:00:00.000000000 +0000 +++ core-memoize-clojure-1.0.257/debian/upstream/metadata 2022-10-25 03:08:25.000000000 +0000 @@ -0,0 +1,4 @@ +Bug-Database: https://clojure.atlassian.net/jira/software/c/projects/CMEMOIZE/issues +Documentation: https://github.com/clojure/core.memoize/tree/master/docs +Repository: https://github.com/clojure/core.memoize.git +Repository-Browse: https://github.com/clojure/core.memoize diff -Nru core-memoize-clojure-0.7.1/debian/watch core-memoize-clojure-1.0.257/debian/watch --- core-memoize-clojure-0.7.1/debian/watch 2020-11-05 10:49:56.000000000 +0000 +++ core-memoize-clojure-1.0.257/debian/watch 2022-10-25 03:08:25.000000000 +0000 @@ -1,2 +1,4 @@ -version=3 -https://github.com/clojure/core.memoize/tags .*\-([\d\.]+)\.tar\.gz +version=4 +opts="mode=git" \ +https://github.com/clojure/core.memoize.git \ +refs/tags/v@ANY_VERSION@ diff -Nru core-memoize-clojure-0.7.1/deps.edn core-memoize-clojure-1.0.257/deps.edn --- core-memoize-clojure-0.7.1/deps.edn 2018-03-02 21:35:58.000000000 +0000 +++ core-memoize-clojure-1.0.257/deps.edn 2022-02-11 22:56:55.000000000 +0000 @@ -1,2 +1,17 @@ +;; You can run clojure.core.memoize tests with: clj -A:test:runner +;; You can also specify an alias to select which version of Clojure to test +;; against: :1.6 :1.7 :1.8 :1.9 :master + {:paths ["src/main/clojure"] - :deps {org.clojure/core.cache {:mvn/version "0.6.5"}}} + :deps {org.clojure/core.cache {:mvn/version "1.0.225"}} + :aliases {:1.8 {:override-deps {org.clojure/clojure {:mvn/version "1.8.0"}}} + :1.9 {:override-deps {org.clojure/clojure {:mvn/version "1.9.0"}}} + :1.10 {:override-deps {org.clojure/clojure {:mvn/version "1.10.3"}}} + :master {:override-deps {org.clojure/clojure {:mvn/version "1.11.0-master-SNAPSHOT"}}} + :test + {:extra-paths ["src/test/clojure"] + :extra-deps {org.clojure/test.check {:mvn/version "1.0.0"} + io.github.cognitect-labs/test-runner + {:git/tag "v0.4.0" :git/sha "334f2e2"}} + :main-opts ["-m" "cognitect.test-runner" + "-d" "src/test/clojure"]}}} diff -Nru core-memoize-clojure-0.7.1/docs/cheatsheet.tex core-memoize-clojure-1.0.257/docs/cheatsheet.tex --- core-memoize-clojure-0.7.1/docs/cheatsheet.tex 2018-03-02 21:35:58.000000000 +0000 +++ core-memoize-clojure-1.0.257/docs/cheatsheet.tex 1970-01-01 00:00:00.000000000 +0000 @@ -1,242 +0,0 @@ -\documentclass[footexclude,twocolumn,DIV25,fontsize=10pt]{scrreprt} - -% Author: Fogus (based on Steve Tayon's Clojure, my own ClojureScript and David Liebke's Incanter cheat sheets) -% Comments, errors, suggestions: fogus -at- clojure -dot- com - -% License -% Eclipse Public License v1.0 -% http://opensource.org/licenses/eclipse-1.0.php - -% Packages -\usepackage[utf8]{inputenc} -\usepackage[T1]{fontenc} -\usepackage{textcomp} -\usepackage[english]{babel} -\usepackage{tabularx} -\usepackage{verbatim} -\usepackage[table]{xcolor} - -% Set column space -\setlength{\columnsep}{0.25em} - -% Define colours -\definecolorset{hsb}{}{}{red,0,.4,0.95;orange,.1,.4,0.95;green,.25,.4,0.95;yellow,.15,.4,0.95} -\definecolorset{hsb}{}{}{blue,.55,.4,0.95;purple,.7,.4,0.95;pink,.8,.4,0.95;blue2,.58,.4,0.95} -\definecolorset{hsb}{}{}{magenta,.9,.4,0.95;green2,.29,.4,0.95} - -\definecolor{Brown}{cmyk}{0,0.81,1,0.60} -\definecolor{OliveGreen}{cmyk}{0.64,0,0.95,0.40} -\definecolor{CadetBlue}{cmyk}{0.62,0.57,0.23,0} -\definecolor{lightlightgray}{gray}{0.9} - -% Redefine sections -\makeatletter -\renewcommand{\section}{\@startsection{section}{1}{0mm} - {-1.7ex}{0.7ex}{\normalfont\large\bfseries}} -\renewcommand{\subsection}{\@startsection{subsection}{2}{0mm} - {-1.7ex}{0.5ex}{\normalfont\normalsize\bfseries}} -\makeatother - -% No section numbers -\setcounter{secnumdepth}{0} - -% No indentation -\setlength{\parindent}{0em} - -% No header and footer -\pagestyle{empty} - - -% A few shortcuts -\newcommand{\cmd}[1] {\texttt{\textbf{{#1}}}} -\newcommand{\cmdline}[1] { - \begin{tabularx}{\hsize}{X} - \texttt{\textbf{{#1}}} - \end{tabularx} -} - -\newcommand{\colouredbox}[2] { - \colorbox{#1!40}{ - \begin{minipage}{0.95\linewidth} - { - \rowcolors[]{1}{#1!20}{#1!10} - #2 - } - \end{minipage} - } -} - -\usepackage{color} -\usepackage{xcolor} -\usepackage{listings} -\usepackage[small,bf]{caption} - -\DeclareCaptionFont{white}{\color{white}} -\DeclareCaptionFormat{listing}{\colorbox{yellow}{\parbox{0.95\linewidth}{\hspace{15pt}#1#2#3}}} -\captionsetup[lstlisting]{format=listing} - -\begin{document} - -\centerline{\Large{\textbf{Lemonad Cheat Sheet (v 0.4.0)}}} -\centerline{{\large{\textbf{\textit{http://github.com/fogus/lemonad}}}}} - -\colouredbox{green}{ -\section{Documentation} -\textmd{\textrm{http://www.functionaljs.org}} -} - -\lstset{ -language=c, % Code langugage -basicstyle=\ttfamily, -keywordstyle=\color{OliveGreen}, -morekeywords={_, L}, -frame=none, -} - -\begin{lstlisting}[label=incl,caption=Including Lemonad] - - -\end{lstlisting} - - -\colouredbox{red}{ -\section{Basic functions} -\begin{tabularx}{\hsize}{lX} -Maps: & \cmd{\{:key1 :val1, :key2 :val2\}} \\ -Vectors: & \cmd{[1 2 3 4 :a :b :c 1 2]} \\ -Sets: & \cmd{\#\{:a :b :c 1 2 3\}} \\ -Truth and nullity: & \cmd{true, false, nil} \\ -Keywords: & \cmd{:kw, :a-2, :prefix/kw, ::pi} \\ -Symbols: & \cmd{sym, sym-2, prefix/sym} \\ -Characters: & \cmd{\textbackslash a, \textbackslash u1123, \textbackslash space} \\ -Numbers/Strings: & same as in JavaScript \\ -\end{tabularx} - -} - - -\colouredbox{blue}{ -\section{Higher-order functions} -\begin{tabularx}{\hsize}{lX} -Math:& \cmd{+ - * / quot rem mod inc dec max min}\\ -Comparison:& \cmd{= == not= < > <= >=}\\ -Tests:& \cmd{nil? identical? zero? pos? neg? even? odd? true? false? nil?} \\ -Keywords:& \cmd{keyword keyword?} \\ -Symbols:& \cmd{symbol symbol? gensym} \\ -Data Processing:& \cmd{map reduce filter partition split-at split-with} \\ -Data Create:& \cmd{vector vec hash-map set list list* for} \\ -Data Examination:& \cmd{first rest count get nth get get-in contains? find keys vals} \\ -Data Manipulation:& \cmd{seq into conj cons assoc assoc-in dissoc zipmap merge merge-with select-keys update-in}\\ -Arrays:& \cmd{into-array to-array aget aset amap areduce alength}\\ -\end{tabularx} - -\subsection{More information} -\begin{tabularx}{\hsize}{lX} -\centerline{{\large{\textbf{\textit{http://clojuredocs.org}}}}} -\end{tabularx} - -} - - -\colouredbox{pink}{ -\section{Applicative functions} -\begin{tabularx}{\hsize}{lX} -Defining:& \cmd{defmacro}\\ -Macros:& \cmd{if if-let cond and or -> ->> doto when when-let ..}\\ -Implementation:& Must be written in Clojure \\ -Emission:& Must emit ClojureScript \\ -\end{tabularx} - -} - - -\colouredbox{orange}{ -\section{Sub libraries} - -\subsection{Monads} -\begin{tabularx}{\hsize}{lX} -Definition:& \cmd{(defprotocol Slicey (slice [at]))} \\ -Extend:& \cmd{(extend-type js/String Slicey (slice [at] ...))} \\ -Extend null:& \cmd{(extend-type nil Slicey (slice [\_] nil))} \\ -Reify:& \cmd{(reify Slicey (slice [at] ...))}\\ -\end{tabularx} - -\subsection{Relational algebra} -\begin{tabularx}{\hsize}{lX} -Definition:& \cmd{(defrecord Pair [h t])} \\ -Access:& \cmd{(:h (Pair. 1 2)) ;=> 1} \\ -Constructing:& \cmd{Pair. ->Pair map->Pair} \\ -\end{tabularx} - -\subsection{Protocols} -\begin{tabularx}{\hsize}{lX} -Definition:& \cmd{(deftype Pair [h t])} \\ -Access:& \cmd{(.-h (Pair. 1 2)) ;=> 1} \\ -Constructing:& \cmd{Pair. ->Pair} \\ -With Method(s):& \cmd{(deftype Pair [h t] Object (toString [] ...))} \\ -\end{tabularx} - -\subsection{TBD} -\begin{tabularx}{\hsize}{lX} -Definition:& \cmd{(defmulti my-mm dispatch-function)}\\ -Method Define:& \cmd{(defmethod my-mm :dispatch-value [args] ...)}\\ -\end{tabularx} - -} - -\colouredbox{yellow}{ -\section{JS Interop (http://fogus.me/cljs-js)} -\begin{tabularx}{\hsize}{lX} -Method Call: & \cmd{(.meth obj args)} \\ -Method Call: & \cmd{(. obj (meth args))} \\ -Property Access: & \cmd{(. obj -prop)} \\ -Property Access: & \cmd{(.-prop obj)} \\ -Set Property: & \cmd{(set! (.-prop obj) val)} \\ -JS Global Access: & \cmd{js/window} \\ -JS \cmd{this}: & \cmd{(this-as me (.method me))} \\ -Create JS Object: & \cmd{(js-obj)} \\ -\end{tabularx} - -} - - -\colouredbox{blue2}{ -\section{Compilation (http://fogus.me/cljsc)} -\begin{tabularx}{\hsize}{lX} -Simple Compile: & \cmdline{cljsc src-home '\{:optimizations :simple :pretty-print true\}'} \\ -Advanced Compile: & \cmdline{cljsc src-home '\{:optimizations :advanced\}'} \\ -\end{tabularx} - -} - - -\colouredbox{pink}{ -\section{Extra ClojureScript Libraries} -\cmd{clojure.\{string set zipper\} clojure.browser.\{dom event net repl\}}\\ - -} - - -\colouredbox{green}{ -\section{Other Useful Libraries} -\begin{tabularx}{\hsize}{lX} -App Sample: & http://clojurescriptone.com \\ -Client/Server: & http://github.com/ibdknox/fetch \\ -Data Viz: & http://github.com/lynaghk/cljs-d3 \\ -DOM: & http://github.com/levand/domina \\ -jQuery: & http://github.com/ibdknox/jayq \\ -Templating: & http://github.com/ibdknox/crate \\ -\end{tabularx} - -} - - -\begin{flushright} -\footnotesize -\rule{0.7\linewidth}{0.25pt} -\verb!$Revision: 1.0, $Date: Feb 08, 2012!\\ -\verb!Fogus (fogus -at- clojure -dot- com)! -\end{flushright} -\end{document} diff -Nru core-memoize-clojure-0.7.1/docs/Including.md core-memoize-clojure-1.0.257/docs/Including.md --- core-memoize-clojure-0.7.1/docs/Including.md 2018-03-02 21:35:58.000000000 +0000 +++ core-memoize-clojure-1.0.257/docs/Including.md 2022-02-11 22:56:55.000000000 +0000 @@ -7,10 +7,10 @@ * Snapshot versions stored at [Sonatype](https://oss.sonatype.org/index.html#nexus-search;gav~org.clojure~core.memoize~~~) (url at ) ## Leiningen -` + You can use core.memoize in your [Leiningen](https://github.com/technomancy/leiningen) projects with the following `:dependencies` directive in your `project.clj` file: - [org.clojure/core.memoize "0.5.6"] + [org.clojure/core.memoize "1.0.250"] ## Maven @@ -19,7 +19,7 @@ org.clojure core.memoize - 0.5.6 + 1.0.250 Enjoy! diff -Nru core-memoize-clojure-0.7.1/docs/README.md core-memoize-clojure-1.0.257/docs/README.md --- core-memoize-clojure-0.7.1/docs/README.md 2018-03-02 21:35:58.000000000 +0000 +++ core-memoize-clojure-1.0.257/docs/README.md 2022-02-11 22:56:55.000000000 +0000 @@ -48,5 +48,5 @@ ## Places * [Source code](https://github.com/clojure/core.memoize) -* [Ticket system](http://dev.clojure.org/jira/browse/CMEMOIZE) +* [Ticket system](http://clojure.atlassian.net/browse/CMEMOIZE) * [Examples and documentation](http://github.com/clojure/core.memoize/wiki) diff -Nru core-memoize-clojure-0.7.1/docs/release-notes/release-0.5.1.markdown core-memoize-clojure-1.0.257/docs/release-notes/release-0.5.1.markdown --- core-memoize-clojure-0.7.1/docs/release-notes/release-0.5.1.markdown 2018-03-02 21:35:58.000000000 +0000 +++ core-memoize-clojure-1.0.257/docs/release-notes/release-0.5.1.markdown 2022-02-11 22:56:55.000000000 +0000 @@ -17,7 +17,7 @@ core.memoize is based on a library named Unk, found at that is planned for deprecation. * [Source code](https://github.com/clojure/core.memoize) -* [Ticket system](http://dev.clojure.org/jira/browse/CMEMOIZE) +* [Ticket system](http://clojure.atlassian.net/browse/CMEMOIZE) Changes from Unk ------------------- diff -Nru core-memoize-clojure-0.7.1/docs/release-notes/release-0.5.2.markdown core-memoize-clojure-1.0.257/docs/release-notes/release-0.5.2.markdown --- core-memoize-clojure-0.7.1/docs/release-notes/release-0.5.2.markdown 2018-03-02 21:35:58.000000000 +0000 +++ core-memoize-clojure-1.0.257/docs/release-notes/release-0.5.2.markdown 2022-02-11 22:56:55.000000000 +0000 @@ -18,8 +18,8 @@ ------ * [Source code](https://github.com/clojure/core.memoize) -* [Ticket system](http://dev.clojure.org/jira/browse/CMEMOIZE) -* [API Reference](https://clojure.github.com/core.memoize) +* [Ticket system](http://clojure.atlassian.net/browse/CMEMOIZE) +* [API Reference](https://clojure.github.io/core.memoize) Changes from v0.5.1 ------------------- diff -Nru core-memoize-clojure-0.7.1/docs/release-notes/release-0.5.4.markdown core-memoize-clojure-1.0.257/docs/release-notes/release-0.5.4.markdown --- core-memoize-clojure-0.7.1/docs/release-notes/release-0.5.4.markdown 2018-03-02 21:35:58.000000000 +0000 +++ core-memoize-clojure-1.0.257/docs/release-notes/release-0.5.4.markdown 2022-02-11 22:56:55.000000000 +0000 @@ -33,16 +33,16 @@ ------ * [Source code](https://github.com/clojure/core.memoize) -* [Ticket system](http://dev.clojure.org/jira/browse/CMEMOIZE) -* [API Reference](https://clojure.github.com/core.memoize) +* [Ticket system](http://clojure.atlassian.net/browse/CMEMOIZE) +* [API Reference](https://clojure.github.io/core.memoize) Changes from v0.5.3 ------------------- The v0.5.4 version of core.memoize works with the v0.6.3 version of [core.cache](http://github.com/clojure/core.cache/wiki). In addition, the following bugs have been fixed: - * [CMEMOIZE-5](http://dev.clojure.org/jira/browse/CMEMOIZE-5): Changed to never assume that the value retrieved from the cache is non-nil. This was causing an occassional issue with TTL caches that timed out between checking for a value and retrieving it. - * [CMEMOIZE-2](http://dev.clojure.org/jira/browse/CMEMOIZE-2): All references to Unk have been removed. + * [CMEMOIZE-5](http://clojure.atlassian.net/browse/CMEMOIZE-5): Changed to never assume that the value retrieved from the cache is non-nil. This was causing an occassional issue with TTL caches that timed out between checking for a value and retrieving it. + * [CMEMOIZE-2](http://clojure.atlassian.net/browse/CMEMOIZE-2): All references to Unk have been removed. Plans ----- diff -Nru core-memoize-clojure-0.7.1/docs/release-notes/release-0.5.5.markdown core-memoize-clojure-1.0.257/docs/release-notes/release-0.5.5.markdown --- core-memoize-clojure-0.7.1/docs/release-notes/release-0.5.5.markdown 2018-03-02 21:35:58.000000000 +0000 +++ core-memoize-clojure-1.0.257/docs/release-notes/release-0.5.5.markdown 2022-02-11 22:56:55.000000000 +0000 @@ -33,8 +33,8 @@ ------ * [Source code](https://github.com/clojure/core.memoize) -* [Ticket system](http://dev.clojure.org/jira/browse/CMEMOIZE) -* [API Reference](https://clojure.github.com/core.memoize) +* [Ticket system](http://clojure.atlassian.net/browse/CMEMOIZE) +* [API Reference](https://clojure.github.io/core.memoize) Changes from v0.5.4 ------------------- diff -Nru core-memoize-clojure-0.7.1/docs/release-notes/release-0.5.6.markdown core-memoize-clojure-1.0.257/docs/release-notes/release-0.5.6.markdown --- core-memoize-clojure-0.7.1/docs/release-notes/release-0.5.6.markdown 2018-03-02 21:35:58.000000000 +0000 +++ core-memoize-clojure-1.0.257/docs/release-notes/release-0.5.6.markdown 2022-02-11 22:56:55.000000000 +0000 @@ -33,19 +33,19 @@ ------ * [Source code](https://github.com/clojure/core.memoize) -* [Ticket system](http://dev.clojure.org/jira/browse/CMEMOIZE) -* [API Reference](https://clojure.github.com/core.memoize) +* [Ticket system](http://clojure.atlassian.net/browse/CMEMOIZE) +* [API Reference](https://clojure.github.io/core.memoize) Changes from v0.5.5 ------------------- The v0.5.6 version of core.memoize works with the v0.6.3 version of [core.cache](http://github.com/clojure/core.cache/wiki). In addition, the following bugs have been fixed, or features added: - * [CMEMOIZE-4](http://dev.clojure.org/jira/browse/CMEMOIZE-4) - `memo-clear!` function now takes an optional args to limit evictions. + * [CMEMOIZE-4](http://clojure.atlassian.net/browse/CMEMOIZE-4) - `memo-clear!` function now takes an optional args to limit evictions. - * [CMEMOIZE-6](http://dev.clojure.org/jira/browse/CMEMOIZE-6) - Widenes the contract on the types of callables allowed. + * [CMEMOIZE-6](http://clojure.atlassian.net/browse/CMEMOIZE-6) - Widenes the contract on the types of callables allowed. - * [CMEMOIZE-7](http://dev.clojure.org/jira/browse/CMEMOIZE-7) - Fixed issues link in README. + * [CMEMOIZE-7](http://clojure.atlassian.net/browse/CMEMOIZE-7) - Fixed issues link in README. Plans ----- diff -Nru core-memoize-clojure-0.7.1/.github/PULL_REQUEST_TEMPLATE core-memoize-clojure-1.0.257/.github/PULL_REQUEST_TEMPLATE --- core-memoize-clojure-0.7.1/.github/PULL_REQUEST_TEMPLATE 1970-01-01 00:00:00.000000000 +0000 +++ core-memoize-clojure-1.0.257/.github/PULL_REQUEST_TEMPLATE 2022-02-11 22:56:55.000000000 +0000 @@ -0,0 +1,14 @@ +Hi! Thanks for your interest in contributing to this project. + +Clojure contrib projects do not use GitHub issues or pull requests, and +require a signed Contributor Agreement. If you would like to contribute, +please read more about the CA and sign that first (this can be done online). + +Then go to this project's issue tracker in JIRA to create tickets, update +tickets, or submit patches. For help in creating tickets and patches, +please see: + +- Signing the CA: https://clojure.org/community/contributing +- Creating Tickets: https://clojure.org/community/creating_tickets +- Developing Patches: https://clojure.org/community/developing_patches +- Contributing FAQ: https://clojure.org/community/contributing diff -Nru core-memoize-clojure-0.7.1/.gitignore core-memoize-clojure-1.0.257/.gitignore --- core-memoize-clojure-0.7.1/.gitignore 2018-03-02 21:35:58.000000000 +0000 +++ core-memoize-clojure-1.0.257/.gitignore 2022-02-11 22:56:55.000000000 +0000 @@ -1,7 +1,13 @@ -target -src/old.lein* +.classpath +.cpcache/ +.idea .lein* +.lsp/sqlite.db .nrepl-port -.idea/ -*.iml -.cpcache/ +.project +.settings +.vscode +/build.boot +lib +multi-lib +target diff -Nru core-memoize-clojure-0.7.1/LICENSE core-memoize-clojure-1.0.257/LICENSE --- core-memoize-clojure-0.7.1/LICENSE 1970-01-01 00:00:00.000000000 +0000 +++ core-memoize-clojure-1.0.257/LICENSE 2022-02-11 22:56:55.000000000 +0000 @@ -0,0 +1,205 @@ +Eclipse Public License - v 1.0 + +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC +LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM +CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + +a) in the case of the initial Contributor, the initial code and documentation + distributed under this Agreement, and +b) in the case of each subsequent Contributor: + i) changes to the Program, and + ii) additions to the Program; + + where such changes and/or additions to the Program originate from and are + distributed by that particular Contributor. A Contribution 'originates' + from a Contributor if it was added to the Program by such Contributor + itself or anyone acting on such Contributor's behalf. Contributions do not + include additions to the Program which: (i) are separate modules of + software distributed in conjunction with the Program under their own + license agreement, and (ii) are not derivative works of the Program. + +"Contributor" means any person or entity that distributes the Program. + +"Licensed Patents" mean patent claims licensable by a Contributor which are +necessarily infringed by the use or sale of its Contribution alone or when +combined with the Program. + +"Program" means the Contributions distributed in accordance with this +Agreement. + +"Recipient" means anyone who receives the Program under this Agreement, +including all Contributors. + +2. GRANT OF RIGHTS + a) Subject to the terms of this Agreement, each Contributor hereby grants + Recipient a non-exclusive, worldwide, royalty-free copyright license to + reproduce, prepare derivative works of, publicly display, publicly + perform, distribute and sublicense the Contribution of such Contributor, + if any, and such derivative works, in source code and object code form. + b) Subject to the terms of this Agreement, each Contributor hereby grants + Recipient a non-exclusive, worldwide, royalty-free patent license under + Licensed Patents to make, use, sell, offer to sell, import and otherwise + transfer the Contribution of such Contributor, if any, in source code and + object code form. This patent license shall apply to the combination of + the Contribution and the Program if, at the time the Contribution is + added by the Contributor, such addition of the Contribution causes such + combination to be covered by the Licensed Patents. The patent license + shall not apply to any other combinations which include the Contribution. + No hardware per se is licensed hereunder. + c) Recipient understands that although each Contributor grants the licenses + to its Contributions set forth herein, no assurances are provided by any + Contributor that the Program does not infringe the patent or other + intellectual property rights of any other entity. Each Contributor + disclaims any liability to Recipient for claims brought by any other + entity based on infringement of intellectual property rights or + otherwise. As a condition to exercising the rights and licenses granted + hereunder, each Recipient hereby assumes sole responsibility to secure + any other intellectual property rights needed, if any. For example, if a + third party patent license is required to allow Recipient to distribute + the Program, it is Recipient's responsibility to acquire that license + before distributing the Program. + d) Each Contributor represents that to its knowledge it has sufficient + copyright rights in its Contribution, if any, to grant the copyright + license set forth in this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form under +its own license agreement, provided that: + + a) it complies with the terms and conditions of this Agreement; and + b) its license agreement: + i) effectively disclaims on behalf of all Contributors all warranties + and conditions, express and implied, including warranties or + conditions of title and non-infringement, and implied warranties or + conditions of merchantability and fitness for a particular purpose; + ii) effectively excludes on behalf of all Contributors all liability for + damages, including direct, indirect, special, incidental and + consequential damages, such as lost profits; + iii) states that any provisions which differ from this Agreement are + offered by that Contributor alone and not by any other party; and + iv) states that source code for the Program is available from such + Contributor, and informs licensees how to obtain it in a reasonable + manner on or through a medium customarily used for software exchange. + +When the Program is made available in source code form: + + a) it must be made available under this Agreement; and + b) a copy of this Agreement must be included with each copy of the Program. + Contributors may not remove or alter any copyright notices contained + within the Program. + +Each Contributor must identify itself as the originator of its Contribution, +if +any, in a manner that reasonably allows subsequent Recipients to identify the +originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities with +respect to end users, business partners and the like. While this license is +intended to facilitate the commercial use of the Program, the Contributor who +includes the Program in a commercial product offering should do so in a manner +which does not create potential liability for other Contributors. Therefore, +if a Contributor includes the Program in a commercial product offering, such +Contributor ("Commercial Contributor") hereby agrees to defend and indemnify +every other Contributor ("Indemnified Contributor") against any losses, +damages and costs (collectively "Losses") arising from claims, lawsuits and +other legal actions brought by a third party against the Indemnified +Contributor to the extent caused by the acts or omissions of such Commercial +Contributor in connection with its distribution of the Program in a commercial +product offering. The obligations in this section do not apply to any claims +or Losses relating to any actual or alleged intellectual property +infringement. In order to qualify, an Indemnified Contributor must: +a) promptly notify the Commercial Contributor in writing of such claim, and +b) allow the Commercial Contributor to control, and cooperate with the +Commercial Contributor in, the defense and any related settlement +negotiations. The Indemnified Contributor may participate in any such claim at +its own expense. + +For example, a Contributor might include the Program in a commercial product +offering, Product X. That Contributor is then a Commercial Contributor. If +that Commercial Contributor then makes performance claims, or offers +warranties related to Product X, those performance claims and warranties are +such Commercial Contributor's responsibility alone. Under this section, the +Commercial Contributor would have to defend claims against the other +Contributors related to those performance claims and warranties, and if a +court requires any other Contributor to pay any damages as a result, the +Commercial Contributor must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR +IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, +NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each +Recipient is solely responsible for determining the appropriateness of using +and distributing the Program and assumes all risks associated with its +exercise of rights under this Agreement , including but not limited to the +risks and costs of program errors, compliance with applicable laws, damage to +or loss of data, programs or equipment, and unavailability or interruption of +operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY +CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION +LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE +EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY +OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under +applicable law, it shall not affect the validity or enforceability of the +remainder of the terms of this Agreement, and without further action by the +parties hereto, such provision shall be reformed to the minimum extent +necessary to make such provision valid and enforceable. + +If Recipient institutes patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Program itself +(excluding combinations of the Program with other software or hardware) +infringes such Recipient's patent(s), then such Recipient's rights granted +under Section 2(b) shall terminate as of the date such litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it fails to +comply with any of the material terms or conditions of this Agreement and does +not cure such failure in a reasonable period of time after becoming aware of +such noncompliance. If all Recipient's rights under this Agreement terminate, +Recipient agrees to cease use and distribution of the Program as soon as +reasonably practicable. However, Recipient's obligations under this Agreement +and any licenses granted by Recipient relating to the Program shall continue +and survive. + +Everyone is permitted to copy and distribute copies of this Agreement, but in +order to avoid inconsistency the Agreement is copyrighted and may only be +modified in the following manner. The Agreement Steward reserves the right to +publish new versions (including revisions) of this Agreement from time to +time. No one other than the Agreement Steward has the right to modify this +Agreement. The Eclipse Foundation is the initial Agreement Steward. The +Eclipse Foundation may assign the responsibility to serve as the Agreement +Steward to a suitable separate entity. Each new version of the Agreement will +be given a distinguishing version number. The Program (including +Contributions) may always be distributed subject to the version of the +Agreement under which it was received. In addition, after a new version of the +Agreement is published, Contributor may elect to distribute the Program +(including its Contributions) under the new version. Except as expressly +stated in Sections 2(a) and 2(b) above, Recipient receives no rights or +licenses to the intellectual property of any Contributor under this Agreement, +whether expressly, by implication, estoppel or otherwise. All rights in the +Program not expressly granted under this Agreement are reserved. + +This Agreement is governed by the laws of the State of New York and the +intellectual property laws of the United States of America. No party to this +Agreement will bring a legal action under this Agreement more than one year +after the cause of action arose. Each party waives its rights to a jury trial in +any resulting litigation. + + diff -Nru core-memoize-clojure-0.7.1/pom.xml core-memoize-clojure-1.0.257/pom.xml --- core-memoize-clojure-0.7.1/pom.xml 2018-03-02 21:35:58.000000000 +0000 +++ core-memoize-clojure-1.0.257/pom.xml 2022-02-11 22:56:55.000000000 +0000 @@ -2,7 +2,7 @@ 4.0.0 core.memoize - 0.7.1 + 1.0.257 core.memoize A memoization library for Clojure jar @@ -18,7 +18,7 @@ org.clojure pom.contrib - 0.2.2 + 1.1.0 @@ -37,19 +37,19 @@ org.clojure core.cache - 0.7.1 + 1.0.225 jira - http://dev.clojure.org/jira/browse/CMEMOIZE + http://clojure.atlassian.net/browse/CMEMOIZE scm:git:git://github.com/clojure/core.memoize.git http://github.com/clojure/core.memoize - core.memoize-0.7.1 + v1.0.257 diff -Nru core-memoize-clojure-0.7.1/project.clj core-memoize-clojure-1.0.257/project.clj --- core-memoize-clojure-0.7.1/project.clj 2018-03-02 21:35:58.000000000 +0000 +++ core-memoize-clojure-1.0.257/project.clj 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -(defproject core.memoize "0.7.2-SNAPSHOT" - :description "A memoization library for Clojure." - :dependencies [[org.clojure/clojure "1.9.0"] - [org.clojure/core.cache "0.7.1"]] - :plugins [[lein-swank "1.4.4"] - [lein-marginalia "0.7.1"]] - :repositories {"sonatype-oss-public" "https://oss.sonatype.org/content/groups/public/"} - :source-paths ["src/main/clojure"] - :test-paths ["src/test/clojure"] - :global-vars {*warn-on-reflection* true} - :profiles {:1.6 {:dependencies [[org.clojure/clojure "1.6.0"]]} - :1.7 {:dependencies [[org.clojure/clojure "1.7.0"]]} - :1.8 {:dependencies [[org.clojure/clojure "1.8.0"]]} - :1.9 {:dependencies [[org.clojure/clojure "1.9.0"]]} - :1.10 {:dependencies [[org.clojure/clojure "1.10.0-master-SNAPSHOT"]]}} - :aliases {"test-all" ["with-profile" - "1.6:1.7:1.8:1.9:1.10" - "test"]}) diff -Nru core-memoize-clojure-0.7.1/README.md core-memoize-clojure-1.0.257/README.md --- core-memoize-clojure-0.7.1/README.md 2018-03-02 21:35:58.000000000 +0000 +++ core-memoize-clojure-1.0.257/README.md 2022-02-11 22:56:55.000000000 +0000 @@ -10,7 +10,7 @@ - Least-recently-used (`clojure.core.memoize/lru`) - Least-used (`clojure.core.memoize/lu`) - Time-to-live (`clojure.core.memoize/ttl`) - - Naive cache (`memo`) that duplicates the functionality of Clojure's `memoize` function + - Naive cache (`memo`) that duplicates the functionality of Clojure's `memoize` function _but, unlike the built-in `memoize` function, ensures that in the case of concurrent calls with the same arguments, the memoized function is only invoked once_; in addition `memo` can use metadata from the memoized function to ignore certain arguments for the purpose of creating the cache key, e.g., allowing you to memoize `clojure.java.jdbc` functions where the first argument includes a (mutable) JDBC `Connection` object by specifying `:clojure.core.memoize/args-fn rest` in the metadata * Functions for manipulating the memoization cache of `core.memoize` backed functions @@ -19,22 +19,29 @@ Releases and Dependency Information ======================================== -Latest stable release: 0.7.1 +This project follows the version scheme MAJOR.MINOR.COMMITS where MAJOR and MINOR provide some relative indication of the size of the change, but do not follow semantic versioning. In general, all changes endeavor to be non-breaking (by moving to new names rather than by breaking existing names). COMMITS is an ever-increasing counter of commits since the beginning of this repository. + +Latest stable release: 1.0.257 * [All Released Versions](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.clojure%22%20AND%20a%3A%22core.memoize%22) * [Development Snapshot Versions](https://oss.sonatype.org/index.html#nexus-search;gav~org.clojure~core.memoize~~~) +[CLI/`deps.edn`](https://clojure.org/reference/deps_and_cli) dependency information: +```clojure +org.clojure/core.memoize {:mvn/version "1.0.257"} +``` + [Leiningen](https://github.com/technomancy/leiningen) dependency information: - [org.clojure/core.memoize "0.7.1"] + [org.clojure/core.memoize "1.0.257"] [Maven](http://maven.apache.org/) dependency information: org.clojure core.memoize - 0.7.1 + 1.0.257 @@ -68,33 +75,52 @@ * [GitHub project](https://github.com/clojure/core.memoize) -* [Bug Tracker](http://dev.clojure.org/jira/browse/CMEMOIZE) +* [Bug Tracker](https://clojure.atlassian.net/browse/CMEMOIZE) -* [Continuous Integration](http://build.clojure.org/job/core.memoize/) +* [Continuous Integration](https://build.clojure.org/job/core.memoize/) -* [Compatibility Test Matrix](http://build.clojure.org/job/core.memoize-test-matrix/) +* [Compatibility Test Matrix](https://build.clojure.org/job/core.memoize-test-matrix/) Change Log ==================== +* Release 1.0.257 on 2022.02.11 + * Implement `IPending` for `RetryingDelay` for folks trying to do low-level availability tests on long-running memoized functions. +* Release 1.0.253 on 2021.12.06 + * Update `core.cache` to 1.0.225 +* Release 1.0.250 on 2021.08.02 + * Clarify differences between `clojure.core/memoize` and `clojure.core.memoize/memo` functions [CMEMOIZE-25](https://clojure.atlassian.net/browse/CMEMOIZE-25). + * Update `core.cache` to 1.0.217. +* Release 1.0.236 on 2020.04.13 + * Switch to 1.0.x versioning [CMEMOIZE-29](https://clojure.atlassian.net/browse/CMEMOIZE-29). + * Update `core.cache` dependency version from 0.8.2 to 1.0.207. + * Fixes [CMEMOIZE-9](https://clojure.atlassian.net/browse/CMEMOIZE-9) - adds `memo-reset!` and deprecates 2-arity version of `memo-swap!`; adds 3+-arity version of `memo-swap!` to behave more like a `swap!` operation on the underlying cache +* Release 0.8.2 on 2019.11.01 (to match core.cache again) + * Update `core.cache` dependency version from 0.7.2 to 0.8.2. + * Fixes [CMEMOIZE-28](https://clojure.atlassian.net/browse/CMEMOIZE-28) - provides `memoizer` as a more convenient way to build custom cached functions that may provide a seed hash map of arguments to return values. `build-memoizer` should be considered deprecated at this point. + * Fixes [CMEMOIZE-27](https://clojure.atlassian.net/browse/CMEMOIZE-27) - the `seed` function on `PluggableMemoization` now makes elements derefable (this case was missed when [CMEMOIZE-18](https://clojure.atlassian.net/browse/CMEMOIZE-18) was fixed) +* Release 0.7.2 on 2019.06.13 + * Fixes [CMEMOIZE-26](https://clojure.atlassian.net/browse/CMEMOIZE-26) - zero-arity function cache could not be replaced by `memo-swap!` (discovered by Teemu Kaukoranta) + * Updated core.cache dependency version from 0.7.1 to 0.7.2 + * Updated test matrix locally to include Clojure 1.10.1, 1.11 master * Release 0.7.1 on 2018.03.02 - * Fixes [CMEMOIZE-15](http://dev.clojure.org/jira/browse/CMEMOIZE-15) - edge case where cache miss/lookup cross an eviction boundary (Ryan Fowler/Colin Jones) + * Fixes [CMEMOIZE-15](https://clojure.atlassian.net/browse/CMEMOIZE-15) - edge case where cache miss/lookup cross an eviction boundary (Ryan Fowler/Colin Jones) * Updated core.cache dependency version from 0.7.0 to 0.7.1 (for TTLCacheQ bug fix) * Release 0.7.0 on 2018.03.01 - * Fixes [CMEMOIZE-22](http://dev.clojure.org/jira/browse/CMEMOIZE-20) - add `:clojure.core.memoize/args-fn` metadata support for memoizing functions which have one or more arguments that should not contribute to the cache key for calls - * Fixes [CMEMOIZE-20](http://dev.clojure.org/jira/browse/CMEMOIZE-20) - add `lazy-snapshot` function - * Fixes [CMEMOIZE-18](http://dev.clojure.org/jira/browse/CMEMOIZE-18) - automatically makes seed map values `deref`-able to match documentation and comply with core.memoize's world view + * Fixes [CMEMOIZE-22](https://clojure.atlassian.net/browse/CMEMOIZE-22) - add `:clojure.core.memoize/args-fn` metadata support for memoizing functions which have one or more arguments that should not contribute to the cache key for calls + * Fixes [CMEMOIZE-20](https://clojure.atlassian.net/browse/CMEMOIZE-20) - add `lazy-snapshot` function + * Fixes [CMEMOIZE-18](https://clojure.atlassian.net/browse/CMEMOIZE-18) - automatically makes seed map values `deref`-able to match documentation and comply with core.memoize's world view * Cleanup/improve/fix tests * Add multi-version testing locally via Leiningen * Jump to 0.7.0 to match core.cache since these two libraries are so closely in sync * Release 0.5.9 on 2016.03.28 * Updated core.cache dependency version from 0.6.4 to 0.6.5 * Release 0.5.8 on 2015.11.06 - * Fixes [CMEMOIZE-21](http://dev.clojure.org/jira/browse/CMEMOIZE-21) - race condition in delay + * Fixes [CMEMOIZE-21](https://clojure.atlassian.net/browse/CMEMOIZE-21) - race condition in delay * Release 0.5.7 on 2015.01.12 - * Fixes [CMEMOIZE-8](http://dev.clojure.org/jira/browse/CMEMOIZE-8) - * Fixes [CMEMOIZE-13](http://dev.clojure.org/jira/browse/CMEMOIZE-13) + * Fixes [CMEMOIZE-8](https://clojure.atlassian.net/browse/CMEMOIZE-8) + * Fixes [CMEMOIZE-13](https://clojure.atlassian.net/browse/CMEMOIZE-13) * Updated core.cache dependency version from 0.6.3 to 0.6.4 * Release 0.5.6 on 2013.06.28 * Added optional args to `memo-clear!`. @@ -103,8 +129,8 @@ * Deprecated `memo-*` APIs * Adds new API of form `(cache-type function <:cache-type/threshold int>)` * Release 0.5.4 on 2013.06.03 - * Fixes [CMEMOIZE-5](http://dev.clojure.org/jira/browse/CMEMOIZE-5) - * Fixes [CMEMOIZE-2](http://dev.clojure.org/jira/browse/CMEMOIZE-2) + * Fixes [CMEMOIZE-5](https://clojure.atlassian.net/browse/CMEMOIZE-5) + * Fixes [CMEMOIZE-2](https://clojure.atlassian.net/browse/CMEMOIZE-2) * Release 0.5.3 on 2013.03.18 * Works with core.cache v0.6.3 * Release 0.5.2 on 2012.07.13 @@ -118,4 +144,4 @@ Copyright and License ======================================== -Copyright (c) Rich Hickey and Michael Fogus, 2012, 2013. All rights reserved. The use and distribution terms for this software are covered by the Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) which can be found in the file epl-v10.html at the root of this distribution. By using this software in any fashion, you are agreeing to be bound bythe terms of this license. You must not remove this notice, or any other, from this software. +Copyright (c) Rich Hickey and Michael Fogus, 2012, 2013. All rights reserved. The use and distribution terms for this software are covered by the Eclipse Public License 1.0 (https://opensource.org/licenses/eclipse-1.0.php) which can be found in the file epl-v10.html at the root of this distribution. By using this software in any fashion, you are agreeing to be bound bythe terms of this license. You must not remove this notice, or any other, from this software. diff -Nru core-memoize-clojure-0.7.1/run-tests.sh core-memoize-clojure-1.0.257/run-tests.sh --- core-memoize-clojure-0.7.1/run-tests.sh 1970-01-01 00:00:00.000000000 +0000 +++ core-memoize-clojure-1.0.257/run-tests.sh 2022-02-11 22:56:55.000000000 +0000 @@ -0,0 +1,8 @@ +#!/bin/sh + +versions="1.8 1.9 1.10 master" +for v in $versions +do + time clj -M:test:$v + if test $? != 0; then exit 1; fi +done diff -Nru core-memoize-clojure-0.7.1/src/main/clojure/clojure/core/memoize.clj core-memoize-clojure-1.0.257/src/main/clojure/clojure/core/memoize.clj --- core-memoize-clojure-0.7.1/src/main/clojure/clojure/core/memoize.clj 2018-03-02 21:35:58.000000000 +0000 +++ core-memoize-clojure-1.0.257/src/main/clojure/clojure/core/memoize.clj 2022-02-11 22:56:55.000000000 +0000 @@ -7,43 +7,24 @@ ; You must not remove this notice, or any other, from this software. (ns clojure.core.memoize - "core.memoize is a memoization library offering functionality above Clojure's core `memoize` - function in the following ways: + "core.memoize is a memoization library offering functionality above + Clojure's core `memoize` function in the following ways: **Pluggable memoization** - core.memoize allows for different back-end cache implmentations to be used as appropriate without - changing the memoization modus operandi. + core.memoize allows for different back-end cache implmentations to + be used as appropriate without changing the memoization modus operandi. + See the `memoizer` function. **Manipulable memoization** - Because core.memoize allows you to access a function's memoization store, you do interesting things like - clear it, modify it, and save it for later. + Because core.memoize allows you to access a function's memoization store, + you do interesting things like clear it, modify it, and save it for later. " {:author "fogus"} (:require [clojure.core.cache :as cache])) -;; Plugging Interface - -(deftype PluggableMemoization [f cache] - cache/CacheProtocol - (has? [_ item] - (clojure.core.cache/has? cache item)) - (hit [_ item] - (PluggableMemoization. f (clojure.core.cache/hit cache item))) - (miss [_ item result] - (PluggableMemoization. f (clojure.core.cache/miss cache item result))) - (evict [_ key] - (PluggableMemoization. f (clojure.core.cache/evict cache key))) - (lookup [_ item] - (clojure.core.cache/lookup cache item nil)) - (lookup [_ item not-found] - (clojure.core.cache/lookup cache item (delay not-found))) - (seed [_ base] - (PluggableMemoization. f (clojure.core.cache/seed cache base))) - Object - (toString [_] (str cache))) ;; Similar to clojure.lang.Delay, but will not memoize an exception and will @@ -68,7 +49,10 @@ ;; or you have a race with the first check above (set! value v) (set! available? true) - v))))))) + v)))))) + clojure.lang.IPending + (isRealized [this] + available?)) (defn- d-lay [fun] (->RetryingDelay fun false nil)) @@ -89,6 +73,28 @@ [seed] (into {} (for [[k v] seed] [k (make-derefable v)]))) +;; Plugging Interface + +(deftype PluggableMemoization [f cache] + cache/CacheProtocol + (has? [_ item] + (clojure.core.cache/has? cache item)) + (hit [_ item] + (PluggableMemoization. f (clojure.core.cache/hit cache item))) + (miss [_ item result] + (PluggableMemoization. f (clojure.core.cache/miss cache item result))) + (evict [_ key] + (PluggableMemoization. f (clojure.core.cache/evict cache key))) + (lookup [_ item] + (clojure.core.cache/lookup cache item nil)) + (lookup [_ item not-found] + (clojure.core.cache/lookup cache item (delay not-found))) + (seed [_ base] + (PluggableMemoization. + f (clojure.core.cache/seed cache (derefable-seed base)))) + Object + (toString [_] (str cache))) + ;; # Auxilliary functions (def ^{:private true @@ -117,7 +123,7 @@ you can infer that what you get is only the cache contents at a moment in time." [memoized-fn] - (when-let [cache (::cache (meta memoized-fn))] + (when-let [cache (cache-id memoized-fn)] (into {} (for [[k v] (.cache ^PluggableMemoization @cache)] [(vec k) @v])))) @@ -130,14 +136,14 @@ Returns a sequence of key/value pairs." [memoized-fn] - (when-let [cache (::cache (meta memoized-fn))] + (when-let [cache (cache-id memoized-fn)] (for [[k v] (.cache ^PluggableMemoization @cache)] [(vec k) @v]))) (defn memoized? "Returns true if a function has an core.memo-placed cache, false otherwise." [f] - (boolean (::cache (meta f)))) + (boolean (cache-id f))) (defn memo-clear! "Reaches into an core.memo-memoized function and clears the cache. This is a @@ -157,7 +163,7 @@ (when-let [cache (cache-id f)] (swap! cache (constantly (clojure.core.cache/evict @cache args)))))) -(defn memo-swap! +(defn memo-reset! "Takes a core.memo-populated function and a map and replaces the memoization cache with the supplied map. This is potentially some serious voodoo, since you can effectively change the semantics of a function on the fly. @@ -171,76 +177,139 @@ [f base] (when-let [cache (cache-id f)] (swap! cache - (constantly (clojure.core.cache/seed @cache - ;; this unconditionally wraps all values to make - ;; them derefable -- it probably should be done - ;; via derefable-seed but... - (into {} - (for [[k v] base] - [k (reify - clojure.lang.IDeref - (deref [this] v))]))))))) + (constantly (clojure.core.cache/seed @cache (derefable-seed base)))))) + +(defn memo-swap! + "The 2-arity version takes a core.memo-populated function and a map and + replaces the memoization cache with the supplied map. Use `memo-reset!` + instead for replacing the cache as this 2-arity version of `memo-swap!` + should be considered deprecated. + + The 3+-arity version takes a core.memo-populated function and arguments + similar to what you would pass to `clojure.core/swap!` and performs a + `swap!` on the underlying cache. In order to satisfy core.memoize's + world view, the assumption is that you will generally be calling it like: + + (def id (memo identity)) + (memo-swap! id clojure.core.cache/miss [13] :omg) + (id 13) + ;=> :omg + + You'll nearly always use `clojure.core.cache/miss` for this operation but + you could pass any function that would work on an immutable cache, such + as `evict` or `assoc` etc. + + Be aware that `memo-swap!` assumes it can wrap each of the `results` values + in a `delay` so that items conform to `clojure.core.memoize`'s world view." + ([f base] + (when-let [cache (cache-id f)] + (swap! cache + (constantly (clojure.core.cache/seed @cache (derefable-seed base)))))) + ([f swap-fn args & results] + (when-let [cache (cache-id f)] + (apply swap! cache swap-fn args (map #(delay %) results))))) (defn memo-unwrap [f] (::original (meta f))) +(defn- cached-function + "Given a function, an atom containing a (pluggable memoization cache), and + and cache key function, return a new function that behaves like the original + function except it is cached, based on its arguments, with the cache and the + original function in its metadata." + [f cache-atom ckey-fn] + (with-meta + (fn [& args] + (let [ckey (or (ckey-fn args) []) + cs (swap! cache-atom through* f args ckey) + val (clojure.core.cache/lookup cs ckey ::not-found)] + ;; If `lookup` returns `(delay ::not-found)`, it's likely that + ;; we ran into a timing issue where eviction and access + ;; are happening at about the same time. Therefore, we retry + ;; the `swap!` (potentially several times). + ;; + ;; core.memoize currently wraps all of its values in a `delay`. + (when val + (loop [n 0 v @val] + (if (= ::not-found v) + (when-let [v' (clojure.core.cache/lookup + (swap! cache-atom through* f args ckey) + ckey ::not-found)] + (when (< n 10) + (recur (inc n) @v'))) + v))))) + {::cache cache-atom + ::original f})) + ;; # Public memoization API +(defn memoizer + "Build a pluggable memoized version of a function. Given a function and a + (pluggable memoized) cache, and an optional seed (hash map of arguments to + return values), return a cached version of that function. + + If you want to build your own cached function, perhaps with combined caches + or customized caches, this is the preferred way to do so now." + ([f cache] + (let [cache (atom (PluggableMemoization. f cache)) + ckey-fn (args-fn f)] + (cached-function f cache ckey-fn))) + ([f cache seed] + (let [cache (atom (clojure.core.cache/seed (PluggableMemoization. f cache) + (derefable-seed seed))) + ckey-fn (args-fn f)] + (cached-function f cache ckey-fn)))) + (defn build-memoizer - "Builds a function that given a function, returns a pluggable memoized - version of it. `build-memoizer` Takes a cache factory function, a function - to memoize, and the arguments to the factory. At least one of those - functions should be the function to be memoized." + "Builds a function that, given a function, returns a pluggable memoized + version of it. `build-memoizer` takes a cache factory function, and the + argunments to that factory function -- at least one of those arguments + should be the function to be memoized (it's usually the first argument). + + `memoizer` above is a simpler version of `build-memoizer` that 'does the + right thing' with a cache and a seed hash map. `build-memoizer` remains + for backward compatibility but should be considered deprecated." ([cache-factory f & args] (let [cache (atom (apply cache-factory f args)) ckey-fn (args-fn f)] - (with-meta - (fn [& args] - (let [ckey (ckey-fn args) - cs (swap! cache through* f args ckey) - val (clojure.core.cache/lookup cs ckey ::not-found)] - ;; If `lookup` returns `(delay ::not-found)`, it's likely that - ;; we ran into a timing issue where eviction and access - ;; are happening at about the same time. Therefore, we retry - ;; the `swap!` (potentially several times). - ;; - ;; core.memoize currently wraps all of its values in a `delay`. - (when val - (loop [n 0 v @val] - (if (= ::not-found v) - (when-let [v' (clojure.core.cache/lookup - (swap! cache through* f args ckey) - ckey ::not-found)] - (when (< n 10) - (recur (inc n) @v'))) - v))))) - {::cache cache - ::original f})))) + (cached-function f cache ckey-fn)))) (defn memo "Used as a more flexible alternative to Clojure's core `memoization` function. Memoized functions built using `memo` will respond to the core.memo manipulable memoization utilities. As a nice bonus, you can use `memo` in place of `memoize` without any additional - changes. + changes, with the added guarantee that the memoized function will + only be called once for a given sequence of arguments (`memoize` + can call the function multiple times when concurrent calls are + made with the same sequence of arguments). - The default way to use this function is to simply apply a function + The default way to use this function is to simply supply a function that will be memoized. Additionally, you may also supply a map of the form `'{[42] 42, [108] 108}` where keys are a vector mapping expected argument values to arity positions. The map values are the return values of the memoized function. + If the supplied function has metadata containing an + `:clojure.core.memoize/args-fn` key, the value is assumed to be a + function that should be applied to the arguments to produce a + subset or transformed sequence of arguments that are used for the + key in the cache (the full, original arguments will still be used + to call the function). This allows you to memoize functions where + one or more arguments are irrelevant for memoization, such as the + `clojure.java.jdbc` functions, whose first argument may include + a (mutable) JDBC `Connection` object: + + (memo/memo (with-meta jdbc/execute! {::memo/args-fn rest})) + You can access the memoization cache directly via the `:clojure.core.memoize/cache` key on the memoized function's metadata. However, it is advised to use the core.memo primitives instead as implementation details may change over time." ([f] (memo f {})) ([f seed] - (build-memoizer - #(PluggableMemoization. %1 (cache/basic-cache-factory %2)) - f - (derefable-seed seed)))) + (memoizer f (cache/basic-cache-factory {}) seed))) ;; ## Utilities @@ -283,11 +352,7 @@ ([f] (memo-fifo f 32 {})) ([f limit] (memo-fifo f limit {})) ([f limit base] - (build-memoizer - #(PluggableMemoization. %1 (cache/fifo-cache-factory %3 :threshold %2)) - f - limit - (derefable-seed base)))) + (memoizer f (cache/fifo-cache-factory {} :threshold limit) base))) (defn fifo "Works the same as the basic memoization function (i.e. `memo` @@ -319,12 +384,7 @@ ([f tkey threshold] (fifo f {} tkey threshold)) ([f base key threshold] (check-args "fifo" f base key threshold) - - (build-memoizer - #(PluggableMemoization. %1 (cache/fifo-cache-factory %3 :threshold %2)) - f - threshold - (derefable-seed base)))) + (memoizer f (cache/fifo-cache-factory {} :threshold threshold) base))) ;; ### LRU @@ -333,11 +393,7 @@ ([f] (memo-lru f 32)) ([f limit] (memo-lru f limit {})) ([f limit base] - (build-memoizer - #(PluggableMemoization. %1 (cache/lru-cache-factory %3 :threshold %2)) - f - limit - (derefable-seed base)))) + (memoizer f (cache/lru-cache-factory {} :threshold limit) base))) (defn lru "Works the same as the basic memoization function (i.e. `memo` @@ -380,12 +436,7 @@ ([f tkey threshold] (lru f {} tkey threshold)) ([f base key threshold] (check-args "lru" f base key threshold) - - (build-memoizer - #(PluggableMemoization. %1 (cache/lru-cache-factory %3 :threshold %2)) - f - threshold - (derefable-seed base)))) + (memoizer f (cache/lru-cache-factory {} :threshold threshold) base))) ;; ### TTL @@ -394,12 +445,7 @@ ([f] (memo-ttl f 3000 {})) ([f limit] (memo-ttl f limit {})) ([f limit base] - (build-memoizer - #(PluggableMemoization. %1 (cache/ttl-cache-factory %3 :ttl %2)) - f - limit - ;; this ignores the base but it's deprecated so it can stay broken - {}))) + (memoizer f (cache/ttl-cache-factory {} :ttl limit) base))) (defn ttl "Unlike many of the other core.memo memoization functions, @@ -427,12 +473,7 @@ ([f tkey threshold] (ttl f {} tkey threshold)) ([f base key threshold] (check-args "ttl" f base key threshold) - - (build-memoizer - #(PluggableMemoization. %1 (cache/ttl-cache-factory %3 :ttl %2)) - f - threshold - (derefable-seed base)))) + (memoizer f (cache/ttl-cache-factory {} :ttl threshold) base))) ;; ### LU @@ -441,11 +482,7 @@ ([f] (memo-lu f 32)) ([f limit] (memo-lu f limit {})) ([f limit base] - (build-memoizer - #(PluggableMemoization. %1 (cache/lu-cache-factory %3 :threshold %2)) - f - limit - (derefable-seed base)))) + (memoizer f (cache/lu-cache-factory {} :threshold limit) base))) (defn lu "Similar to the implementation of memo-lru, except that this @@ -469,9 +506,4 @@ ([f tkey threshold] (lu f {} tkey threshold)) ([f base key threshold] (check-args "lu" f base key threshold) - - (build-memoizer - #(PluggableMemoization. %1 (cache/lu-cache-factory %3 :threshold %2)) - f - threshold - (derefable-seed base)))) + (memoizer f (cache/lu-cache-factory {} :threshold threshold) base))) diff -Nru core-memoize-clojure-0.7.1/src/test/clojure/clojure/core/memoize/deprecation_test.clj core-memoize-clojure-1.0.257/src/test/clojure/clojure/core/memoize/deprecation_test.clj --- core-memoize-clojure-0.7.1/src/test/clojure/clojure/core/memoize/deprecation_test.clj 1970-01-01 00:00:00.000000000 +0000 +++ core-memoize-clojure-1.0.257/src/test/clojure/clojure/core/memoize/deprecation_test.clj 2022-02-11 22:56:55.000000000 +0000 @@ -0,0 +1,64 @@ +; Copyright (c) Rich Hickey and Michael Fogus. All rights reserved. +; The use and distribution terms for this software are covered by the +; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) +; which can be found in the file epl-v10.html at the root of this distribution. +; By using this software in any fashion, you are agreeing to be bound by +; the terms of this license. +; You must not remove this notice, or any other, from this software. + +(ns ^{:doc "A memoization library for Clojure." + :author "Michael Fogus"} + clojure.core.memoize.deprecation-test + (:use [clojure.test] + [clojure.core.memoize] + [clojure.core.cache :only [defcache lookup has? hit miss seed ttl-cache-factory]]) + (:import (clojure.core.memoize PluggableMemoization) + (clojure.core.cache CacheProtocol))) + +(def id (memo identity)) + +(deftest test-memo-fifo + (let [mine (memo-fifo identity 2)] + (testing "that when the limit threshold is not breached, the cache works like the basic version" + (are [x y] = + 42 (mine 42) + {[42] 42} (snapshot mine) + 43 (mine 43) + {[42] 42, [43] 43} (snapshot mine) + 42 (mine 42) + {[42] 42, [43] 43} (snapshot mine))) + (testing "that when the limit is breached, the oldest value is dropped" + (are [x y] = + 44 (mine 44) + {[44] 44, [43] 43} (snapshot mine))))) + +(deftest test-memo-lru + (let [mine (memo-lru identity)] + (are [x y] = + 42 (id 42) + 43 (id 43) + {[42] 42, [43] 43} (snapshot id) + 44 (id 44) + {[44] 44, [43] 43} (snapshot id) + 43 (id 43) + 0 (id 0) + {[0] 0, [43] 43} (snapshot id)))) + +(deftest test-ttl + (let [mine (memo-ttl identity 2000)] + (are [x y] = + 42 (id 42) + {[42] 42} (snapshot id)) + (Thread/sleep 3000) + (are [x y] = + 43 (id 43) + {[43] 43} (snapshot id)))) + +(deftest test-memo-lu + (let [mine (memo-lu identity 3)] + (are [x y] = + 42 (id 42) + 42 (id 42) + 43 (id 43) + 44 (id 44) + {[44] 44, [42] 42} (snapshot id)))) diff -Nru core-memoize-clojure-0.7.1/src/test/clojure/clojure/core/memoize/deprecation_tests.clj core-memoize-clojure-1.0.257/src/test/clojure/clojure/core/memoize/deprecation_tests.clj --- core-memoize-clojure-0.7.1/src/test/clojure/clojure/core/memoize/deprecation_tests.clj 2018-03-02 21:35:58.000000000 +0000 +++ core-memoize-clojure-1.0.257/src/test/clojure/clojure/core/memoize/deprecation_tests.clj 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -; Copyright (c) Rich Hickey and Michael Fogus. All rights reserved. -; The use and distribution terms for this software are covered by the -; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this distribution. -; By using this software in any fashion, you are agreeing to be bound by -; the terms of this license. -; You must not remove this notice, or any other, from this software. - -(ns ^{:doc "A memoization library for Clojure." - :author "Michael Fogus"} - clojure.core.memoize.deprecation-tests - (:use [clojure.test] - [clojure.core.memoize] - [clojure.core.cache :only [defcache lookup has? hit miss seed ttl-cache-factory]]) - (:import (clojure.core.memoize PluggableMemoization) - (clojure.core.cache CacheProtocol))) - -(def id (memo identity)) - -(deftest test-memo-fifo - (let [mine (memo-fifo identity 2)] - (testing "that when the limit threshold is not breached, the cache works like the basic version" - (are [x y] = - 42 (mine 42) - {[42] 42} (snapshot mine) - 43 (mine 43) - {[42] 42, [43] 43} (snapshot mine) - 42 (mine 42) - {[42] 42, [43] 43} (snapshot mine))) - (testing "that when the limit is breached, the oldest value is dropped" - (are [x y] = - 44 (mine 44) - {[44] 44, [43] 43} (snapshot mine))))) - -(deftest test-memo-lru - (let [mine (memo-lru identity)] - (are [x y] = - 42 (id 42) - 43 (id 43) - {[42] 42, [43] 43} (snapshot id) - 44 (id 44) - {[44] 44, [43] 43} (snapshot id) - 43 (id 43) - 0 (id 0) - {[0] 0, [43] 43} (snapshot id)))) - -(deftest test-ttl - (let [mine (memo-ttl identity 2000)] - (are [x y] = - 42 (id 42) - {[42] 42} (snapshot id)) - (Thread/sleep 3000) - (are [x y] = - 43 (id 43) - {[43] 43} (snapshot id)))) - -(deftest test-memo-lu - (let [mine (memo-lu identity 3)] - (are [x y] = - 42 (id 42) - 42 (id 42) - 43 (id 43) - 44 (id 44) - {[44] 44, [42] 42} (snapshot id)))) diff -Nru core-memoize-clojure-0.7.1/src/test/clojure/clojure/core/memoize/regression_test.clj core-memoize-clojure-1.0.257/src/test/clojure/clojure/core/memoize/regression_test.clj --- core-memoize-clojure-0.7.1/src/test/clojure/clojure/core/memoize/regression_test.clj 1970-01-01 00:00:00.000000000 +0000 +++ core-memoize-clojure-1.0.257/src/test/clojure/clojure/core/memoize/regression_test.clj 2022-02-11 22:56:55.000000000 +0000 @@ -0,0 +1,70 @@ +; Copyright (c) Rich Hickey and Michael Fogus. All rights reserved. +; The use and distribution terms for this software are covered by the +; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) +; which can be found in the file epl-v10.html at the root of this distribution. +; By using this software in any fashion, you are agreeing to be bound by +; the terms of this license. +; You must not remove this notice, or any other, from this software. + +(ns ^{:doc "A memoization library for Clojure." + :author "Michael Fogus"} + clojure.core.memoize.regression-test + (:use [clojure.test] + [clojure.core.memoize] + [clojure.core.cache :only [defcache lookup has? hit miss seed ttl-cache-factory]]) + (:import (clojure.core.memoize PluggableMemoization) + (clojure.core.cache CacheProtocol))) + +(deftest test-regression-cmemoize-5 + (testing "that the TTL doesn't bomb on race-condition" + (try + (let [id (ttl identity :ttl/threshold 100)] + (dotimes [_ 10000000] (id 1))) + (is (= 1 1)) + (catch NullPointerException npe + (is (= 1 0)))))) + +(deftest test-regression-cmemoize-7 + (testing "that a memoized function that throws a RTE continues to retry" + (let [doit (fn [] (throw (RuntimeException. "Foo"))) + it (lru doit)] + (is (= :RTE + (try + (it) + (catch Exception _ + (try + (it) + (catch NullPointerException _ + :NPE) + (catch RuntimeException _ + :RTE) + (catch Exception e + (class e)))))))))) + +(defn- test-helper-26 + ([] 100) + ([i] (inc i))) + +(deftest test-regression-cmemoize-26 + (let [mine (memo test-helper-26)] + (testing "that memo-swap! is respected for zero arity" + (is (= 100 (mine))) + (is (= 201 (mine 200))) + (is (= {[] 100, [200] 201} (snapshot mine))) + (memo-swap! mine {[] :something [200] :else}) + (is (= {[] :something, [200] :else} (snapshot mine))) + ;; unary works... + (is (= :else (mine 200))) + ;; ...but 0-arity still has old value... + (is (= :something (mine))) + ;; ...and snapshot gets changed + (is (= {[] :something, [200] :else} (snapshot mine)))))) + +(deftest test-regression-cmemoize-27 + (testing "that seed makes elements derefable" + (let [mine (memo identity) + mine (vary-meta mine update-in [:clojure.core.memoize/cache] + swap! seed {[:a] :b [:b] :c})] + (is (= :b (mine :a))) + (is (= :c (mine :b))) + (is (= :x (mine :x)))))) diff -Nru core-memoize-clojure-0.7.1/src/test/clojure/clojure/core/memoize/regression_tests.clj core-memoize-clojure-1.0.257/src/test/clojure/clojure/core/memoize/regression_tests.clj --- core-memoize-clojure-0.7.1/src/test/clojure/clojure/core/memoize/regression_tests.clj 2018-03-02 21:35:58.000000000 +0000 +++ core-memoize-clojure-1.0.257/src/test/clojure/clojure/core/memoize/regression_tests.clj 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -; Copyright (c) Rich Hickey and Michael Fogus. All rights reserved. -; The use and distribution terms for this software are covered by the -; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this distribution. -; By using this software in any fashion, you are agreeing to be bound by -; the terms of this license. -; You must not remove this notice, or any other, from this software. - -(ns ^{:doc "A memoization library for Clojure." - :author "Michael Fogus"} - clojure.core.memoize.regression-tests - (:use [clojure.test] - [clojure.core.memoize] - [clojure.core.cache :only [defcache lookup has? hit miss seed ttl-cache-factory]]) - (:import (clojure.core.memoize PluggableMemoization) - (clojure.core.cache CacheProtocol))) - -(deftest test-regression-cmemoize-5 - (testing "that the TTL doesn't bomb on race-condition" - (try - (let [id (ttl identity :ttl/threshold 100)] - (dotimes [_ 10000000] (id 1))) - (is (= 1 1)) - (catch NullPointerException npe - (is (= 1 0)))))) - -(deftest test-regression-cmemoize-7 - (testing "that a memoized function that throws a RTE continues to retry" - (let [doit (fn [] (throw (RuntimeException. "Foo"))) - it (lru doit)] - (is (= :RTE - (try - (it) - (catch Exception _ - (try - (it) - (catch NullPointerException _ - :NPE) - (catch RuntimeException _ - :RTE) - (catch Exception e - (class e)))))))))) - diff -Nru core-memoize-clojure-0.7.1/src/test/clojure/clojure/core/memoize/tests.clj core-memoize-clojure-1.0.257/src/test/clojure/clojure/core/memoize/tests.clj --- core-memoize-clojure-0.7.1/src/test/clojure/clojure/core/memoize/tests.clj 2018-03-02 21:35:58.000000000 +0000 +++ core-memoize-clojure-1.0.257/src/test/clojure/clojure/core/memoize/tests.clj 1970-01-01 00:00:00.000000000 +0000 @@ -1,236 +0,0 @@ -; Copyright (c) Rich Hickey and Michael Fogus. All rights reserved. -; The use and distribution terms for this software are covered by the -; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this distribution. -; By using this software in any fashion, you are agreeing to be bound by -; the terms of this license. -; You must not remove this notice, or any other, from this software. - -(ns ^{:doc "A memoization library for Clojure." - :author "Michael Fogus"} - clojure.core.memoize.tests - (:use [clojure.test] - [clojure.core.cache :only [defcache lookup has? hit miss seed ttl-cache-factory]] - [clojure.core.memoize])) - -(def id (memo identity)) - -(defn- check-core-features - [factory] - (let [mine (factory identity) - them (memoize identity)] - (testing "That the memo function works the same as core.memoize" - (are [x y] = - (mine 42) (them 42) - (mine ()) (them ()) - (mine []) (them []) - (mine #{}) (them #{}) - (mine {}) (them {}) - (mine nil) (them nil))) - (testing "That the memo function has a proper cache" - (is (memoized? mine)) - (is (not (memoized? them))) - (is (= 42 (mine 42))) - (is (not (empty? (snapshot mine)))) - (is (not (empty? (lazy-snapshot mine)))) - (is (memo-clear! mine)) - (is (empty? (snapshot mine))) - (is (empty? (lazy-snapshot mine))))) - (testing "That the cache retries in case of exceptions" - (let [access-count (atom 0) - f (factory - (fn [] - (swap! access-count inc) - (throw (Exception.))))] - (is (thrown? Exception (f))) - (is (thrown? Exception (f))) - (is (= 2 @access-count)))) - (testing "That the memo function does not have a race condition" - (let [access-count (atom 0) - slow-identity - (factory (fn [x] - (swap! access-count inc) - (Thread/sleep 100) - x))] - (every? identity (pvalues (slow-identity 5) (slow-identity 5))) - (is (= @access-count 1))))) - -(deftest test-memo - (check-core-features memo)) - - -(deftest test-fifo - (let [mine (fifo identity :fifo/threshold 2)] - ;; First check that the basic memo behavior holds - (check-core-features #(fifo % :fifo/threshold 10)) - - ;; Now check FIFO-specific behavior - (testing "that when the limit threshold is not breached, the cache works like the basic version" - (are [x y] = - 42 (mine 42) - {[42] 42} (snapshot mine) - 43 (mine 43) - {[42] 42, [43] 43} (snapshot mine) - 42 (mine 42) - {[42] 42, [43] 43} (snapshot mine) - [[42] 42, [43] 43] (lazy-snapshot mine))) - (testing "that when the limit is breached, the oldest value is dropped" - (are [x y] = - 44 (mine 44) - {[44] 44, [43] 43} (snapshot mine) - [[44] 44, [43] 43] (lazy-snapshot mine))))) - -(deftest test-lru - ;; First check that the basic memo behavior holds - (check-core-features #(lru % :lru/threshold 10)) - - ;; Now check LRU-specific behavior - (let [mine (lru identity)] - (are [x y] = - 42 (mine 42) - 43 (mine 43) - {[42] 42, [43] 43} (snapshot mine) - 44 (mine 44) - {[44] 44, [43] 43} (snapshot mine) - 43 (mine 43) - 0 (mine 0) - {[0] 0, [43] 43} (snapshot mine) - [[0] 0, [43] 43] (lazy-snapshot mine)))) - - -(deftest test-ttl - ;; First check that the basic memo behavior holds - (check-core-features #(ttl % :ttl/threshold 2000)) - - ;; Now check TTL-specific behavior - (let [mine (ttl identity :ttl/threshold 2000)] - (are [x y] = - 42 (mine 42) - {[42] 42} (snapshot mine)) - (Thread/sleep 3000) - (are [x y] = - 43 (mine 43) - {[43] 43} (snapshot mine) - [[43] 43] (lazy-snapshot mine))) - - ;; CMEMOIZE-15 edge case where TTLCache expires on miss/lookup - (let [mine (ttl identity :ttl/threshold 5) - limit 2000000 - start (System/currentTimeMillis)] - (loop [n 0] - (if-not (mine 42) - (do - (is false (str "Failure on call " n))) - (if (< n limit) - (recur (+ 1 n))))) - (println "ttl test completed" limit "calls in" - (- (System/currentTimeMillis) start) "ms"))) - - -(deftest test-lu - ;; First check that the basic memo behavior holds - (check-core-features #(lu % :lu/threshold 10)) - - ;; Now check LU-specific behavior - (let [mine (lu identity :lu/threshold 3)] - (are [x y] = - 42 (mine 42) - 42 (mine 42) - 43 (mine 43) - 44 (mine 44) - {[44] 44, [42] 42} (snapshot mine) - [[44] 44, [42] 42] (lazy-snapshot mine)))) - - -(defcache PassThrough [impl] - clojure.core.cache/CacheProtocol - (lookup [_ item] - (if (has? impl item) - (lookup impl item) - (delay nil))) - (has? [_ item] - (clojure.core.cache/has? impl item)) - (hit [this item] - (PassThrough. (hit impl item))) - (miss [this item result] - (PassThrough. (miss impl item result))) - (seed [_ base] - (PassThrough. (seed impl base)))) - -(defn memo-pass-through [f limit] - (build-memoizer - #(clojure.core.memoize.PluggableMemoization. %1 (PassThrough. (ttl-cache-factory %3 :ttl %2))) - f - limit - {})) - -(deftest test-snapshot-without-cache-field - (testing "that we can call snapshot against an object without a 'cache' field" - (is (= {} (snapshot (memo-pass-through identity 2000)))))) - - -(deftest test-memoization-utils - (let [CACHE_IDENTITY (:clojure.core.memoize/cache (meta id))] - (testing "that the stored cache is not null" - (is (not= nil CACHE_IDENTITY))) - (testing "that a populated function looks correct at its inception" - (is (memoized? id)) - (is (snapshot id)) - (is (empty? (snapshot id)))) - (testing "that a populated function looks correct after some interactions" - ;; Memoize once - (is (= 42 (id 42))) - ;; Now check to see if it looks right. - (is (find (snapshot id) '(42))) - (is (= 1 (count (snapshot id)))) - ;; Memoize again - (is (= [] (id []))) - (is (find (snapshot id) '([]))) - (is (= 2 (count (snapshot id)))) - (testing "that upon memoizing again, the cache should not change" - (is (= [] (id []))) - (is (find (snapshot id) '([]))) - (is (= 2 (count (snapshot id))))) - (testing "if clearing the cache works as expected" - (is (memo-clear! id)) - (is (empty? (snapshot id))))) - (testing "that after all manipulations, the cache maintains its identity" - (is (identical? CACHE_IDENTITY (:clojure.core.memoize/cache (meta id))))) - (testing "that a cache can be seeded and used normally" - (is (memo-swap! id {[42] 42})) - (is (= 42 (id 42))) - (is (= {[42] 42} (snapshot id))) - (is (= 108 (id 108))) - (is (= {[42] 42 [108] 108} (snapshot id)))) - (testing "that we can get back the original function" - (is (memo-clear! id)) - (is (memo-swap! id {[42] 24})) - (is (= 24 (id 42))) - (is (= 42 ((memo-unwrap id) 42)))))) - -(deftest memo-with-seed-cmemoize-18 - (let [mine (memo identity {[42] 99})] - (testing "that a memo seed works" - (is (= 41 (mine 41))) - (is (= 99 (mine 42))) - (is (= 43 (mine 43))) - (is (= {[41] 41, [42] 99, [43] 43} (snapshot mine))) - (are [x y] = - [[41] 41, [42] 99, [43] 43] (lazy-snapshot mine))))) - -(defn- ^{:clojure.core.memoize/args-fn rest} - ignores-first-arg - "Even tho' this adds all three arguments, we're going to cache it as if - the first argument is irrelevant, so we can verify that the cache will - collapse the argument space." - [a b c] - (+ a b c)) - -(deftest memo-with-args-fn-cmemoize-22 - ;; must use var to preserve metadata - (let [mine (memo #'ignores-first-arg)] - (testing "that args-fn collapses the cache key space" - (is (= 13 (mine 1 2 10))) - (is (= 13 (mine 10 2 1))) - (is (= 13 (mine 10 2 10))) - (is (= {[2 10] 13, [2 1] 13} (snapshot mine)))))) diff -Nru core-memoize-clojure-0.7.1/src/test/clojure/clojure/core/memoize_test.clj core-memoize-clojure-1.0.257/src/test/clojure/clojure/core/memoize_test.clj --- core-memoize-clojure-0.7.1/src/test/clojure/clojure/core/memoize_test.clj 1970-01-01 00:00:00.000000000 +0000 +++ core-memoize-clojure-1.0.257/src/test/clojure/clojure/core/memoize_test.clj 2022-02-11 22:56:55.000000000 +0000 @@ -0,0 +1,261 @@ +; Copyright (c) Rich Hickey and Michael Fogus. All rights reserved. +; The use and distribution terms for this software are covered by the +; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) +; which can be found in the file epl-v10.html at the root of this distribution. +; By using this software in any fashion, you are agreeing to be bound by +; the terms of this license. +; You must not remove this notice, or any other, from this software. + +(ns ^{:doc "A memoization library for Clojure." + :author "Michael Fogus"} + clojure.core.memoize-test + (:use [clojure.test] + [clojure.core.cache :only [defcache lookup has? hit miss seed ttl-cache-factory]] + [clojure.core.memoize])) + +(println "\nTesting with Clojure" (clojure-version)) + +(def id (memo identity)) + +(defn- check-core-features + [factory] + (let [mine (factory identity) + them (memoize identity)] + (testing "That the memo function works the same as core.memoize" + (are [x y] = + (mine 42) (them 42) + (mine ()) (them ()) + (mine []) (them []) + (mine #{}) (them #{}) + (mine {}) (them {}) + (mine nil) (them nil))) + (testing "That the memo function has a proper cache" + (is (memoized? mine)) + (is (not (memoized? them))) + (is (= 42 (mine 42))) + (is (not (empty? (snapshot mine)))) + (is (not (empty? (lazy-snapshot mine)))) + (is (memo-clear! mine)) + (is (empty? (snapshot mine))) + (is (empty? (lazy-snapshot mine))))) + (testing "That the cache retries in case of exceptions" + (let [access-count (atom 0) + f (factory + (fn [] + (swap! access-count inc) + (throw (Exception.))))] + (is (thrown? Exception (f))) + (is (thrown? Exception (f))) + (is (= 2 @access-count)))) + (testing "That the memo function does not have a race condition" + (let [access-count (atom 0) + slow-identity + (factory (fn [x] + (swap! access-count inc) + (Thread/sleep 100) + x))] + (every? identity (pvalues (slow-identity 5) (slow-identity 5))) + (is (= @access-count 1))))) + +(deftest test-memo + (check-core-features memo)) + + +(deftest test-fifo + (let [mine (fifo identity :fifo/threshold 2)] + ;; First check that the basic memo behavior holds + (check-core-features #(fifo % :fifo/threshold 10)) + + ;; Now check FIFO-specific behavior + (testing "that when the limit threshold is not breached, the cache works like the basic version" + (are [x y] = + 42 (mine 42) + {[42] 42} (snapshot mine) + 43 (mine 43) + {[42] 42, [43] 43} (snapshot mine) + 42 (mine 42) + {[42] 42, [43] 43} (snapshot mine) + [[42] 42, [43] 43] (lazy-snapshot mine))) + (testing "that when the limit is breached, the oldest value is dropped" + (are [x y] = + 44 (mine 44) + {[44] 44, [43] 43} (snapshot mine) + [[44] 44, [43] 43] (lazy-snapshot mine))))) + +(deftest test-lru + ;; First check that the basic memo behavior holds + (check-core-features #(lru % :lru/threshold 10)) + + ;; Now check LRU-specific behavior + (let [mine (lru identity)] + (are [x y] = + 42 (mine 42) + 43 (mine 43) + {[42] 42, [43] 43} (snapshot mine) + 44 (mine 44) + {[44] 44, [43] 43} (snapshot mine) + 43 (mine 43) + 0 (mine 0) + {[0] 0, [43] 43} (snapshot mine) + [[0] 0, [43] 43] (lazy-snapshot mine)))) + + +(deftest test-ttl + ;; First check that the basic memo behavior holds + (check-core-features #(ttl % :ttl/threshold 2000)) + + ;; Now check TTL-specific behavior + (let [mine (ttl identity :ttl/threshold 2000)] + (are [x y] = + 42 (mine 42) + {[42] 42} (snapshot mine)) + (Thread/sleep 3000) + (are [x y] = + 43 (mine 43) + {[43] 43} (snapshot mine) + [[43] 43] (lazy-snapshot mine))) + + ;; CMEMOIZE-15 edge case where TTLCache expires on miss/lookup + (let [mine (ttl identity :ttl/threshold 5) + limit 2000000 + start (System/currentTimeMillis)] + (loop [n 0] + (if-not (mine 42) + (do + (is false (str "Failure on call " n))) + (if (< n limit) + (recur (+ 1 n))))) + (println "ttl test completed" limit "calls in" + (- (System/currentTimeMillis) start) "ms"))) + + +(deftest test-lu + ;; First check that the basic memo behavior holds + (check-core-features #(lu % :lu/threshold 10)) + + ;; Now check LU-specific behavior + (let [mine (lu identity :lu/threshold 3)] + (are [x y] = + 42 (mine 42) + 42 (mine 42) + 43 (mine 43) + 44 (mine 44) + {[44] 44, [42] 42} (snapshot mine) + [[44] 44, [42] 42] (lazy-snapshot mine)))) + + +(defcache PassThrough [impl] + clojure.core.cache/CacheProtocol + (lookup [_ item] + (if (has? impl item) + (lookup impl item) + (delay nil))) + (has? [_ item] + (clojure.core.cache/has? impl item)) + (hit [this item] + (PassThrough. (hit impl item))) + (miss [this item result] + (PassThrough. (miss impl item result))) + (seed [_ base] + (PassThrough. (seed impl base)))) + +(defn memo-pass-through-1 [f limit] + (build-memoizer + #(clojure.core.memoize.PluggableMemoization. %1 (PassThrough. (ttl-cache-factory %3 :ttl %2))) + f + limit + {})) + +(deftest test-snapshot-without-cache-field-1 + (testing "that we can call snapshot against an object without a 'cache' field" + (is (= {} (snapshot (memo-pass-through-1 identity 2000)))))) + +(defn memo-pass-through-2 [f limit] + (memoizer f (PassThrough. (ttl-cache-factory {} :ttl limit)))) + +(deftest test-snapshot-without-cache-field-2 + (testing "that we can call snapshot against an object without a 'cache' field" + (is (= {} (snapshot (memo-pass-through-2 identity 2000)))))) + +(deftest test-memoization-utils + (let [CACHE_IDENTITY (:clojure.core.memoize/cache (meta id))] + (testing "that the stored cache is not null" + (is (not= nil CACHE_IDENTITY))) + (testing "that a populated function looks correct at its inception" + (is (memoized? id)) + (is (snapshot id)) + (is (empty? (snapshot id)))) + (testing "that a populated function looks correct after some interactions" + ;; Memoize once + (is (= 42 (id 42))) + ;; Now check to see if it looks right. + (is (find (snapshot id) '(42))) + (is (= 1 (count (snapshot id)))) + ;; Memoize again + (is (= [] (id []))) + (is (find (snapshot id) '([]))) + (is (= 2 (count (snapshot id)))) + (testing "that upon memoizing again, the cache should not change" + (is (= [] (id []))) + (is (find (snapshot id) '([]))) + (is (= 2 (count (snapshot id))))) + (testing "if clearing the cache works as expected" + (is (memo-clear! id)) + (is (empty? (snapshot id))))) + (testing "that after all manipulations, the cache maintains its identity" + (is (identical? CACHE_IDENTITY (:clojure.core.memoize/cache (meta id))))) + (testing "that a cache can be swapped and used normally" + (is (memo-swap! id clojure.core.cache/miss [42] 42)) + (is (= 42 (id 42))) + (is (= {[42] 42} (snapshot id))) + (is (= 108 (id 108))) + (is (= {[42] 42 [108] 108} (snapshot id)))) + (testing "that a cache can be seeded and used normally" + (is (memo-reset! id {[42] 42})) + (is (= 42 (id 42))) + (is (= {[42] 42} (snapshot id))) + (is (= 108 (id 108))) + (is (= {[42] 42 [108] 108} (snapshot id)))) + (testing "that we can get back the original function" + (is (memo-clear! id)) + (is (memo-reset! id {[42] 24})) + (is (= 24 (id 42))) + (is (= 42 ((memo-unwrap id) 42)))) + (testing "that a cache can be seeded and used normally - deprecated memo-swap!" + (is (memo-swap! id {[42] 42})) + (is (= 42 (id 42))) + (is (= {[42] 42} (snapshot id))) + (is (= 108 (id 108))) + (is (= {[42] 42 [108] 108} (snapshot id)))) + (testing "that we can get back the original function - deprecated memo-swap!" + (is (memo-clear! id)) + (is (memo-swap! id {[42] 24})) + (is (= 24 (id 42))) + (is (= 42 ((memo-unwrap id) 42)))))) + +(deftest memo-with-seed-cmemoize-18 + (let [mine (memo identity {[42] 99})] + (testing "that a memo seed works" + (is (= 41 (mine 41))) + (is (= 99 (mine 42))) + (is (= 43 (mine 43))) + (is (= {[41] 41, [42] 99, [43] 43} (snapshot mine))) + (are [x y] = + [[41] 41, [42] 99, [43] 43] (lazy-snapshot mine))))) + +(defn- ^{:clojure.core.memoize/args-fn rest} + ignores-first-arg + "Even tho' this adds all three arguments, we're going to cache it as if + the first argument is irrelevant, so we can verify that the cache will + collapse the argument space." + [a b c] + (+ a b c)) + +(deftest memo-with-args-fn-cmemoize-22 + ;; must use var to preserve metadata + (let [mine (memo #'ignores-first-arg)] + (testing "that args-fn collapses the cache key space" + (is (= 13 (mine 1 2 10))) + (is (= 13 (mine 10 2 1))) + (is (= 13 (mine 10 2 10))) + (is (= {[2 10] 13, [2 1] 13} (snapshot mine))))))