agrostis / diff-match-patch Goto Github PK
View Code? Open in Web Editor NEWA Common Lisp port of Neil Fraser's library of the same name
License: Apache License 2.0
A Common Lisp port of Neil Fraser's library of the same name
License: Apache License 2.0
The test diff-timout fails on slow machines, because the code outside diff-bisect (where it calls past-diff-deadline) is not limited by *diff-timeout*.
This specific test fails for slow machines, but it means similar failures for faster machines on more complex diff operations.
It should either have a way to propagate reaching the deadline out of diff-bisect to the callers, or check in other places too.
The function apply-hunk is calling the function cleanup-semantic.shift-lossless with only one argument, missing the test argument.
Hello,
I'm writing a little test to try to understand how to use diff-patch-match.
Everything seems to work nicely for char diffs, but with line patches, I cannot reconstitute the original sequences of lines: the last two assert fail. Why? Is this a bug or did I do something wrong?
(accessorily, it might be nice to have a equal operator to compare hunks before and after writing and reading back).
(ql:quickload :diff-match-patch)
(defparameter *one* "Hao Wang, logicien americain.
L'algorithme en question a été publié en 1960 dans l'IBM Journal,
article intitule \"Toward Mechanical Mathematics\", avec des variantes et
une extension au calcul des prédicats. Il s'agit ici du \"premier
programme\" de Wang, systeme \"P\".
Il observe que les preuves engendrées sont \"essentiellement des arbres\",
et annonce que la machine a démontre 220 théorèmes du calcul des
propositions (tautologies) en 3 minutes. Il en tire argument pour la
supériorité d'une approche algorithmique par rapport à une approche
heuristique comme celle du \"Logic Theorist\" de Newell, Shaw et Simon (à
partir de 1956 sur la machine JOHNNIAC de la Rand Corporation): un débat
qui dure encore...
Cet algorithme a été popularisé par J. McCarthy, comme exemplefanion
d'application de LISP. Il figure dans le manuel de la première version
de LISP (LISP 1, sur IBM 704 justement, le manuel est daté de Mars
1960), et il a été repris dans le celebre \"LISP 1.5 Programmer's Manual\"
publié en 1962 par MIT Press, un des maîtreslivres de l'Informatique.
")
(defparameter *two* "Hao Wang, logicien americain.
'algorithme en question a été publié en 1960 dans l'IBM
Journal, article intitule \"Toward Mechanical Mathematics\", avec des
variantes et une extension au calcul des prédicats. Il s'agit
ici du \"premier programme\" de Wang, systeme \"P\".
L'article a été écrit en 1958, et les expériences effectuées sur IBM
704 machine à lampes, 32 k mots de 36 bits, cellelà même qui vit
naître LISP à la même époque. Le programme a été écrit en assembleur
et l'auteur estime que \"there is very little in the program that is
not straightforward\".
Il observe que les preuves engendrées sont \"essentiellement des
arbres\", et annonce que la machine a démontre 220 théorèmes du
calcul des propositions en 3 minutes. Il en tire
argument pour la supériorité d'une approche algorithmique par
rapport à une approche heuristique comme celle du \"Logic Theorist\"
de Newell, Shaw et Simon (à partir de 1956 sur la machine JOHNNIAC de
la Rand Corporation): un débat qui dure encore...
Cet algorithme a été popularisé par J. McCarthy, comme
exemplefanion d'application de LISP. Il figure dans le manuel de la
première version de LISP, et il a été repris dans le celebre
\"LISP 1.5 Programmer's Manual\" publié en 1962 par MIT Press, un des
maîtreslivres de l'Informatique. ")
;; char diffs
(defparameter *d* (diff-match-patch:diff *one* *two*))
(assert (string= *one* (diff-match-patch:diff-origin *d*)))
(assert (string= *two* (diff-match-patch:diff-destination *d*)))
(defparameter *p*
(diff-match-patch:make-patch *one* *two*))
(defparameter *pp*
(with-input-from-string (inp (with-output-to-string (out)
(diff-match-patch:write-chars-patch *p* out)))
(diff-match-patch:read-chars-patch inp)))
;; (assert (equalp *p* *pp*)) ;; Why not? ;-)
(multiple-value-bind (new appliedp) (diff-match-patch:apply-patch *p* *one*)
(assert (every (function identity) appliedp))
(assert (string= *two* new)))
(multiple-value-bind (new appliedp) (diff-match-patch:apply-patch *pp* *one*)
(assert (every (function identity) appliedp))
(assert (string= *two* new)))
;; line diffs
(defparameter *onel* (split-sequence #\newline *one*))
(defparameter *twol* (split-sequence #\newline *two*))
(defparameter *l* (diff-match-patch:diff *onel* *twol* :test (function string=)))
(assert (equal *onel* (diff-match-patch:diff-origin *l*)))
(assert (equal *twol* (diff-match-patch:diff-destination *l*)))
(defparameter *q* (diff-match-patch:make-patch :diffs *l*))
(defparameter *qq*
(with-input-from-string (inp (with-output-to-string (out)
(diff-match-patch:write-lines-patch *q* out)))
(diff-match-patch:read-lines-patch inp)))
;; (assert (equalp *q* *qq*)) ;; Why not? ;-)
(multiple-value-bind (new appliedp) (diff-match-patch:apply-patch *q* *onel*)
(assert (every (function identity) appliedp))
(assert (equal *twol* new)))
(multiple-value-bind (new appliedp) (diff-match-patch:apply-patch *qq* *onel*)
(assert (every (function identity) appliedp)) ; FAILS - WHY?
(assert (equal *twol* new))) ; FAILS - WHY?
The function join does apply #'concatenate on its argument (after removing empty elements), which may end up trying to call concatenate with too many arguments (more than call-arguments-limit).
In the tests, in the diff-timeout test it ends up calling it with 4096 arguments, which at least on LispWorks is bigger than call-arguments-limit (2047). Since the file is compiled with safety 0, it may not give an error, but may crash badly as a result.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.