Skip to content

Commit

Permalink
Added tests for JDT persistence / project value identifiers.
Browse files Browse the repository at this point in the history
  • Loading branch information
cderoove committed Feb 5, 2015
1 parent 878859f commit f1d43ca
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 10 deletions.
5 changes: 0 additions & 5 deletions damp.ekeko.plugin.test/.classpath
Expand Up @@ -3,10 +3,5 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="lib" path="classes">
<attributes>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>
2 changes: 1 addition & 1 deletion damp.ekeko.plugin.test/META-INF/MANIFEST.MF
Expand Up @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: Tycho-compatible unit tests for Ekeko
Bundle-SymbolicName: damp.ekeko.plugin.test
Bundle-Version: 2.0.9.qualifier
Fragment-Host: damp.ekeko.plugin
Fragment-Host: damp.ekeko.plugin;bundle-version="2.0.9.qualifier"
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Require-Bundle: org.junit,
org.eclipse.ui.ide,
Expand Down
7 changes: 7 additions & 0 deletions damp.ekeko.plugin.test/src/test/damp/EkekoTest.java
Expand Up @@ -41,6 +41,13 @@ public void testEkekoJDTSuite() {
}


@Test
public void testEkekoJDTPersistence() {
EkekoTestHelper.testClojureNamespace(myBundle,"test.damp.ekeko.persistence");
}






Expand Down
70 changes: 70 additions & 0 deletions damp.ekeko.plugin.test/src/test/damp/ekeko/persistence.clj
@@ -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)
)


7 changes: 3 additions & 4 deletions damp.ekeko.plugin/EkekoPluginLauncher.launch

Large diffs are not rendered by default.

0 comments on commit f1d43ca

Please sign in to comment.