marick/Midje — Issue #58: Problem with sorted maps
Author: ath
Created: 2011-11-02 15:12:34+00:00
State: open

I am using :dev-dependencies [[midje "1.3-alpha4"]] and the midje-mode in Emacs.
After some experimenting I came up with this test case:

(defn foo []
(sorted-map :a 1, :b 2, :c 3))

(defn bar []
{:a 1, :b 2, :c 3})

(fact
(foo) => (bar))

This works fine, as expected.
But when I change bar to

(defn bar []
{:a 1, :b 2, :c 4}) ; key for :c changed from 3 to 4

and check that fact again, I run into this:

clojure.lang.Keyword cannot be cast to java.lang.String
[Thrown class java.lang.ClassCastException]

Restarts:
0: [QUIT] Quit to the SLIME top level

Backtrace:
0: java.lang.String.compareTo(Unknown Source)
1: clojure.lang.Util.compare(Util.java:104)
2: clojure.lang.RT$DefaultComparator.compare(RT.java:265)
3: clojure.lang.PersistentTreeMap.doCompare(PersistentTreeMap.java:302)
4: clojure.lang.PersistentTreeMap.entryAt(PersistentTreeMap.java:289)
5: clojure.lang.PersistentTreeMap.valAt(PersistentTreeMap.java:269)
6: clojure.lang.PersistentTreeMap.valAt(PersistentTreeMap.java:274)
7: clojure.lang.APersistentMap.invoke(APersistentMap.java:177)
8: midje.checkers.util$captured_exception_QMARK_.invoke(util.clj:18)
9: midje.util.report$attractively_stringified_form.invoke(report.clj:50)
10: midje.util.report$eval3898$fn__3899.invoke(report.clj:88)
11: clojure.lang.MultiFn.invoke(MultiFn.java:163)
12: midje.util.report$render.invoke(report.clj:138)
13: midje.util.report$eval3931$fn__3932.invoke(report.clj:143)
14: clojure.lang.MultiFn.invoke(MultiFn.java:163)
15: midje.unprocessed$eval3947$fn__3948.invoke(unprocessed.clj:43)
16: clojure.lang.MultiFn.invoke(MultiFn.java:167)
17: midje.unprocessed$expect_STAR_$fn__3961.invoke(unprocessed.clj:78)
18: midje.util.thread_safe_var_nesting$with_altered_roots_STAR_.invoke(thread_safe_var_nesting.clj:38)
19: midje.unprocessed$expect_STAR_.invoke(unprocessed.clj:73)
20: stats.test.core$eval5304$fn__5305.invoke(NO_SOURCE_FILE:1)
21: midje.util.thread_safe_var_nesting$with_altered_roots_STAR_.invoke(thread_safe_var_nesting.clj:38)
22: stats.test.core$eval5304.invoke(NO_SOURCE_FILE:1)
23: clojure.lang.Compiler.eval(Compiler.java:6465)
24: clojure.lang.Compiler.eval(Compiler.java:6454)
25: clojure.lang.Compiler.eval(Compiler.java:6431)
26: clojure.core$eval.invoke(core.clj:2795)
27: swank.core$eval680$fn__681.invoke(core.clj:409)
28: clojure.lang.MultiFn.invoke(MultiFn.java:163)
29: swank.commands.basic$eval_region.invoke(basic.clj:48)
30: swank.commands.basic$eval_region.invoke(basic.clj:38)
31: swank.commands.basic$eval995$eval_and_grab_output__996$fn__997.invoke(basic.clj:83)
32: swank.commands.basic$eval995$eval_and_grab_output__996.invoke(basic.clj:82)
33: clojure.lang.Var.invoke(Var.java:401)
34: stats.test.core$eval5300.invoke(NO_SOURCE_FILE)
35: clojure.lang.Compiler.eval(Compiler.java:6465)
36: clojure.lang.Compiler.eval(Compiler.java:6431)
37: clojure.core$eval.invoke(core.clj:2795)
38: swank.core$eval_in_emacs_package.invoke(core.clj:94)
39: swank.core$eval_for_emacs.invoke(core.clj:241)
40: clojure.lang.Var.invoke(Var.java:409)
41: clojure.lang.AFn.applyToHelper(AFn.java:167)
42: clojure.lang.Var.applyTo(Var.java:518)
43: clojure.core$apply.invoke(core.clj:600)
44: swank.core$eval_from_control.invoke(core.clj:101)
45: swank.core$spawn_worker_thread$fn__603$fn__604.invoke(core.clj:309)
46: clojure.lang.AFn.applyToHelper(AFn.java:159)
47: clojure.lang.AFn.applyTo(AFn.java:151)
48: clojure.core$apply.invoke(core.clj:600)
49: swank.core$spawn_worker_thread$fn__603.doInvoke(core.clj:305)
50: clojure.lang.RestFn.invoke(RestFn.java:397)
51: clojure.lang.AFn.run(AFn.java:24)
52: java.lang.Thread.run(Unknown Source)