Skip to content

Commit

Permalink
Allow foo// meaning the function / in namespace foo
Browse files Browse the repository at this point in the history
Added regression tests

Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
  • Loading branch information
chrismgray authored and stuarthalloway committed May 24, 2013
1 parent 4a29ce2 commit 88cad25
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
10 changes: 1 addition & 9 deletions src/jvm/clojure/lang/LispReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class LispReader{
static IFn[] macros = new IFn[256];
static IFn[] dispatchMacros = new IFn[256];
//static Pattern symbolPat = Pattern.compile("[:]?([\\D&&[^:/]][^:/]*/)?[\\D&&[^:/]][^:/]*");
static Pattern symbolPat = Pattern.compile("[:]?([\\D&&[^/]].*/)?([\\D&&[^/]][^/]*)");
static Pattern symbolPat = Pattern.compile("[:]?([\\D&&[^/]].*/)?(/|[\\D&&[^/]][^/]*)");
//static Pattern varPat = Pattern.compile("([\\D&&[^:\\.]][^:\\.]*):([\\D&&[^:\\.]][^:\\.]*)");
//static Pattern intPat = Pattern.compile("[-+]?[0-9]+\\.?");
static Pattern intPat =
Expand Down Expand Up @@ -309,14 +309,6 @@ else if(s.equals("false"))
{
return RT.F;
}
else if(s.equals("/"))
{
return SLASH;
}
else if(s.equals("clojure.core//"))
{
return CLOJURE_SLASH;
}
Object ret = null;

ret = matchSymbol(s);
Expand Down
2 changes: 1 addition & 1 deletion src/jvm/clojure/lang/Symbol.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ static public Symbol intern(String ns, String name){
}

static public Symbol intern(String nsname){
int i = nsname.lastIndexOf('/');
int i = nsname.indexOf('/');
if(i == -1 || nsname.equals("/"))
return new Symbol(null, nsname.intern());
else
Expand Down
8 changes: 8 additions & 0 deletions test/clojure/test_clojure/reader.clj
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,14 @@

(deftest t-read)

(deftest division
(is (= clojure.core// /))
(binding [*ns* *ns*]
(eval '(do (ns foo
(:require [clojure.core :as bar])
(:use [clojure.test]))
(is (= clojure.core// bar//))))))

(deftest Instants
(testing "Instants are read as java.util.Date by default"
(is (= java.util.Date (class #inst "2010-11-12T13:14:15.666"))))
Expand Down

0 comments on commit 88cad25

Please sign in to comment.