Skip to content

Commit 3893258

Browse files
Abdussalam Abdurrahmanmarijnh
authored andcommitted
[clojure mode] Add tests.
This PR also fixes a few minor issues revealed by the tests: - Keywords or numbers following a single quote (') were being styled as `variable` instead of `atom` or `number`, respectively. - Single quote (') was missing on the list of valid symbol characters. Such symbols include `*'` and `+'`. - `new` and `when-some` were missing on the keyword list. There are a few other symbols that are also missing on the list that I plan to add later (e.g., `as->`, `cond->`, `condp->`, etc.) - `tests.keyword_char` and `tests.symbol` had redundant characters in them. - `+` and `+'` were missing on the core symbols list as a regression introduced by commit 74fca7c . Note that there are some `FIXME`es in the tests. I'm planning to fix them soon.
1 parent 23695f2 commit 3893258

File tree

3 files changed

+614
-8
lines changed

3 files changed

+614
-8
lines changed

mode/clojure/clojure.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ CodeMirror.defineMode("clojure", function (options) {
3333
"defstruct", "deftype", "defprotocol", "defrecord", "defproject", "deftest", "slice", "defalias",
3434
"defhinted", "defmacro-", "defn-memo", "defnk", "defonce-", "defunbound", "defunbound-",
3535
"defvar", "defvar-", "let", "letfn", "do", "case", "cond", "condp", "for", "loop", "recur", "when",
36-
"when-not", "when-let", "when-first", "if", "if-let", "if-not", ".", "..", "->", "->>", "doto",
36+
"when-not", "when-let", "when-first", "when-some", "if", "if-let", "if-not", ".", "..", "->", "->>", "doto",
3737
"and", "or", "dosync", "doseq", "dotimes", "dorun", "doall", "load", "import", "unimport", "ns",
3838
"in-ns", "refer", "try", "catch", "finally", "throw", "with-open", "with-local-vars", "binding",
39-
"gen-class", "gen-and-load-class", "gen-and-save-class", "handler-case", "handle"];
39+
"gen-class", "gen-and-load-class", "gen-and-save-class", "handler-case", "handle", "new"];
4040
var commonBuiltins = ["*", "*'", "*1", "*2", "*3", "*agent*", "*allow-unresolved-vars*", "*assert*",
4141
"*clojure-version*", "*command-line-args*", "*compile-files*", "*compile-path*", "*compiler-options*",
4242
"*data-readers*", "*default-data-reader-fn*", "*e", "*err*", "*file*", "*flush-on-newline*", "*fn-loader*",
4343
"*in*", "*math-context*", "*ns*", "*out*", "*print-dup*", "*print-length*", "*print-level*", "*print-meta*",
4444
"*print-namespace-maps*", "*print-readably*", "*read-eval*", "*reader-resolver*", "*source-path*",
4545
"*suppress-read*", "*unchecked-math*", "*use-context-classloader*", "*verbose-defrecords*",
46-
"*warn-on-reflection*'", "-", "-'", "->", "->>", "->ArrayChunk", "->Eduction", "->Vec", "->VecNode",
46+
"*warn-on-reflection*", "+", "+'", "-", "-'", "->", "->>", "->ArrayChunk", "->Eduction", "->Vec", "->VecNode",
4747
"->VecSeq", "-cache-protocol-fn", "-reset-methods", "..", "/", "<", "<=", "=", "==", ">", ">=",
4848
"EMPTY-NODE", "Inst", "StackTraceElement->vec", "Throwable->map", "accessor", "aclone", "add-classpath",
4949
"add-watch", "agent", "agent-error", "agent-errors", "aget", "alength", "alias", "all-ns", "alter",
@@ -115,7 +115,7 @@ CodeMirror.defineMode("clojure", function (options) {
115115
"zipmap"];
116116
var commonIndentKeys = [
117117
// Built-ins
118-
"ns", "fn", "def", "defn", "defmethod", "bound-fn", "if", "if-not", "case", "condp", "when", "while", "when-not", "when-first", "do", "future", "comment", "doto",
118+
"ns", "fn", "def", "defn", "defmethod", "bound-fn", "if", "if-not", "case", "condp", "when", "while", "when-not", "when-first", "when-some", "do", "future", "comment", "doto",
119119
"locking", "proxy", "with-open", "with-precision", "reify", "deftype", "defrecord", "defprotocol", "extend", "extend-protocol", "extend-type",
120120
"try", "catch",
121121
// Binding forms
@@ -136,12 +136,11 @@ CodeMirror.defineMode("clojure", function (options) {
136136

137137
var tests = {
138138
digit: /\d/,
139-
digit_or_colon: /[\d:]/,
140139
hex: /[0-9a-f]/i,
141140
sign: /[+-]/,
142141
exponent: /e/i,
143-
keyword_char: /[^\s\(\[\;\)\]]/,
144-
symbol: /[\w*+!\-\._?:<>\/\xa1-\uffff]/,
142+
keyword_char: /[^\s;()\[\]{}]/,
143+
symbol: /[\w*+!\-._?:<>\/'\xa1-\uffff]/,
145144
block_indent: /^(?:def|with)[^\/]+$|\/(?:def|with)/
146145
};
147146

@@ -252,7 +251,7 @@ CodeMirror.defineMode("clojure", function (options) {
252251
} else if (ch == "\\") {
253252
eatCharacter(stream);
254253
returnType = CHARACTER;
255-
} else if (ch == "'" && !( tests.digit_or_colon.test(stream.peek()) )) {
254+
} else if (ch == "'") {
256255
returnType = ATOM;
257256
} else if (ch == ";") { // comment
258257
stream.skipToEnd(); // rest of the line is a comment

0 commit comments

Comments
 (0)