Skip to content

Commit

Permalink
Adding Basic Clojure Project (May not run...)
Browse files Browse the repository at this point in the history
  • Loading branch information
walterg2 committed Jan 8, 2012
1 parent c682d9b commit eac6814
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 0 deletions.
7 changes: 7 additions & 0 deletions clojure/.gitignore
@@ -0,0 +1,7 @@
classes/**/*
classes/*
lib/**/*
lib/*
.lein*
*~
**/*~
39 changes: 39 additions & 0 deletions clojure/README.md
@@ -0,0 +1,39 @@
Dead Simple Clojure Sample
==========================

The newest swank-clojure jar greately simplifies running a Clojure REPL in emacs, provided that you have
a Clojure project set up.

This is the simplest clojure project I could think of to try out the newest swank-clojure features.

Requires:

- Leiningen

- A recent clojure-mode.el, with proper .emacs require statements.


__These notes are very incomplete. I will fill in with links and detailed directions as I go.__

You have to run `lein deps` in the project directory to install all needed dependancies.

Once in Emacs `M-x clojure-jack-in` will get you a clojure REPL with classpath set to include all your project libs.

You do _not_ need slime installed in your emacs for this to work.

You can run the test suite(!!) by running `lein test` from the command line.

From the clojure REPL in emacs you can run tests this way:

user> (use 'clojure.test)
nil
user> (use 'simple-test)
nil
user> (run-tests 'simple-test)

Testing simple-test

Ran 2 tests containing 5 assertions.
0 failures, 0 errors.
{:type :summary, :pass 5, :test 2, :error 0, :fail 0}
user>
5 changes: 5 additions & 0 deletions clojure/project.clj
@@ -0,0 +1,5 @@
(defproject test-project "0.1.0-SNAPSHOT"
:description "FIXME: write this!"
:dependencies [[org.clojure/clojure "1.3.0"]]
)

12 changes: 12 additions & 0 deletions clojure/src/simple.clj
@@ -0,0 +1,12 @@
(ns simple )
(defn hello
([] "hello world!")
([name] (str "hello " name "!")))

(defn addem
"Add stuff"
([] 0)
([n] n)
([n m] (+ n m))
([n m & more] (reduce + (flatten (list n m more))))
)
12 changes: 12 additions & 0 deletions clojure/test/simple_test.clj
@@ -0,0 +1,12 @@
(ns simple-test
(:use clojure.test)
(:use simple))

(deftest simple-test
(is (= (hello) "hello world!"))
(is (= (hello "test") "hello test!")))

(deftest addem-test
(is (= (addem) 0))
(is (= (addem 5) 5))
(is (= (addem 3 4) 7)))

0 comments on commit eac6814

Please sign in to comment.