test.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999
  1. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  2. // Distributed under an MIT license: https://codemirror.net/LICENSE
  3. ;(function () {
  4. var mode = CodeMirror.getMode({ indentUnit: 2 }, 'clojure')
  5. function MT(name) {
  6. test.mode(name, mode, Array.prototype.slice.call(arguments, 1))
  7. }
  8. MT('atoms', '[atom false]', '[atom nil]', '[atom true]')
  9. MT('keywords', '[atom :foo]', '[atom ::bar]', '[atom :foo/bar]', '[atom :foo.bar/baz]')
  10. MT(
  11. 'numbers',
  12. '[number 42] [number +42] [number -421]',
  13. '[number 42N] [number +42N] [number -42N]',
  14. '[number 0.42] [number +0.42] [number -0.42]',
  15. '[number 42M] [number +42M] [number -42M]',
  16. '[number 42.42M] [number +42.42M] [number -42.42M]',
  17. '[number 1/42] [number +1/42] [number -1/42]',
  18. '[number 0x42af] [number +0x42af] [number -0x42af]',
  19. '[number 0x42AF] [number +0x42AF] [number -0x42AF]',
  20. '[number 1e2] [number 1e+2] [number 1e-2]',
  21. '[number +1e2] [number +1e+2] [number +1e-2]',
  22. '[number -1e2] [number -1e+2] [number -1e-2]',
  23. '[number -1.0e2] [number -0.1e+2] [number -1.01e-2]',
  24. '[number 1E2] [number 1E+2] [number 1E-2]',
  25. '[number +1E2] [number +1E+2] [number +1E-2]',
  26. '[number -1E2] [number -1E+2] [number -1E-2]',
  27. '[number -1.0E2] [number -0.1E+2] [number -1.01E-2]',
  28. '[number 2r101010] [number +2r101010] [number -2r101010]',
  29. '[number 2r101010] [number +2r101010] [number -2r101010]',
  30. '[number 8r52] [number +8r52] [number -8r52]',
  31. '[number 36rhello] [number +36rhello] [number -36rhello]',
  32. '[number 36rz] [number +36rz] [number -36rz]',
  33. '[number 36rZ] [number +36rZ] [number -36rZ]',
  34. // invalid numbers
  35. '[error 42foo]',
  36. '[error 42Nfoo]',
  37. '[error 42Mfoo]',
  38. '[error 42.42Mfoo]',
  39. '[error 42.42M!]',
  40. '[error 42!]',
  41. '[error 0x42afm]'
  42. )
  43. MT(
  44. 'characters',
  45. '[string-2 \\1]',
  46. '[string-2 \\a]',
  47. '[string-2 \\a\\b\\c]',
  48. '[string-2 \\#]',
  49. '[string-2 \\\\]',
  50. '[string-2 \\"]',
  51. '[string-2 \\(]',
  52. '[string-2 \\A]',
  53. '[string-2 \\backspace]',
  54. '[string-2 \\formfeed]',
  55. '[string-2 \\newline]',
  56. '[string-2 \\space]',
  57. '[string-2 \\return]',
  58. '[string-2 \\tab]',
  59. '[string-2 \\u1000]',
  60. '[string-2 \\uAaAa]',
  61. '[string-2 \\u9F9F]',
  62. '[string-2 \\o123]',
  63. '[string-2 \\符]',
  64. '[string-2 \\シ]',
  65. '[string-2 \\ۇ]',
  66. // FIXME
  67. // "[string-2 \\🙂]",
  68. // invalid character literals
  69. '[error \\abc]',
  70. '[error \\a123]',
  71. '[error \\a!]',
  72. '[error \\newlines]',
  73. '[error \\NEWLINE]',
  74. '[error \\u9F9FF]',
  75. '[error \\o1234]'
  76. )
  77. MT(
  78. 'strings',
  79. '[string "I\'m a teapot."]',
  80. '[string "I\'m a \\"teapot\\"."]',
  81. '[string "I\'m]', // this is
  82. '[string a]', // a multi-line
  83. '[string teapot."]' // string
  84. // TODO unterminated (multi-line) strings?
  85. )
  86. MT('comments', '[comment ; this is an in-line comment.]', '[comment ;; this is a line comment.]', '[keyword comment]', '[bracket (][comment comment (foo 1 2 3)][bracket )]')
  87. MT(
  88. 'reader macro characters',
  89. '[meta #][variable _]',
  90. '[meta #][variable -Inf]',
  91. '[meta ##][variable Inf]',
  92. '[meta ##][variable NaN]',
  93. '[meta @][variable x]',
  94. '[meta ^][bracket {][atom :tag] [variable String][bracket }]',
  95. '[meta `][bracket (][builtin f] [variable x][bracket )]',
  96. '[meta ~][variable foo#]',
  97. "[meta '][number 1]",
  98. "[meta '][atom :foo]",
  99. '[meta \'][string "foo"]',
  100. "[meta '][variable x]",
  101. "[meta '][bracket (][builtin a] [variable b] [variable c][bracket )]",
  102. "[meta '][bracket [[][variable a] [variable b] [variable c][bracket ]]]",
  103. "[meta '][bracket {][variable a] [number 1] [atom :foo] [number 2] [variable c] [number 3][bracket }]",
  104. "[meta '#][bracket {][variable a] [number 1] [atom :foo][bracket }]"
  105. )
  106. MT(
  107. 'symbols',
  108. '[variable foo!]',
  109. '[variable foo#]',
  110. '[variable foo$]',
  111. '[variable foo&]',
  112. "[variable foo']",
  113. '[variable foo*]',
  114. '[variable foo+]',
  115. '[variable foo-]',
  116. '[variable foo.]',
  117. '[variable foo/bar]',
  118. '[variable foo:bar]',
  119. '[variable foo<]',
  120. '[variable foo=]',
  121. '[variable foo>]',
  122. '[variable foo?]',
  123. '[variable foo_]',
  124. '[variable foo|]',
  125. '[variable foobarBaz]',
  126. '[variable foo¡]',
  127. '[variable 符号]',
  128. '[variable シンボル]',
  129. '[variable ئۇيغۇر]',
  130. '[variable 🙂❤🇺🇸]',
  131. // invalid symbols
  132. '[error 3foo]',
  133. '[error 3+]',
  134. '[error 3|]',
  135. '[error 3_]'
  136. )
  137. MT(
  138. 'numbers and other forms',
  139. '[number 42][bracket (][builtin foo][bracket )]',
  140. '[number 42][bracket [[][variable foo][bracket ]]]',
  141. '[number 42][meta #][bracket {][variable foo][bracket }]',
  142. '[number 42][bracket {][atom :foo] [variable bar][bracket }]',
  143. '[number 42][meta `][variable foo]',
  144. '[number 42][meta ~][variable foo]',
  145. '[number 42][meta #][variable foo]'
  146. )
  147. var specialForms = ['.', 'catch', 'def', 'do', 'if', 'monitor-enter', 'monitor-exit', 'new', 'quote', 'recur', 'set!', 'throw', 'try', 'var']
  148. MT('should highlight special forms as keywords', typeTokenPairs('keyword', specialForms))
  149. var coreSymbols1 = [
  150. '*',
  151. "*'",
  152. '*1',
  153. '*2',
  154. '*3',
  155. '*agent*',
  156. '*allow-unresolved-vars*',
  157. '*assert*',
  158. '*clojure-version*',
  159. '*command-line-args*',
  160. '*compile-files*',
  161. '*compile-path*',
  162. '*compiler-options*',
  163. '*data-readers*',
  164. '*default-data-reader-fn*',
  165. '*e',
  166. '*err*',
  167. '*file*',
  168. '*flush-on-newline*',
  169. '*fn-loader*',
  170. '*in*',
  171. '*math-context*',
  172. '*ns*',
  173. '*out*',
  174. '*print-dup*',
  175. '*print-length*',
  176. '*print-level*',
  177. '*print-meta*',
  178. '*print-namespace-maps*',
  179. '*print-readably*',
  180. '*read-eval*',
  181. '*reader-resolver*',
  182. '*source-path*',
  183. '*suppress-read*',
  184. '*unchecked-math*',
  185. '*use-context-classloader*',
  186. '*verbose-defrecords*',
  187. '*warn-on-reflection*',
  188. '+',
  189. "+'",
  190. '-',
  191. "-'",
  192. '->',
  193. '->>',
  194. '->ArrayChunk',
  195. '->Eduction',
  196. '->Vec',
  197. '->VecNode',
  198. '->VecSeq',
  199. '-cache-protocol-fn',
  200. '-reset-methods',
  201. '..',
  202. '/',
  203. '<',
  204. '<=',
  205. '=',
  206. '==',
  207. '>',
  208. '>=',
  209. 'EMPTY-NODE',
  210. 'Inst',
  211. 'StackTraceElement->vec',
  212. 'Throwable->map',
  213. 'accessor',
  214. 'aclone',
  215. 'add-classpath',
  216. 'add-watch',
  217. 'agent',
  218. 'agent-error',
  219. 'agent-errors',
  220. 'aget',
  221. 'alength',
  222. 'alias',
  223. 'all-ns',
  224. 'alter',
  225. 'alter-meta!',
  226. 'alter-var-root',
  227. 'amap',
  228. 'ancestors',
  229. 'and',
  230. 'any?',
  231. 'apply',
  232. 'areduce',
  233. 'array-map',
  234. 'as->',
  235. 'aset',
  236. 'aset-boolean',
  237. 'aset-byte',
  238. 'aset-char',
  239. 'aset-double',
  240. 'aset-float',
  241. 'aset-int',
  242. 'aset-long',
  243. 'aset-short',
  244. 'assert',
  245. 'assoc',
  246. 'assoc!',
  247. 'assoc-in',
  248. 'associative?',
  249. 'atom',
  250. 'await',
  251. 'await-for',
  252. 'await1',
  253. 'bases',
  254. 'bean',
  255. 'bigdec',
  256. 'bigint',
  257. 'biginteger',
  258. 'binding',
  259. 'bit-and',
  260. 'bit-and-not',
  261. 'bit-clear',
  262. 'bit-flip',
  263. 'bit-not',
  264. 'bit-or',
  265. 'bit-set',
  266. 'bit-shift-left',
  267. 'bit-shift-right',
  268. 'bit-test',
  269. 'bit-xor',
  270. 'boolean',
  271. 'boolean-array',
  272. 'boolean?',
  273. 'booleans',
  274. 'bound-fn',
  275. 'bound-fn*',
  276. 'bound?',
  277. 'bounded-count',
  278. 'butlast',
  279. 'byte',
  280. 'byte-array',
  281. 'bytes',
  282. 'bytes?',
  283. 'case',
  284. 'cast',
  285. 'cat',
  286. 'char',
  287. 'char-array',
  288. 'char-escape-string',
  289. 'char-name-string',
  290. 'char?',
  291. 'chars',
  292. 'chunk',
  293. 'chunk-append',
  294. 'chunk-buffer',
  295. 'chunk-cons',
  296. 'chunk-first',
  297. 'chunk-next',
  298. 'chunk-rest',
  299. 'chunked-seq?',
  300. 'class',
  301. 'class?',
  302. 'clear-agent-errors',
  303. 'clojure-version',
  304. 'coll?',
  305. 'comment',
  306. 'commute',
  307. 'comp',
  308. 'comparator',
  309. 'compare',
  310. 'compare-and-set!',
  311. 'compile',
  312. 'complement',
  313. 'completing',
  314. 'concat',
  315. 'cond',
  316. 'cond->',
  317. 'cond->>',
  318. 'condp',
  319. 'conj',
  320. 'conj!',
  321. 'cons',
  322. 'constantly',
  323. 'construct-proxy',
  324. 'contains?',
  325. 'count',
  326. 'counted?',
  327. 'create-ns',
  328. 'create-struct',
  329. 'cycle',
  330. 'dec',
  331. "dec'",
  332. 'decimal?',
  333. 'declare',
  334. 'dedupe',
  335. 'default-data-readers',
  336. 'definline',
  337. 'definterface',
  338. 'defmacro',
  339. 'defmethod',
  340. 'defmulti',
  341. 'defn',
  342. 'defn-',
  343. 'defonce',
  344. 'defprotocol',
  345. 'defrecord',
  346. 'defstruct',
  347. 'deftype',
  348. 'delay',
  349. 'delay?',
  350. 'deliver',
  351. 'denominator',
  352. 'deref',
  353. 'derive',
  354. 'descendants',
  355. 'destructure',
  356. 'disj',
  357. 'disj!',
  358. 'dissoc',
  359. 'dissoc!',
  360. 'distinct',
  361. 'distinct?',
  362. 'doall',
  363. 'dorun',
  364. 'doseq',
  365. 'dosync',
  366. 'dotimes',
  367. 'doto',
  368. 'double',
  369. 'double-array',
  370. 'double?',
  371. 'doubles',
  372. 'drop',
  373. 'drop-last',
  374. 'drop-while',
  375. 'eduction',
  376. 'empty',
  377. 'empty?',
  378. 'ensure',
  379. 'ensure-reduced',
  380. 'enumeration-seq',
  381. 'error-handler',
  382. 'error-mode',
  383. 'eval',
  384. 'even?',
  385. 'every-pred',
  386. 'every?',
  387. 'ex-data',
  388. 'ex-info',
  389. 'extend',
  390. 'extend-protocol',
  391. 'extend-type',
  392. 'extenders',
  393. 'extends?',
  394. 'false?',
  395. 'ffirst',
  396. 'file-seq',
  397. 'filter',
  398. 'filterv',
  399. 'find',
  400. 'find-keyword',
  401. 'find-ns',
  402. 'find-protocol-impl',
  403. 'find-protocol-method',
  404. 'find-var',
  405. 'first',
  406. 'flatten',
  407. 'float',
  408. 'float-array',
  409. 'float?',
  410. 'floats',
  411. 'flush',
  412. 'fn',
  413. 'fn?',
  414. 'fnext',
  415. 'fnil',
  416. 'for',
  417. 'force',
  418. 'format',
  419. 'frequencies',
  420. 'future',
  421. 'future-call',
  422. 'future-cancel',
  423. 'future-cancelled?',
  424. 'future-done?',
  425. 'future?',
  426. 'gen-class',
  427. 'gen-interface',
  428. 'gensym',
  429. 'get',
  430. 'get-in',
  431. 'get-method',
  432. 'get-proxy-class',
  433. 'get-thread-bindings',
  434. 'get-validator',
  435. 'group-by',
  436. 'halt-when',
  437. 'hash',
  438. 'hash-combine',
  439. 'hash-map',
  440. 'hash-ordered-coll',
  441. 'hash-set',
  442. 'hash-unordered-coll',
  443. 'ident?',
  444. 'identical?',
  445. 'identity',
  446. 'if-let',
  447. 'if-not',
  448. 'if-some',
  449. 'ifn?',
  450. 'import',
  451. 'in-ns',
  452. 'inc',
  453. "inc'",
  454. 'indexed?',
  455. 'init-proxy',
  456. 'inst-ms',
  457. 'inst-ms*',
  458. 'inst?',
  459. 'instance?',
  460. 'int',
  461. 'int-array',
  462. 'int?',
  463. 'integer?',
  464. 'interleave',
  465. 'intern',
  466. 'interpose',
  467. 'into',
  468. 'into-array',
  469. 'ints',
  470. 'io!',
  471. 'isa?',
  472. 'iterate',
  473. 'iterator-seq',
  474. 'juxt',
  475. 'keep',
  476. 'keep-indexed',
  477. 'key',
  478. 'keys',
  479. 'keyword',
  480. 'keyword?',
  481. 'last',
  482. 'lazy-cat',
  483. 'lazy-seq',
  484. 'let',
  485. 'letfn',
  486. 'line-seq',
  487. 'list',
  488. 'list*',
  489. 'list?',
  490. 'load',
  491. 'load-file',
  492. 'load-reader',
  493. 'load-string',
  494. 'loaded-libs',
  495. 'locking',
  496. 'long',
  497. 'long-array',
  498. 'longs',
  499. 'loop',
  500. 'macroexpand',
  501. 'macroexpand-1',
  502. 'make-array',
  503. 'make-hierarchy',
  504. 'map',
  505. 'map-entry?',
  506. 'map-indexed',
  507. 'map?',
  508. 'mapcat',
  509. 'mapv',
  510. 'max',
  511. 'max-key',
  512. 'memfn',
  513. 'memoize',
  514. 'merge',
  515. 'merge-with',
  516. 'meta',
  517. 'method-sig',
  518. 'methods',
  519. ]
  520. var coreSymbols2 = [
  521. 'min',
  522. 'min-key',
  523. 'mix-collection-hash',
  524. 'mod',
  525. 'munge',
  526. 'name',
  527. 'namespace',
  528. 'namespace-munge',
  529. 'nat-int?',
  530. 'neg-int?',
  531. 'neg?',
  532. 'newline',
  533. 'next',
  534. 'nfirst',
  535. 'nil?',
  536. 'nnext',
  537. 'not',
  538. 'not-any?',
  539. 'not-empty',
  540. 'not-every?',
  541. 'not=',
  542. 'ns',
  543. 'ns-aliases',
  544. 'ns-imports',
  545. 'ns-interns',
  546. 'ns-map',
  547. 'ns-name',
  548. 'ns-publics',
  549. 'ns-refers',
  550. 'ns-resolve',
  551. 'ns-unalias',
  552. 'ns-unmap',
  553. 'nth',
  554. 'nthnext',
  555. 'nthrest',
  556. 'num',
  557. 'number?',
  558. 'numerator',
  559. 'object-array',
  560. 'odd?',
  561. 'or',
  562. 'parents',
  563. 'partial',
  564. 'partition',
  565. 'partition-all',
  566. 'partition-by',
  567. 'pcalls',
  568. 'peek',
  569. 'persistent!',
  570. 'pmap',
  571. 'pop',
  572. 'pop!',
  573. 'pop-thread-bindings',
  574. 'pos-int?',
  575. 'pos?',
  576. 'pr',
  577. 'pr-str',
  578. 'prefer-method',
  579. 'prefers',
  580. 'primitives-classnames',
  581. 'print',
  582. 'print-ctor',
  583. 'print-dup',
  584. 'print-method',
  585. 'print-simple',
  586. 'print-str',
  587. 'printf',
  588. 'println',
  589. 'println-str',
  590. 'prn',
  591. 'prn-str',
  592. 'promise',
  593. 'proxy',
  594. 'proxy-call-with-super',
  595. 'proxy-mappings',
  596. 'proxy-name',
  597. 'proxy-super',
  598. 'push-thread-bindings',
  599. 'pvalues',
  600. 'qualified-ident?',
  601. 'qualified-keyword?',
  602. 'qualified-symbol?',
  603. 'quot',
  604. 'rand',
  605. 'rand-int',
  606. 'rand-nth',
  607. 'random-sample',
  608. 'range',
  609. 'ratio?',
  610. 'rational?',
  611. 'rationalize',
  612. 're-find',
  613. 're-groups',
  614. 're-matcher',
  615. 're-matches',
  616. 're-pattern',
  617. 're-seq',
  618. 'read',
  619. 'read-line',
  620. 'read-string',
  621. 'reader-conditional',
  622. 'reader-conditional?',
  623. 'realized?',
  624. 'record?',
  625. 'reduce',
  626. 'reduce-kv',
  627. 'reduced',
  628. 'reduced?',
  629. 'reductions',
  630. 'ref',
  631. 'ref-history-count',
  632. 'ref-max-history',
  633. 'ref-min-history',
  634. 'ref-set',
  635. 'refer',
  636. 'refer-clojure',
  637. 'reify',
  638. 'release-pending-sends',
  639. 'rem',
  640. 'remove',
  641. 'remove-all-methods',
  642. 'remove-method',
  643. 'remove-ns',
  644. 'remove-watch',
  645. 'repeat',
  646. 'repeatedly',
  647. 'replace',
  648. 'replicate',
  649. 'require',
  650. 'reset!',
  651. 'reset-meta!',
  652. 'reset-vals!',
  653. 'resolve',
  654. 'rest',
  655. 'restart-agent',
  656. 'resultset-seq',
  657. 'reverse',
  658. 'reversible?',
  659. 'rseq',
  660. 'rsubseq',
  661. 'run!',
  662. 'satisfies?',
  663. 'second',
  664. 'select-keys',
  665. 'send',
  666. 'send-off',
  667. 'send-via',
  668. 'seq',
  669. 'seq?',
  670. 'seqable?',
  671. 'seque',
  672. 'sequence',
  673. 'sequential?',
  674. 'set',
  675. 'set-agent-send-executor!',
  676. 'set-agent-send-off-executor!',
  677. 'set-error-handler!',
  678. 'set-error-mode!',
  679. 'set-validator!',
  680. 'set?',
  681. 'short',
  682. 'short-array',
  683. 'shorts',
  684. 'shuffle',
  685. 'shutdown-agents',
  686. 'simple-ident?',
  687. 'simple-keyword?',
  688. 'simple-symbol?',
  689. 'slurp',
  690. 'some',
  691. 'some->',
  692. 'some->>',
  693. 'some-fn',
  694. 'some?',
  695. 'sort',
  696. 'sort-by',
  697. 'sorted-map',
  698. 'sorted-map-by',
  699. 'sorted-set',
  700. 'sorted-set-by',
  701. 'sorted?',
  702. 'special-symbol?',
  703. 'spit',
  704. 'split-at',
  705. 'split-with',
  706. 'str',
  707. 'string?',
  708. 'struct',
  709. 'struct-map',
  710. 'subs',
  711. 'subseq',
  712. 'subvec',
  713. 'supers',
  714. 'swap!',
  715. 'swap-vals!',
  716. 'symbol',
  717. 'symbol?',
  718. 'sync',
  719. 'tagged-literal',
  720. 'tagged-literal?',
  721. 'take',
  722. 'take-last',
  723. 'take-nth',
  724. 'take-while',
  725. 'test',
  726. 'the-ns',
  727. 'thread-bound?',
  728. 'time',
  729. 'to-array',
  730. 'to-array-2d',
  731. 'trampoline',
  732. 'transduce',
  733. 'transient',
  734. 'tree-seq',
  735. 'true?',
  736. 'type',
  737. 'unchecked-add',
  738. 'unchecked-add-int',
  739. 'unchecked-byte',
  740. 'unchecked-char',
  741. 'unchecked-dec',
  742. 'unchecked-dec-int',
  743. 'unchecked-divide-int',
  744. 'unchecked-double',
  745. 'unchecked-float',
  746. 'unchecked-inc',
  747. 'unchecked-inc-int',
  748. 'unchecked-int',
  749. 'unchecked-long',
  750. 'unchecked-multiply',
  751. 'unchecked-multiply-int',
  752. 'unchecked-negate',
  753. 'unchecked-negate-int',
  754. 'unchecked-remainder-int',
  755. 'unchecked-short',
  756. 'unchecked-subtract',
  757. 'unchecked-subtract-int',
  758. 'underive',
  759. 'unquote',
  760. 'unquote-splicing',
  761. 'unreduced',
  762. 'unsigned-bit-shift-right',
  763. 'update',
  764. 'update-in',
  765. 'update-proxy',
  766. 'uri?',
  767. 'use',
  768. 'uuid?',
  769. 'val',
  770. 'vals',
  771. 'var-get',
  772. 'var-set',
  773. 'var?',
  774. 'vary-meta',
  775. 'vec',
  776. 'vector',
  777. 'vector-of',
  778. 'vector?',
  779. 'volatile!',
  780. 'volatile?',
  781. 'vreset!',
  782. 'vswap!',
  783. 'when',
  784. 'when-first',
  785. 'when-let',
  786. 'when-not',
  787. 'when-some',
  788. 'while',
  789. 'with-bindings',
  790. 'with-bindings*',
  791. 'with-in-str',
  792. 'with-loading-context',
  793. 'with-local-vars',
  794. 'with-meta',
  795. 'with-open',
  796. 'with-out-str',
  797. 'with-precision',
  798. 'with-redefs',
  799. 'with-redefs-fn',
  800. 'xml-seq',
  801. 'zero?',
  802. 'zipmap',
  803. ]
  804. MT('should highlight core symbols as keywords (part 1/2)', typeTokenPairs('keyword', coreSymbols1))
  805. MT('should highlight core symbols as keywords (part 2/2)', typeTokenPairs('keyword', coreSymbols2))
  806. MT(
  807. 'should properly indent forms in list literals',
  808. '[bracket (][builtin foo] [atom :a] [number 1] [atom true] [atom nil][bracket )]',
  809. '',
  810. '[bracket (][builtin foo] [atom :a]',
  811. ' [number 1]',
  812. ' [atom true]',
  813. ' [atom nil][bracket )]',
  814. '',
  815. '[bracket (][builtin foo] [atom :a] [number 1]',
  816. ' [atom true]',
  817. ' [atom nil][bracket )]',
  818. '',
  819. '[bracket (]',
  820. ' [builtin foo]',
  821. ' [atom :a]',
  822. ' [number 1]',
  823. ' [atom true]',
  824. ' [atom nil][bracket )]',
  825. '',
  826. '[bracket (][builtin foo] [bracket [[][atom :a][bracket ]]]',
  827. ' [number 1]',
  828. ' [atom true]',
  829. ' [atom nil][bracket )]'
  830. )
  831. MT(
  832. 'should properly indent forms in vector literals',
  833. '[bracket [[][atom :a] [number 1] [atom true] [atom nil][bracket ]]]',
  834. '',
  835. '[bracket [[][atom :a]',
  836. ' [number 1]',
  837. ' [atom true]',
  838. ' [atom nil][bracket ]]]',
  839. '',
  840. '[bracket [[][atom :a] [number 1]',
  841. ' [atom true]',
  842. ' [atom nil][bracket ]]]',
  843. '',
  844. '[bracket [[]',
  845. ' [variable foo]',
  846. ' [atom :a]',
  847. ' [number 1]',
  848. ' [atom true]',
  849. ' [atom nil][bracket ]]]'
  850. )
  851. MT(
  852. 'should properly indent forms in map literals',
  853. '[bracket {][atom :a] [atom :a] [atom :b] [number 1] [atom :c] [atom true] [atom :d] [atom nil] [bracket }]',
  854. '',
  855. '[bracket {][atom :a] [atom :a]',
  856. ' [atom :b] [number 1]',
  857. ' [atom :c] [atom true]',
  858. ' [atom :d] [atom nil][bracket }]',
  859. '',
  860. '[bracket {][atom :a]',
  861. ' [atom :a]',
  862. ' [atom :b]',
  863. ' [number 1]',
  864. ' [atom :c]',
  865. ' [atom true]',
  866. ' [atom :d]',
  867. ' [atom nil][bracket }]',
  868. '',
  869. '[bracket {]',
  870. ' [atom :a] [atom :a]',
  871. ' [atom :b] [number 1]',
  872. ' [atom :c] [atom true]',
  873. ' [atom :d] [atom nil][bracket }]'
  874. )
  875. MT(
  876. 'should properly indent forms in set literals',
  877. '[meta #][bracket {][atom :a] [number 1] [atom true] [atom nil] [bracket }]',
  878. '',
  879. '[meta #][bracket {][atom :a]',
  880. ' [number 1]',
  881. ' [atom true]',
  882. ' [atom nil][bracket }]',
  883. '',
  884. '[meta #][bracket {]',
  885. ' [atom :a]',
  886. ' [number 1]',
  887. ' [atom true]',
  888. ' [atom nil][bracket }]'
  889. )
  890. var haveBodyParameter = [
  891. '->',
  892. '->>',
  893. 'as->',
  894. 'binding',
  895. 'bound-fn',
  896. 'case',
  897. 'catch',
  898. 'cond',
  899. 'cond->',
  900. 'cond->>',
  901. 'condp',
  902. 'def',
  903. 'definterface',
  904. 'defmethod',
  905. 'defn',
  906. 'defmacro',
  907. 'defprotocol',
  908. 'defrecord',
  909. 'defstruct',
  910. 'deftype',
  911. 'do',
  912. 'doseq',
  913. 'dotimes',
  914. 'doto',
  915. 'extend',
  916. 'extend-protocol',
  917. 'extend-type',
  918. 'fn',
  919. 'for',
  920. 'future',
  921. 'if',
  922. 'if-let',
  923. 'if-not',
  924. 'if-some',
  925. 'let',
  926. 'letfn',
  927. 'locking',
  928. 'loop',
  929. 'ns',
  930. 'proxy',
  931. 'reify',
  932. 'some->',
  933. 'some->>',
  934. 'struct-map',
  935. 'try',
  936. 'when',
  937. 'when-first',
  938. 'when-let',
  939. 'when-not',
  940. 'when-some',
  941. 'while',
  942. 'with-bindings',
  943. 'with-bindings*',
  944. 'with-in-str',
  945. 'with-loading-context',
  946. 'with-local-vars',
  947. 'with-meta',
  948. 'with-open',
  949. 'with-out-str',
  950. 'with-precision',
  951. 'with-redefs',
  952. 'with-redefs-fn',
  953. ]
  954. function testFormsThatHaveBodyParameter(forms) {
  955. for (var i = 0; i < forms.length; i++) {
  956. MT(
  957. 'should indent body argument of `' + forms[i] + '` by `options.indentUnit` spaces',
  958. '[bracket (][keyword ' + forms[i] + '] [variable foo] [variable bar]',
  959. ' [variable baz]',
  960. ' [variable qux][bracket )]'
  961. )
  962. }
  963. }
  964. testFormsThatHaveBodyParameter(haveBodyParameter)
  965. MT('should indent body argument of `comment` by `options.indentUnit` spaces', '[bracket (][comment comment foo bar]', '[comment baz]', '[comment qux][bracket )]')
  966. function typeTokenPairs(type, tokens) {
  967. return '[' + type + ' ' + tokens.join('] [' + type + ' ') + ']'
  968. }
  969. })()