Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for JDT persistence / project value identifiers.
- Loading branch information
Showing
5 changed files
with
81 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
damp.ekeko.plugin.test/src/test/damp/ekeko/persistence.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
(ns | ||
^{:doc "Test suite for persistence of JDT values." | ||
:author "Coen De Roover"} | ||
test.damp.ekeko.persistence | ||
(:refer-clojure :exclude [== type declare record?]) | ||
(:require [clojure.core.logic :exclude [is] :as l]) | ||
(:require [test.damp [ekeko :as test]]) | ||
(:require [damp.ekeko.jdt | ||
[javaprojectmodel :as javaprojectmodel] | ||
[astnode :as astnode] | ||
]) | ||
(:import [org.eclipse.jdt.core.dom CompilationUnit]) | ||
(:use clojure.test)) | ||
|
||
|
||
|
||
|
||
;; Persisting JDT AST nodes | ||
;; ------------------------ | ||
|
||
(deftest | ||
^{:doc "For all nodes compilation units cu, cu has to be persistable."} | ||
persist-compilationunits | ||
(let [cus | ||
(mapcat (fn [jpm] (.getCompilationUnits jpm)) | ||
(javaprojectmodel/java-project-models))] | ||
(doseq [cu cus] | ||
(let [serialized (astnode/astnode-as-persistent-string cu) | ||
deserialized (astnode/astnode-from-persistent-string serialized)] | ||
(is (instance? CompilationUnit deserialized)))))) | ||
|
||
|
||
|
||
;; Looking up AST nodes in project by identifier | ||
;; --------------------------------------------- | ||
|
||
(deftest | ||
^{:doc "For all AST nodes returned by Ekeko, an equivalent AST node should be found in a workspace project."} | ||
lookup-equivalent-nodes | ||
(is (reduce (fn [sofar t] | ||
(let [exp (first t) | ||
expid (astnode/project-value-identifier exp) | ||
equivalent (astnode/corresponding-project-value expid)] | ||
(and sofar (= (str exp) (str equivalent))))) | ||
(damp.ekeko/ekeko [?e ?key] (damp.ekeko.jdt.ast/ast ?key ?e))))) | ||
|
||
;; Test suite | ||
;; ---------- | ||
|
||
(deftest | ||
test-suite | ||
(let [testproject "TestCase-JDT-CompositeVisitor"] | ||
(test/against-project-named testproject false persist-compilationunits) | ||
(test/against-project-named testproject false lookup-equivalent-nodes) | ||
|
||
) | ||
) | ||
|
||
(defn | ||
test-ns-hook | ||
[] | ||
(test/with-ekeko-disabled test-suite)) | ||
|
||
|
||
(comment | ||
;;Example repl session | ||
(run-tests) | ||
) | ||
|
||
|
Large diffs are not rendered by default.
Oops, something went wrong.